#archived-dots
1 messages ยท Page 284 of 1
ah no, that is not what i want lol
i have an entity with a desired z axis rotation, i have a gameobject that needs it
turns out that is a nightmare to do
i know im being an idiot and that there is a simple solution to my issue somewhere, but what the solution is has evaded me for 3 days now
im going a tad insane at this point
you want to rotate to this z axis or just set?
just set
and the xy from the entity doesn't matter?
do you have a Rotation comp or just quat?
on the entity, i am using the rotation component yes
seems a lot more accurate than the rotation from any of the tranform components
so that means you also have a LocalToWorld comp. (makes it easier to get the forward
the go rotation xy should stay the same?
yes
Transform goTransform;
float3 forward = entityLTW.Forward;
float3 goForward = goTransform.forward;
var newRot = quaternion.LookRotationSafe(new float3(goForward.x, goForward.y, forward.z), new float3(0, 1, 0));```
you can apply the newRot to your go.transform.rotation then
there was something i want to try first, incase im a huge idiot, as i made an assumption that because transform rotation when converted to euler angles was broken, that rotation to euler angles would be aswell, but this may not be the case i realise, so let me try incase i am an idiot first
don't calculate with euler angles. it will start to drift no matter what
quaternion exists for a reason
basically you can't go from quat to euler and then from euler to quat without float inaccuracy
float innaccuracy doesnt matter too much here, i think, as long as it is only within .01 inaccuracy it will be fine
feel free to try ๐
ill try, and if it doesnt work, ill come back and try your solution
hmm that is inaccurate, im getting an accuracy that is randomly wrong by anywhere from 0.01 to literal hundreds of numbers wrong, i mean how do we go from 1 to 203, that is an insane floating point error to the point of stupidity
float is pain
yup it appears they are, although i still dont get how they jump from 1 to 203...
they are the worst, how do you floating point error with over a 100?
at that point even ints can have better precision!!!
fixed point is good, and bad
float absolute are fine but relative, over severl frames the inaccuracy quickly adds up
i guess, but i would assume them to reset
as im telling them the same value, so logicaly it should have the same innaccuracy each time?
anyway, guess ill now try this considering how it is my last option
what am I looking at? this looks funky
floating point error following a frac() visualized
it's jumping between 0.0001 and 0.9999 every other pixel
because frac causes a wrap around at 1, normally it's 1.0001 and 0.9999.
hitAngle = hitAngle > 0.99 ? 0 : hitAngle; I just clamp high enough values to 0 to prevent that visualization
it's also partially due to floating point error emerging from ddx() as well so it's floating point error^2.
how exactly would i go about this, guessing something like: ```csharp
go.transform.rotation = newRot;
yeah
aha, didnt work
i mean it did something
not exactly what i had wanted though
it changed the x and y rotation, didnt change the z rotation
so kinda the opposite of what was wanted
oh it is way weirder though than just being the opposite though
how can it change the xy rot of the go when the same xy rot is applied?
i dont know
but it is
and it is weirder than that though
i change the y value of the rotation of the game object in the inspector, it resets to 70 or 250, whichever is closest, and then changes the x angle to something random
whats your code now?
var new_rot = quaternion.LookRotationSafe(new float3(sync_forward.x, sync_forward.y, ent_forward.z), new float3(0, 1, 0));
sync_objects[sync_comp.sync_id].transform.rotation = new_rot;
these are how the ent forward and sync forward are defined:```csharp
float3 ent_forward = pos_transform.Forward;
float3 sync_forward = sync_objects[sync_comp.sync_id].transform.forward;
dont worry about my weird naming schemes, they make sense to me, although probably no one else
any ideas on why it isnt working?
imma probably go make breakfast now, so ill read your answer afterwards, sorry lol
hm, i'll have to think about it
wasn't thinking hard enough about it because when you want to get the z-axis(roll) the up vector is actually not 0,1,0. you can get the Up from the LTW too and use instead of the 0,1,0
another try: var new_rot = quaternion.LookRotationSafe(new float3(sync_forward.x, sync_forward.y, ent_forward.z), pos_transform.Up); assuming pos_transform is your LTW
yes pos_transform is my ltw, ill try that and report back, thank you!
OH MY IT WORKS!!!!!
Thank you so much!!!!!
you are the best!
thanks lol so much
im trying to create a water gun, to do this im instantiating some spheres with a lot of initial velocity in the z direction, this should cause them to go flying in the z direction as soon as they spawn right?
that is what i would assume, unfortunately this does not appear to be the case
seems to be missing the rotation, isn't it? i'm actually not sure is this is in local or world space. i'd assume it's world space
good point, ill mess around with it some more!
Does anyone know why Variable Rate Simulation System Group was added? Was there a problem they are solving with it? Just curious cause it's empty apart from the command buffers
perhaps just a bunch of people were asking for it or something..
wondering, to burst compile adding forces to rigidbodies is there anything special i need to do, or will burst auto do it?
also how do i add transforms to a component?
if you're in a burst compiled job, then it will do it
everything in a burst compiled job is run by burst (as long as burst is enabled)
unless it is a structural change that is
if you're trying to do something burst can't do, it will complain at you ๐
if you haven't specified (without burst) or anything, and burst is enabled, then you can assume burst is running
and if you want to know for sure you can check the burst debugger
if you want to make structural changes, you are probably using EntityManager directly. Burst will complain if you try to do that in a burst job
otherwise you are probably using an entity command buffer, which is burst compatible cause the structural change happens later
woah cool, thanks for the knowledge!
is there a primitive or bittible way of getting a game object or transform?
specifically for icomponentdata
transforms and gameobjects are managed, that's monobehaviour land. You can work with these things in ECS if you REALLY want to but to work with burst you need to used unmanaged types
ah that is annoying
So you can put them in an IComponentData, as long as it is a CLASS IComponentData, and you dont' try to access it with burst
welp, i need burst so that is unfortunate
I can't remember if you can jobify class icomponentdata
cause my player is a game object, and i need the camera's tranform.forward, to use for aiming a water gun that is an entity
oh that is clever!
instead of trying to pass in the entire transform
ok, so how would i do that though?
are you using systems, or just jobs in monobehaviour code?
systems unfortunately
either way, in the 'update', before the actual job code, just get a float3 cameraDirection
how though?
from, for example, Camera.main.transform.forward
cool lol, i had no clue, this shall be a lot easier, thanks so much!
No problem
Careful
Camera.main
Is just
Object.FindObectOfType Camera and then compare tag for MainCamera
Hm
In contrived test cases containing 50,000 objects, we saw speed increase by 21,000x to 51,000x.
only slightly improved
lol
how does main camera work now, as i want to make certain that i dont accidentally choose my main menu camera instead of my player camera
also what do i need to import with using to get Camera.main?
It's efficient enough for your needs ๐
just write the line and if you need a using your ide will tell you, pretty sure it's UnityEngine though
my ide did not tell me, but thanks it is UnityEngine!
huh i always thought that on update ran automatically but apparrently it does not in system bases, how do you make something run every frame in a system base?
it runs only if there's required query (if it exist), which added automatically through code
but can be overriden through RequireForUpdate
also
there's attribute
AlwaysUpdateSystem
ooh how can i use that, cause i have a query and multiple debug logs, and it aint running any of them
which bypasses that
i just want to use a for entity loop
oh that is annoying, that means that i have no physics objects in my scene
you call it only through foreach lambda
hmmm, how do i add physics object, real ones, not rigidbodies which dont count as physics objects for some reason?
I'm not sure what you mean by that
i mean like how do you create a real physic object that can be detected by Unity.Physics
ahem
do you know that ECS Physics and Classic Physics exist in 2 different dimensions?
yes, and im using ecs physics, atleast i hope so
then I have no idea what is your problem
neither do i, but apparrently physics bodies are not physic objects
what defines physics objects?
then they are
?
physics shape and physics body
not according to my for each entity loop they aint
what is your loop?
Entities
.WithName("fluid_destroy_system")
.ForEach((Entity particle, ref PhysicsVelocity physics_velocity, ref PhysicsMass physics_mass, ref shoot_particle_component shoot_comp) =>
{
if (!shoot_comp.has_fired)
{
shoot_comp.has_fired = true;
var force_vector = direction * shoot_comp.force_amount; //* delta_time;
physics_velocity.ApplyLinearImpulse(physics_mass, force_vector);
Debug.Log("added force");
}
})
.Run();
exactly i have no way of knowing
ooh ill try that
cause currently all i know is that they have the shoot particle component and a physics body and shape
i think i have bigger issues
over 999 likely leaks
although it came out correctly in the debugger, they have all the components
it just does not want to run the for each loop for some reason
weird
you got any ideas?
hmm it seems nothing i try has any different results, odd
although the whole leak thing appears to randomly happen sometimes, and not others
are you sure it's not running?
your log is under conditional
you can see whether system is running or not
in debugger
if system has time instead -
in profiler
that means OnUpdate is called
100% i know cause i have a log on the beginning of on update
and it never runs
ok i shall, where on earth is the debugger thing?
it will at least tell you all relationships with entities
relationships tab
nice, how do i give them those components
that does not help
i know how to add i component data components, that is the 1 component they do have
it is the 2 physic's components they dont have
and i dont know how to give it to them
any ideas?
yes, mine have both of those
can you show it?
ill try
and now suddenly it loses the 1 component i was certain there would be, let me recompile it, and restart unity, due to how annoying components are to make
wish components were easy, but they are nightmares to make
components are literally just structs with fields, hehe
yes, but it way more complex than that
it shouldn't be
half the time they compile incorrectly and you have to restart unity, and then change something in them so that it then attempts to recompile
they are nightmares
lucky
example of a component that unity says it cant compile for seemingly no reason, cause there is no error: ```csharp
using Unity.Entities;
[GenerateAuthoringComponent]
public struct shoot_particle_component : IComponentData
{
public bool has_fired;
public float force_amount;
}
that is certainly not smth most people from here encounter either
welp guess im just bad then
i dont get it
are you using ctrl+R hotkey?
no?
it's also reimport option through right click in folders
welp thank you!
and sometimes like now, i just cant seem to get the component to work
it just wont
it is refusing
File must be same name as component
or else MonoBehaviour
will not be created
or actually, it won't be seen by Editor
i think they are the same name
well it can be seen in the editor
i dont get how to make components
i just dont get it
they are nightmares
i avoid them when possible, but in cases like now, they are useful, even if they are a pain
that is one thing that ecs needs to fix fast
cause the longer components are a pain, the less i like using ecs
mono behaviours might be slow, but atleast they work first try, rather then the hours or days i have to spend getting a single component to work
exactly, hence why i hate components
they work randomly
never consistent
you get a game object, you tell it to conver to an entity, you attatch a component to it, what happens next can go 1 of 2 ways:
a: it works and the entity has a component
b (more likely): the entity has no component
it is pointless to try debugging, because there is no issue to solve, randomly removing and adding the component and changing the order of lines in the component code, and eventually it solves itself
problem is this takes hours, sometimes days
that is exactly what debugging is supposed to solve
yet is doesn't
and i dont get how to debug
caue the debugger tells me obvious stuff only, such as the component being or not being there
nothing else
if there is more to the debugger which i dont get, speak now, or forever hold your peace
are you familiar with breakpoints?
somewhat, i crashed my computer the first 3 times while attempting to use them, then never touched them since
you going to explain further?
it is a somewhat essential tool for debugging ๐
you should look it up on youtube or smth, I won't be able to explain it, as it's tutorials heavily depend on IDE you use
ok, welp im gonna have to set up a new ide then
cause my current ide when doing break points freezes my computer to the point where i have to power button it
ok well that's not good lol
ye, my computer is a tad old
the only reason i even started using and learning dots was to try and get decent framerate
motivated by your old hardware. interesting ^^;
yup lol
oh well if i can optimize my games on this computer, imagine how well it will run on normal and good computers
i suppose i better go now do some research into which ide uses the least proccessing power for break points
oh god please don't pick your ide on this criteria ๐
i install multiple ides, each one optimized for a certain purpose in developing my game
it is a tad annoying sure, but required in my case
terrifying
very, although imo not as bad as omnisharp in visual studio code
i hate omnisharp with a burning passion
I get using different IDEs if you need a feature another doesn't have, but like "which one processes breakpoints the fastest*
T_T
sure
Yea that would be cool, don't know if it's possible though. You could create a script template in your IDE so you don't have to write as much boilerplate.
oh man
I just came up with a nice way for workflow, heh
Imagine creating world instance as GameObject, where you can define serialized System Instances that will direct references to assets/objects
that would be cool lol
Assert.IsTrue(catalogData.IsCreated, "The scene catalog has not been loaded yet");
return catalogData.Value.GetGUIDFromPath(scenePath);
hmm
why is it getting triggered?
android build
SceneSystem
also this
Failed to load native plugin: Unable to lookup library path for 'lib_burst_0_0'.
I have an abstract system that implements methods to automatically get an ECB and register dependencies, and then systems can inherit that system
put it in fixed update group
i do this in my AI authoring. basically i have scriptable objects that create instances of systems with queries i can define in that scriptable object.
huh
So i dont have to write any AI systems anymore. i just define a system in that SO and it works
yeah I kind of want to do that too.
Instead of creating world through custom bootstrap
i never looked at DOTS scritping but id imagine it was kinda similar
How many entities?
Hey folks, i'm destroying some child entities during Convert, but the parenting system is throwing an error about the entities not existing - is there a proper way to destroy during conversion?
Yeah one thing i noticed with havok is it has sleeping, which will give some gains where bodies aren't moving around
Only thing is the determinism thing if it's going to be networked
What kind of colliders are they and are there joints?
30k is quite a lot tbf
last test i did was around 12k i think with reasonable rates
haven't looked at optimizing though
that was literally just a quick, dump a bunch of objects in a scene and test
this is i think around 12k bricks and 800 ragdolls
with that particular test, the sleeping capability of havok definitely had an impact, over unity physics, but i've found unity physics to be quite decent and in some cases better
other thing is maybe tweak iterations, but beyond that i'm going to start looking into some optimizations myself pretty soon
i'm not exactly sure on that, but definitely by default unity will respawn the whole build world system etc multiple times per frame if things invalidate the world or need rebuilt
something interesting with the physics samples is they set the fixedrate manager to null, which i think kinda forces a single build world per frame
i think application target framerate might have some impact, but still not sure on this tbh
how is it possible that the mere existence of entities can bring down the whole playerloop? (around 6ms) I thought that's not possible. There's no work done on these entities. (and they are a LOT 7.25 million) - still, should only be memory?
my ai job alone goes from 0.6 to 2.2ms - I don't get it, timeline looks very similar so it's not that some thread seems clogged up
are they maybe part of a query even if the work is not being done?
good thinking, i removed the query. still the same. also closed the dots hierarchy window (wasn't focused) and also still the same
i cannot for the life of me find where i spotted this in the samples, but i'm sure that's where i seen it originally :shrugs:
updating a system in FixedStepSimulation group
it's a sub group of Simulation system group
are burst safety checks on and jobs debugger
I wonder if entity journaling can be related
Anybody have any insight into this?
RequireForUpdate(
GetEntityQuery(new EntityQueryDesc
{
All = new[] { ComponentType.ReadOnly<PlayerTag>() },
Options = EntityQueryOptions.FilterWriteGroup
}));
hmmm
I wonder how that would work
I have it disabled ๐ฆ
so? you can put as much as you want in there. Simulation System Group will always run on every frame.
what the? am I the only one having broken BuildConfiguration? If I want to Add Component the window doesn't update.
is this a 2021.3.5f1 thing?
god damn
annoying
you can try create whatever assets you want in 2020
and then import them into your project
yep, I see no other way ๐คฃ
you can also use search
if you know exactly name of component
it'll just be on top
of hiearchy
and you can blindly pick it
ah good thinking. I want to set the build to what was it called, smaller buildsize or smth. so the generics bug isn't happening
Have you tried select IL2CPP build type to Faster(Smaller) Build??
Where do I set this in a BuildConf?
is there a built in way to tag a child object to not be converted, say a child of a prefab
i'd like to use a child gameobject as a reference for position, store the value during Convert, but not have that dummy child object be converted to entity
tried destroying the entity with dst manager during Convert, throws an error because the parent system is expecting that entity, tried Object.Destroy but it doesn't like it much either.. final solution is tag it with a custom DestroyThis tag and have a LateDestroy system which runs after Transform and destroys the entities
final solution works but just wondering if theres, like, a way already for this
just destroy entity during conversion
converted subscene won't have it
it's not in a subscene as yet.. and as i say because the conversionSystem has already picked up the object and marked it for inclusion in the parenting system, destroying the primary entity during Convert causes an error when the parenting system then looks for that entity
so if there was some way to mark that child object to be ignored by the conversion system it'd save some work
so kinda like the opposite of applying a ConvertToEntity component to the gameobject
screw it I'm going back to 2020.3. They have really botched this release
remember all 2020 bugs before you do it xD
huh? 2020.3 was totally stable for me.
i like the snapiness and speed of 2021 but with those weird ui glitches and build problems I'll have to postpone it somewhat. Hopefully next Wednesday they have a fixed version.
but I doubt it. Probably too minor on their list and fixed in 1.0
can't wait for 2022
with their rare updates I'm not too hopeful that it'll have the expected quality
it'll have a ton of new (untested) features
eh, I'm just salty right now. (and hungry) ๐
@devout prairie are you using GameObjectAfterConversionGroup? also tbh im not sure if destroying actually works, I recall having issues with it myself but need to test again
actually a quick test showed it worked
public class DestroyDuringConversionAuthoring : MonoBehaviour { }
[UpdateInGroup(typeof(GameObjectAfterConversionGroup))]
public class DestroyDuringConversionSysten : GameObjectConversionSystem
{
protected override void OnUpdate()
{
Entities.ForEach((DestroyDuringConversionAuthoring authoring) =>
{
var entity = GetPrimaryEntity(authoring);
DstEntityManager.DestroyEntity(entity);
});
}
}
IIRC it's in the legacy build menu
I saw it there. Is this setting used in my buildconf?
I assumed those pipelines are split
Yeah the build config is just an override for the usual build
ok, i see. thanks
Mainly to add subscene support as far as i'm aware
thanks that's an interesting approach, i'm currently just using a mono IConvertGameObjectToEntity.. the only issue i predict with either method is basically the same problem - if you try to destroy the entity of a child gameobject of that main authoring gameobject, it will throw an error later when the parenting system looks for that child entity..
is it that big of a deal to delete it in first frame? i got some problems with the current conversion too but most of it is solved with systems just running once in first frame and afterwards removing some Tag to never handle them again
is conversionSystem.CreateAdditionalEntity the only way to create an entity during conversion? dstManager.CreateEntity doesn't create one
if so, is it possible CreateAdditonalEntity adds performance baggage that's not directly visible in the Inspector?
somewhere in the conversion docs it says that CreateAdditionalEntity should be the only way to create Entities in Conversion reliably
i dont think there is any invisible stuff.
hm, ok. quite puzzled because of this: #archived-dots message
and build has the same perf
so it's not just some editor thing
i mean all that bookkeeping and filtering is iterating over chunks somehow. if you got too many of them maybe it scales bad at some point?
not a big deal no, it's destroyed before it hits the rendering pipeline.. would just be nice to have a simple way, like a component to add to GO's to just have them be ignored by conversionSystem
do you use changefilters?
they supposedly changed alot for 1.0 conversion (called baking atm) so i bet there will be at some point
for now i do it in first frame and as soon as you can have Systems running in conversion after EVERYTHING is done (LinkedEntityGroups) ill just plug it in there
possibly because CreateAdditionalEntity also creates an association with an object ( editor only i think ) it could possibly have some baggage if there's millions of them?
maybe it would be better for you to create one prefab of your object, and then in a later system instantiate them?
@viral sonnet what does the profiler say? anything in particular got slower or just every single system?
yeah i have to do something like that with joints, because the Joint/ConnectedBody entities are created after conversion and there doesn't even seem to be a primary entity for them during conversion
everything isl ike 15-20% slower
maybe clear entities cache and/or restart the editor?
i've tested this now in 2021, 2020.3 and in build ๐
just with added entities? thats really weird. id expect it to actually have 0 impact aside from memory. my first guess is still that it has sth to do with queries getting slower
that should be the characteristic. I've removed the system query too
you removed all queries or just the one handling your additional entities?
I only have 1 query that's using those entity comps and that was removed
The more entities you have the slower your queries are
even if those are not in the same archetype?
Yes
๐ design
A query has to iterate all chunks to see what chunks match the query
yes that was what i thought :S is there a way to make it faster? like grouping/sorting queries or chunks somehow before checking?
chunks beeing sorted into chunkchunks
why are entityqueries not associated with archetypes and cached. i mean whoa I'm baffled how bad this is
cause why check 1000 chunks if the first one of that archetype doesnt fit
that's kinda what i woulda thunk tbh
99.9% of projects don't just have, your archetype and some random archetype
they have 8000 different archetypes
you're optimizing a benchmark not for real world conditions
and how can you even make a proper game with this when you'd have millions of rendermeshes and all are affecting other system speed
but to be fair all of unities demos had like 5 archetypes ๐
wait. breaking it up into a diffrent world could work?
you shouldn't have millions of render meshes active
you open/close subscenes as required
and most large games implement some form of relevance
for the record
entity queries do cache their it does cache their ArchetypeChunk list now
I was attempting to install the DOTS packages, first starting with Hybrid (as I've seen recommended online) and these errors occurred:
Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Scenes\Hybrid\CompanionSceneUtility.cs(62,37): error CS0103: The name 'PreviewSceneFlags' does not exist in the current context
Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Scenes\Hybrid\CompanionSceneUtility.cs(62,82): error CS0103: The name 'PreviewSceneFlags' does not exist in the current context
Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Scenes\Hybrid\CompanionSceneUtility.cs(62,82): error CS0103: The name 'PreviewSceneFlags' does not exist in the current context```
I hope someone may be able to help me or at the very least direct me in the right direction! I attempted to clear/delete my library folder and reinstall the packages, but neither worked. Thank you.
hmm still this scales worse than i expected. they market it with render millions of the same stuff on screen and have 1000 fps and yet the more systems you have and the more entities you have it gets exponentially worse :S
more entities you have it gets exponentially worse
a) pretty sure it's linear b) it's more to do with archetypes than entities
archetype changes invalidate the queries cache
no its not archetype count for enzi (its chunkCount). he has a single archetype entity in the millions which he doesnt do anything with.
as for why a job would be slower
it's probably just because the ai chunks are further away in memory than before or something
people have been complaining about job schedule performance for a long time, but really the big benefit of ISystem is query lookup + dependency handling
this all said, without seeing what enzi entire project is doing it's hard to speculate
i'm currently testing 10,000,000 entities and my simulation system group is 0.15ms
now my presentation is nearly 1ms without having a single renderer in the scene
but you are testing with a low amount of queries running right?
not really
hmm ok
probably 25 systems atm
but only 3 have valid queries atm
obviously that's small for a full application
i take it just having a query inside RequireForUpdate could potentially slow things down
in the above case of lots of archetypes and millions of entities
actually using RequireForUpdate can speed up your systems
instead of checking potentially every query in your system to run
it only has to check 1
yeah that makes perfect sense
i wonder if, in the above example ( Enzi's case ) if he has say just one system and it uses RequireForUpdate, that single query could still cause the slowdown, even if the system doesn't run.. would it then be better to hypothetically just have say a bool flag that early exits the system rather than a query
how would you update the flag
no amount of entities should require you to run at 2ms for a query
even on old consoles when we had an archetype explosion issues the worst case we were having was like 3ms for queries/frame
hehe good point.. just thinking hypothetically, would the flag be faster
please don't misunderstand me, i'm not saying enzi's entire performance woes are from increased query lookup time. he simply asked
how is it possible that the mere existence of entities can bring down the whole playerloop?
and I pointed out a case
yeah
i think the issue is it seems millions of entities is kinda the whole point ( or to have that capability ), so what is actually causing his issue
just thinking out loud here
Which Unity version ?
Yeah- updating it right now. I'll be sure to let you know if that was the cause! I finally saw in the docs the necessary versions. I had 2021.3.3.
Great ๐
hm, interesting. i mean, this is kind of easy to test because I'm not doing anything different (that I'm aware of) just create 10 million entities of some archetype and the effects should be visible. from your testing you don't seem to have any apparent downsides?
i have no structural changes in this, so if i was doing some per frame it could get worse
but just as a default systems executing with perfect caching etc the overhead is negligible on my small system set
oh except presentation where even though i have 0 presentation entities it just has this giant overhead ^_^'
hopefully goes way a bit in builds i haven't tested - though in reality any build would have actual rendering entities
it's just an interesting amount of overhead for 0 renderers
what do you have without the millions of entities?
where it's getting strange I think is when a job struct takes longer. the system overhead of getting queries, etc... shouldn't affect the job itself, right? unless that's accounted for in the timeline
1000 entities - exactly the same
chunk memory might be a bit more split up
i wouldn't have expected that much of a difference though
How come NativeArray doesn't have AsParallelWriter? Whereas like NativeList etc do..
Why would it need one?
i'm having this problem, when writing to a nativearray inside a parallel foreach job:
what's your code here? you have it pre-allocated and are using valid indices, right?
previously as far as i can remember, where i've passed in NativeList or NativeHashMap i can pass them in AsParallelWriter and it circumvents this indexing problem
yeah
let me show the setup
list and hashmap have a ParallelWriter for adding and because they can change their length
yeah in this case i'm literally just writing to existing indexs
nativelist can't write to index in parallel
the safety system supports writing to native array in parallel to the same index as a ijobfor
yeah possibly used TryAdd with list
apart from that you have to turn off safety
and promise that you aren't causing threading issues
yeah this is exactly the problem
it only allows the job index which is, a bit stupid given it's an external array using completely different indexing/length
how can the safety system know what you're doing is safe?
you could be writing to anything
so if i turn off safety in the player settings it will allow this?
mm yeah seems a conflict of interest to me
[NativeDisableParallelForRestriction]
is how you turn off the parallel safety
but then you're on your own to not fuck it up
i can understand it where it applies to indexing the entity query and it's related components, but not to an array that's passed in
ah yesss i forgot about this
thanks
it's not safe to write to an array in parallel unless you can guarantee to never share indices
so of course it's blocked!
well yeah i can see the thinking there
so it restricts to the job's index range
even for arrays that are external to the query
//[ChunkSerializable]
public unsafe struct StatReferenceBuffer : IBufferElementData
{
[NativeDisableUnsafePtrRestriction]
public AvatarStat* StatPtr;
}``` one culprit down. uncommenting the tag costs me 4-5ms for 250k entities
hmm wouldn't that just mean the component would no longer be serialized in a subscene and left out of the archetype stopping systems from updating?
there's no system using it so ๐คท
and yeah, I've added it because unity complained about serializing the pointer. I've done this before and builds were broken if I not use ChunkSerializable
should just break in editor generally
again it's a case of, what happens to my performance?
the buffer is empty on all entities and not used. how can 4-5ms get lost
kinda loosely wondering about this atm:
say you have a parallel job and it needs an array of say 13 slots to write to, and then read from
would it make more sense to make one bigger persistent array of 13 * threadcount, and pass that in
or have the job create its own little array of 13 on each thread when it runs and then discard
i would guess creating the arrays on the fly would be more time consuming
than just accessing an existing persistent array
you'd be better off with a NativeStream
i haven't looked at that at all, what is the difference
it's a great parallel writer out of the box. of course you could allocate 128 arrays with 13 elements. just takes more effort
you know what's great when doing performance timing tests. windows updating and failing all the time -.-
btw @devout prairie it shouldnt be the case because using GameObjectAfterConversionGroup the parenting should be completed
Ah yeah true, the key is in the name right 'AfterConversionGroup'
Well damn
pretty sure at that point a job is nicer to read :S
hehe i refuse to accept that
It was indeed the version! Thanks for the help.
it's long past that point
ijobentity would be so much cleaner
i should have a look at using these tbh
for now, i'm converting a prototype into an ecs prototype
which i now have working, so i'm converting to parallel
as it is tbh i love ForEach it's just really simple and easy
but i'll definitely look at using struct jobs at some point
just seems more typing for the same thing
hey im quite new to the way adding forces works with dots physics, as such im watching a couple tutorials, most are old from 2020 or earlier, just checking, is the current method still the same as these old tutorials?
yeah sadly still the same
ok, thanks!
why sadly?
I think it was released in 2019, and hasnt really changed a whole lot since. the initial release and patches were really fast, but theres been nothing significant since 2020
oh unlucky
i just want faster development ๐ฅฒ
ye it would be nice, oh well im sure they are doing their best
what kind of features and improvements are you looking for with physics?
one thing i am wondering, if you have a prefab (the fake kind), and you then tick convert to entity, would it become an entity?
well some core stuff would be official joints, I personally want the unification of shapes and body authoring because I find it tiresome to add both, better trigger/collision workflow and parallel processing would be nice. then my wishlist is some sort of destruction workflow, ala unreal(probably a pipedream though)
better debug systems(current is ass)
better api tbh, and modifying colliders at runtime isnt really supported
ye those could i nice i suppose
report a bug and post about it in the dots graphics forum, not sure what else you can do at the moment
i had something similier, although i had no error, but i have had the invisible entity bug before, for me i just kinda ignored it and one day it just stopped happening, but i wish you luck finding a solution in your case!
congratz!
was just feeding the baby when windows was updating. now i came back and my pc is dead
unlucky, hopefully you had backups of everything important
sure, it's just a veeery weird coincidence
perhaps try downgrading to the previous windows update?
no the pc is dead. no lights, nothing ๐
oh, that is very unfortunate, and power button aint even attempting booting?
nope, guess the power supply is fried or smth
unlucky, hope you manage to fix it!
thanks :)
wish you luck!
im trying to implement a water gun, as such im trying to detect when a button is pressed inside a system base, im wondering is there any special method to do this, or do i just use the on update and just tell it to always run?
like a keyboard/mouse button?
simplest is to poll it in update just before schedule/run the job, i personally have an input system that takes all mouse/keyboard and stores that button press info in a component, and then query that component in jobs
ok, im not exactly sure how to do that, but with a bit of experimenting im sure ill figure it out
thanks so much!
first i have to figure out how to make the on update function run every time then in this system!
apparently there is something called AlwaysUpdateSystem, but i cant seem to figure out how it works
aha i think i got it working!
ok almost got it working, just tryna work out how i get something to run once at the start, something like a monobehaviour's start()
google says that OnCreate() would be what im looking for, although im pretty sure that is old outdated info, as it isnt working
hmm i really cant figure it out, anyone who knows what im looking for pls tell me, as i cant find any info
im not sure if you're using the new input system package, but if you are OnCreate might be called before the keyboard/mouse are initialized - so OnStartRunning might be a better candidate to initialize (you can always have a flag to have it only initialize once)
i dont know which input system im using but dont worry the only think im trying to do in OnCreate would be grabbing a game object by tag
but i shall try OnStartRunning!!!
Thank you so much, it works!!!!
look at manuals
they have according syntax
which has changed a lot through versions
why use pre-50 anyway
bruuuh, feels so bad I can't get query outside of foreach with filter group
Entities.WithEntityQueryOptions(EntityQueryOptions.FilterWriteGroup)
.ForEach((ref PlayerGravityTag pgt) =>
{
_curMov.X -= 0.5f * Time.DeltaTime;
_curMov.Y -= 9.81f * Time.DeltaTime;
Debug.Log("keked");
})
.WithoutBurst()
.Run();
hmmm
why is it running
[WriteGroup(typeof(PlayerGravityTag))]
[WriteGroup(typeof(PlayerRotationTag))]
[Serializable]
public struct PlayerFlyingUpTag : IComponentData
{
}
I have this
which should ensure it won't run
bruuuuuh
I only need it for filtering
causing writing is done to managed component
but seems like system failed me with it
You can't write group a tag
Not sure what this means
GetEntityQuery (desc)
and desc will contain FilterWriteGroup
so entities in query will only contain entities without write group
Yeah? I'm not getting problem
hmm
Could you show how it looks?
Even in codegen it transforms desc Options to Default
for some reason
{
All = new[]
{
ComponentType.ReadWrite<EffectActive>(),
ComponentType.ReadOnly<ConditionActive>(),
},
Options = EntityQueryOptions.FilterWriteGroup,
});```
is this what you mean?
yeah
(also ah, did they fix the bot)
so, this filters EffectActive?
(i didn't get deleted from face of earth)
yes because that's the write element
it'll filter on anything with write
so if there's any component with writegroup typeof EffectActive entities are filtered?
why it doesn't work for me
bruuuh
lemme check again
managed components work with write group though
I did check
they can't contain attribute
but they can be affected
pretty sure it supports mobile
but android only supports Vulkan
Currently, Hybrid Renderer does not support desktop OpenGL or GLES. For Android and Linux, you should use Vulkan. However, be aware that the Vulkan drivers on many older Android devices are in a bad shape and will never be upgraded. This limits the platform coverage Hybrid Renderer can currently offer on Android devices. OpenGL and GLES3.1 support are planned for a future version of Hybrid Renderer.
depends how old your phone is
hmm thought s7 was first to support it
Did anyone solve the problem with state machine design in ECS? I have seen few approaches
- use tag component per state + component with ComponentType field which stores current added state tag type to be able to remove it without knowing actual state: the problem with data copying still exist when state changes are frequent. (also using ComponentType in components may break deserialization process if type set in assembly was changed, but experienced devs recommend to write simple save system and don't try to use ecs serialization)
- use shared state component, so you can change it. Writing to this component by itself moving entity to another chunk: the problem is data copying + filtration by shared component in every system which handle state
- 1 component for state and a god system which handles all possible states
- other solutions which leads to breaking a rule that system have only logic and entities have only data.
I use it like this
public struct GameState : ISystemStateComponentData
{
public interface IGameState
{
}
public struct Idle : IComponentData, IGameState
{
}
public struct Play : IComponentData, IGameState
{
}
public struct Cannon : IComponentData, IGameState
{
}
public struct Dead : IComponentData, IGameState
{
}
}
then I have helper method for EntityManager/ECB which lets me remove all IGameState ComponentTypes from state entity
and add whataver is picked
public static class GameStateUtility
{
static GameStateUtility()
{
GameStates = new ComponentTypes(TypeUtility.GetAllAssignableFromComponentTypesArray());
}
public static readonly ComponentTypes GameStates;
public static void SetGameState<T>(this EntityManager em, in Entity stateEntity)
where T : GameState.IGameState, IComponentData
{
em.RemoveComponent(stateEntity, GameStates);
em.AddComponent<T>(stateEntity);
}
}
Kind of like this
so you just gather all your state tags and remove it brutally
have you tested this with lots entities?
it's not really brutally, kek
it's native way of removing ComponentTypes
a lot of iterations for the cost of 1
i mean for N state there would be N-1 unnecessary checks if component exists on entity
also AFAIK ComponentTypes may contain only ~6 types
it does it through queries though
yes, but i'm about removing component em.RemoveComponent(stateEntity, GameStates);
There are no checks
it literally just switches archetype
Hmm, ok. But still can't store lots of components inside one ComponentTypes struct
that's true
allthough
I just figured
why even use components switching
when you can just change archetype
@frosty siren
just store archetypes somewhere
and change state entity archetype
that's it
no need for component types switching or smth
I only wonder how to access those archetypes statically
what if you have another component added/removed at runtime?
i have pretty clean state machines
but that auto register components in the state
but it's a bit hard to explain
{
byte Value { get; }
}
public interface IStateFlagComponent<T> : IComponentData
where T : unmanaged, IBitArray<T>
{
T Value { get; }
}```
can either be unique or flag based (up to any size flags you want)
if there are different states, why not just use different entitites?
because an entity can change state?
- flee
- follow
- avoid
etc are all movement states an entity might have
but you can use states for a lot of other things
current UI, input, etc
hmm, I actually meant states for game
on which systems rely
not what's inside system, hehe
oh that's fair
i actually use the same underlying system for this
but i use systems for each state
and OnStartRunning
yeah
as like, state enter
think i've shown that off before
it's an, interesting approach
I copied it from you, kek
Curious about this.. Just changing system/ecb order, the second is about twice as fast as the first:
the timings on this window are close to useless
if you have 234123423 systems before your system, and then your system causes a sync point
all the timing data goes tot hat 1 system instead of the million before it
So i've selected my main system, and highlighted in green the ecb it's targeting.. The version which delays ecb until the next frame seems to be doubly fast than the one which plays back in the end sim ecb
that's not surprising at all
you've let your jobs run while rendering
the frame doesn't end at endsimulation
it then has the entire rendering part to do
if you use end simulation you are just triggering a sync point then
hmm ๐ค
and then during rendering threads are empty
at work endsimulation is banned
we use begin presentation - though this is because we slice like
client int, server int, client update, server update, client presentation, server networking
this way server/client can execute jobs while the other is updating
ok so i figured, each ecb is basically a sync point anyway, so it's not going to make a difference which one i choose per say
the later the sync point the better
it's not hte latest
as your own diagram above shows you
using the ecb on the next frame is later
ah right i get you
than using the ecb at the end of current frame (and it's only the end of simulation, not end of frame)
yeah that's interesting, thanks
hmm
something to think about
good point re doing some work while rendering
rather than trying to do it all inbetween all of the other system work
not trying to over optimize at this point but was just wondering as the differences were really noticeable
worst case i'll get like 10fps compared to best case of 29fps just by changing job/ecb ordering
you should never use endsimulation really
on server you should use begin init, on client begin presentation
the pain comes from them being different ecbs
which is a huge pet peeve of mine
so isn't postponing new values to next frame best you can do and you should always target this behaviour?
I was wondering about this a while ago
why we don't render previous frame while calculationg next one
how do you mean, what is the problem?
I read this as same as I wrote
if i have the same system on client and server
i need to use different ecbs since presentation doesn't exist on a server
you should have presentation at the beginning of the frame, and then calculations
and you should use on init/presetnation one whichever is first
in this way you can calculate next frame why rendering so both CPU and GPU have something to do
schedule is on ONE thread and scheduleparallel is on many threads
you realize it makes no different right if you just move rendering to the front of the next frame
yeah, I mean it from perspective of using ECB not actually moving systems
you can't
what do you mean?
hmm, if you have to ask that question i'm going to stick with you can't
dots time can only be pushed in a system
all I can add is that you probably want to pause game between frames not actually in random point
I wonder if it's doable as there should be some dependencies between LtW and rendering?
transform group is in simulation
rendering is in Presentation
between them there's ecb which causes sync
so
if you want to manually cause Update on system : .Update(); method
there is a DisableAutoCreation flag i think, so you can then manually create the system ( which will then start it running )
'[DisableAutoCreation]' attribute
yeah, and we can't easily change that
to move calculations of next frame after presentation
so you would calculate things while rendering
isn't rendering is controlled only on main thread?
that would mean
it's impossible
but you are calculating next frame in background
if you are using end simulation ECB the current frame needs to be calculated before actual rendering
so you will get more of: SCHEDULE -> RENDER -> SCHEDULE -> RENDER
instead of: SCHEDULE -> WAIT -> RENDER -> SCHEDULE -> WAIT -> RENDER
ahem
but wait before render is literally calculation of jobs
if you don't wait - data will be corrpu
you can't calculate components while rendering
when running all on single thread becomes not worthy
scheduling into parallel is costly
so either do it when there's too much entities or when processing chunks is super expensive
is it? does it cost more on mainthread to schedule parallel? never tested
for me default is ScheduleParallel. only if i have some algorithm i need to run singlethreaded i go with Schedule
throughput vs speed i guess. scheduleparallel will complete the work faster for heavy loads than a single thread even though schedule will take less overall time summed over all threads. so if you want short delays between when the job is scheduled vs when its finished scheduleparallel should be better after some workload threshold
Yeah i think basically if you're doing a lot of work, parallel will be faster, but if you're not, it might not be any quicker
at very least it'll require syncing between threads
which is probably not free
Like if the work to do already takes less than the time to schedule etc, you're not going to gain anything
well at that point youd probably use Run() though
Adds an IJobChunk instance to the Job scheduler queue for parallel execution. Note: This method is being replaced with use of ScheduleParallel to make non-sequential execution explicit.
hmm
Yeah i guess the problem with Run is it's blocking the main thread and more importantly isn't part of the dependency chain of scheduled jobs.. So i think that needs to be considered ie order of what you're changing/updating with a Run and how it slots in to other stuff that is being Schedule'd
yes the dependency issue is why i never use Run if i dont have to even if i lose performance. But Scheduling is also blocking mainthread in that sense right? if Scheduling blocks it longer than the actual work does then why schedule.
cause stacked scheduled jobs allow for multithreading?
kind of odd comparison
not sure i understand what you think im comparing. i am talking about mainthread here. if you want to do a very simple operation like 1 sum why would you schedule it. schedule would be way more expensive for the mainthread. the job does the same work as the mainthread would (the 1 sum) but you got all that scheduling overhead on mainthread too.
i take it there's no guarantee of the order that Run will execute in comparison to scheduled jobs
or does it always run before or always run after scheduled work, no idea
AFAIK when there are Dependencies to be resolved before Run can execute you'll get a Dependency.Complete call. basically a syncpoint for the components involved
The problem with that approach is that once you run your work on the main thread all other work writing to the components you are processing has to be completed
Therefor you either need clear grouped intervals where you do your work on the main-thread, double buffer your data or just don't schedule anything
Sorry, what do you mean?
I mean, why wouldn't Unity add second buffer in vanilla
Well, how would it know what data you want?
The one that you are writing to in the previous system or the one from the last frame
yep
Buy new hardware
Disable Physics
it was meant only for project tiny(rip) so expect headaches trying to use it at this point
you can't even install it anymore
0.17 only
Is there any trick to getting Entity collision working?
I have a Sub Scene with 2 GameObjects. Each has a nested object containing the Physics Shape. When I run it, they pass right through each other. Is there something else needed to have them not do that? or does it just not work with nested game objects?
Colliders are always root objects
If you put a collider on a child it will unparent the child during conversion
oh i thought thats only for bodies not for shapes
ok, I just moved the Physics Shapes to the top level objects, but they still aren't preventing a passthrough
shapes dont collide when none of them is also a body i think
I'm not quite sure what that means
i really fucked up writing a coherent sentence there^^. atleast one of the two colliders involved in the collision must also have a physicsbody component
Ahh - ok, that partially worked. I have my player now set up with a static body, and the wall set up with a Dynamic body. It seems if I switch the wall away from Dynamic the collision no longer happens. I was hoping for the wall not to move, lol
xD should be the other way around. why is the player static
I switched it to static to stop him from falling over with dynamic, lol
even Kinematic does nothing either
kinematic triggers collisions but doesnt force the collider out of the collision.
well mabye if you move with forces it works. idk didnt test the phyiscs alot
but to avoid falling over people used joints i think
@surreal pagoda you should probably ask about DOTS here
yeap
you kind of need to explain why it doesn't work well
Restart? As in reset all variables to initial?
That process is identical to restarting in mono / game objects. Have a storage containing an initial game world state then regenerate all variables using initial values
how else do you first start up the world then?
if you mark the objects rb with IsKinematic=true, basically the entity's Mass will be set to zero so will be unaffected by normal gravity and not fall over etc
but it should still react to collision ie if you move it towards a wall the wall should block it
( actually need to double check that last statement ie blocking )
Ideally, your systems are stateless and thus doesnt care if there's a restart or not. As for your entities, you can use the SerializeWorld function to save the current entities existing at round start (saving the binary to a file somewhere) then clear all entities and then Deserialize the world to completely restart.
Systems can have cached component handles and entity queries but should not have any variables as private properties that rely on the state of the entity world. That should be the role of singletons and entities.
you are disposing world, have you recreated it?
Just realised that JobsUtility.MaxJobThreadCount returns the thread limit (128) whereas JobsUtility.JobWorkerCount returns the actual available threads for scheduling.. Which on a 6 core machine is of course 11 ( (cores*2) - main thread )
yes
but just not, annoyingly your thread indexes might not be 0-11
(you can actually set JobsUtility.JobWorkerCount to limit workers etc)
there are circumstances where they could be given alternative index numbers?
99% of the time
just go debug our your indices it's sometimes weird
like if you got 24 cores
gives you 0-14, 16-24
or something weird like that
it's consistent, you'll only get the same thread indices
but thread index behaviour i would say should currently be considered undefined
ahh
was just thinking, it used to be possible in task manager to set affinity i think of cores to specific processes
maybe beyond certain core counts the OS or application might allocate a different main thread other than zero
i have subscene(dots 0.51, latest 2021lts unity) and use ss for prefab=>entity conversion (empty game object on ss with authoring component (field is Entity where i put simple cube prefab)) - this works when ss is open - when i close ss i get weird err : AssertionException: Assertion failure. Values are not equal. Expected: 0 == 1 - is this some bug or what i am doing wrong here?(code i used is similar to this : https://forum.unity.com/threads/prefab-workflow-and-managing.968299/#post-6675886 )
Do you have the full error?
Where is the assert failing?
What's the authoring component
What a best practice to add entity to array after syncpoint happens ? if i do it directly in system its add entity with id = -1
Can you elaborate? It's not clear what you are trying to achieve
protected override void OnUpdate()
{
var ecb = _syncSystem.CreateCommandBuffer();
var blockStorage = ObjectStorage.BlockStorage;
Entities
.ForEach((Entity currentStateEntity) =>
{
var blockEntity = ecb.CreateEntity();
blockStorage.Add(blockEntity);
}).Run();
}
blockEntity EntityId = -1
best practice would generally be don't
ok, but i really need use this storage so only way to create another system with filling storage after sync
What happens if another systems deletes an entity
its clearing storage
There's no way to do it outside if using entity manager or a multiple jobs with some type of tag component or hashmap
It's just not designed to be done
But if you're already creating a sync point why not just use entity manager
but this system can be burstable
Some EntityManager methods are also burstable
but ngl, if it's that simple
you will lose more trying to burst that
my system more complex and have SetComponents/AppnedBuffers and so on. Ok, so if im writing Entities.WithStructuralChanges.Foreach().Run() so some methods calling by EntityManager will be call burstable?
which versions of Vulcan API does DOTS support?
I changed in Convert To Entity conversion mode to ConvertAndInjectGameObject and now it works without error
for GameObject which holds prefab
yes seems you you right i removed it and it works now - thanks
hey guys I got some problems installing dots, any one can help me?, I made a new project with urp, and installed the dots package with all the components
but now I am getthing a few erros
unity version 2022.1
Entities 0.51 only works for 2021.3
@surreal pagoda well thats the wrong one to follow
https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/install_setup.html
the easiest way to get everything going is to install the hybrid renderer package. it pulls in all other necassary packages through its dependencies
So i got this pattern i often have to use. I wonder how you guys handle it.
I need to do work on a Prefab that i just spawned but that work only has to be done to setup certain aspects of that prefab. So lets say i have a Component that holds a RandomSeed on a Prefab. I cannot initialize that randomseed in the conversion since then my prefab has the seed and everything spawned from that prefab has the same seed. So what i do is having an InitializeTag Component that is removed in the first frame an entity exists. so all systems with WithAll<InitializeTag> will only run once and setup specific components (in the example i initialize the RandomSeed with the EntityIndex to guarantee a unique seed).
Are there better pattern that are equally as easy to implement?
It is very similar to the SystemStateComponents usecase of cleaning up after EntityDestruction. Of course i could also do it the other way around and add a tag once the entity is initialized but that would mean an extra useless permanent tagcomponent on every entity.
I don't really get, why conversion is not an option?
you can always init random from entity index
which will most probably be unpredicted
if you do it in conversion you do it for the prefabentity.
and when you then spawn an instance of it and not again initialize then the seed will of course be copied
oh
so you need to initialize the randomseed after you spawned the prefab
thats exactly what i do. the question is what is the best pattern to do something in the first frame only
oh when spawning i dont want to have a system i have to touch everytime i add some new component
I'd just make some static helper method that does it for EntityManager and ECB
Is the prefab instantiated from being in a (sub-)scene or are you spawning it manually? I'd probably have different approaches for each.
ooor, tbh it's way simpler than it needs to be, heh
its by calling EntityManager.Instantiate
well, if you know for sure
like spawning abilities
well my AbilitySpawnSystem doesnt know about the actual ability that is spawned. it only knows that it needs to spawn whatevery is queued next
so it would be a huge pain to add all initialization logic for every possible component into that system and check if that spawned ability needs the setup for certain components
Right. Personally I'd say then it is the responsibility of the system that creates those entities to make sure those seeds are set immediately.
But what if that system can spawn all kinds of diffrent entities and is mainly there to spawn at the right locations? not every entity will have a randomseed component on them but still will be spawned by that system.
not sure what you mean
I mean you could potentially give additional data to whatever is holding your prefab entity
wrap Entity around struct of AbilityPrefab
which will contain all data about what needs to be setup during instantiation
the ability is comprised of alot of diffrent authoring components all working together to create the wanted ability behaviour. so its hard to create one struct that contains all setup logic but might be possible
no I mean
you keep entity prefab reference
but along with it you will have bool
hasRandom
so if it exists - you add inited random
well thats the same as checking HasComponent<Randomseed>
still that would be so much overhead to setup and not very modular
but i guess faster
Ok, I think I get what is going on. I think you split up your components much more than I do. In your approach I'd probably make it so the prefab has a NeedsRandomSeed component that gets replaced with a RandomSeed component first (or same) frame after spawn. That way only "valid" entities get picked up by other systems groups.
it's pretty powerful pattern in case you require a lot of setup things around instantiation
Or that, I like that approach too
thats exactly what im doing atm
basically Def, hehe
yes i figured others would do the same. i was just wondering if there are some things you learned that improved that pattern somehow
Yeah. When I started learning ECS I tended to make to many teensy, tiny components. But often, packing the data as a bool in an other component leads to way simpler systems
hm yes i agree. not everything should be split up. however in case of the ability example i do need alot of small components because the combination of them defines the ability itself.
Projectile + Heading + TargetNotStatic -> homingmissile
i just have a lot of very small building blocks that stack additively to create any ability i need
and of course i cannot have a dedicated spawner system for every single combination of those that handles setup. i need to somehow distribute that setup over multiple systems (one system can setup more than one component if it makes sense of course)
i am too stupid to figure out how to HasBuffer<LinkedEntityGroup>(entity) in a Systembase without needing to go through entitymanager
do i need to just use getbuffer?
if (HasComponent<LinkedEntityGroup>(entity)) does not work
HasComponent should work though
well it doesnt work with Buffers
The type 'Unity.Entities.LinkedEntityGroup' must be convertible to 'Unity.Entities.IComponentData' in order to use it as parameter 'T' in the generic method 'bool Unity.Entities.SystemBase.HasComponent<T>(Entity)'
i feel stupid now. how did i never stumble upon this until now :S guess i need to write it as a job and use the BufferTypeHandle to check
Wait
Why are you using systembase method?
i was using a small Entities.ForEach and needed it to run in parallel. so cannot do EntityManager.HasComponent which would work fine with buffers...