#archived-dots
1 messages ยท Page 86 of 1
Yeah, I prefer square grids cause hexes are hard to grok, at first
There are definitely some clever programmatic ways to generate hex grids
I know
I wanted to try and follow this page
They use Cube coordinates
Or prefer to, any way
I'll check it out, after coffee - I'd like to know how to hex, too, haha
That is a pretty complete resource on how to do hex grids
Everything from how the math is supposed to work, how to think about coordinates, etc.
If you can translate it to whatever you are using
You will have a solid grid
Very cool. What interests me is how isometric tiles, done a certain way, are identical to hexes
The column-row arrangement of hexes is easily translated to a NativeHashMap<int2, Entity>
The tricky part is just getting the even-odd offsets right, I guess?
What are you specifically struggling with, at the moment?
Oh right now I wasn't really trying
Just to see if I could make two rows underneath each other
But I couldn't so
I'll look into that another time
Haha, fair enough! I'm interested in 3d-grids, so thanks for these resources! They will certainly prove useful.
Hex grids are just square girds where every second row (or column, depending on perspective) is offset.
And I see you've already linked to red blob, which is good.
I work exactly with hex grids and use this guide. So i can tell that it's very simple and once u implement coordinates casts (Cubic <=> Offset <=> Index) u will work with grids very comfortable
I'm curious if this would be a legitimate use-case of SubScene: as my content-delivery container for user-generated content. It's stored in binary, so I can easily keep in AWS simple storage, or something like that. What kind've contextual constraints come with loading a SubScene remotely into a client at runtime? SubScenes convert their objects into entities on load, right? Or can they only be prebuilt in the editor?
I see now that the SubScene is only converted when you rebuild the entity cache in the editor. However, each SubScene has its own EntityManager, which gives me hope that I can use it at runtime for remote content delivery.
All that said, Blobs will probably be much easier to work with, I imagine ๐ฉ
wonder why they bumped Burst to 1.2
## [Burst 1.2.0-preview.1] - 2019-09-09
- Fix assembly caching issue, cache usage now conservative (Deals with methods that require resolving multiple assemblies prior to starting the compilation - generics).
- Fix Mac OS compatibility of burst (10.10 and up) - fixes undefined symbol _futimens```
changelog is quite tiny
but they must have their reasons
https://forum.unity.com/threads/chunk-info-ui-explained.586729/ Oh man I wish I saw this post earlier ๐
physics preview does not work at all for me. i am following the first part of https://docs.unity3d.com/Packages/com.unity.physics@0.2/manual/getting_started.html but the ball does not fall
regarding the convert script, using "convert and destroy" like in the link really does destroy them. they disappear. changing it to "convert and inject" does not do anything. ball remains hanging in the air
@sacred tundra did you try the physics samples first?
you need hybrid renderer for the converted objects I think
no. this guide is all i did
hybrid renderer eh? makes sense. because the simulation is running, i can see that in debug view
well, you can probably get away without hybrid renderer but you can then only use like collision shapes and rigidbodies that haven't been linked to meshes
anyway, physics samples are here: https://github.com/Unity-Technologies/EntityComponentSystemSamples
I recommend looking those up as they give practical samples for a lot of these things
hybrid renderer made it work 
can i use hd render pipeline combined with this? ๐ค
yes
buildtin is what i am having right now. so it works :p
ah
then it's all good
you can't use HDRP's DXR with hybrid renderer atm
just putting that out there in case that's any interest to anyone
(I know I would want that)
ahh that might explain my crashing earlier
it doesn't crash for me, but raytracing totally breaks around the hybrid renderer's objects
like, just get pitch black objects or some weird artifacts around the objects
oh. well at least it i know its generally incompatible
Unity's RT dev said on the #archived-hdrp that hybrid renderer hasn't been tested at all with DXR
I'm sure they'll sort it out eventually
but it seems like these are two separately developed systems atm
DXR support is super early anyway
i was impressed i could run your sponza proj on a 1070
but after enabling dxr in my project, unity refuses to open without a good crash
@safe lintel are you on beta 2?
at least a12 was super crash happy with DXR for me
betas are better but they've also fixed some of the crashes on SRP also
I dunno which version you downloaded, I updated the dxr sample repo a while ago for newer HDRP master
or staging, can't remember which it was (I mainly pick one that's newest from the two)
b1 was doing that for me, havent tried with b2 yet
got other dots woes just eating away at my time
Hm does anyone know a way to use reflection probes with RenderMesh's?
I have this werid thing I'm not sure if I've managed to create myself, or something that is within ECS or the multiplayer system. I spawn a ghost entity, parent another ghost entity to it. But the Translation component of the child in the debugger seems to be showing world space instead of local space.
The child is just offset 6 units from the parent.
nvm, I think I just parented on one side. So the values I look on is on server, so that's why it looks correct, but I'm actually displacing it in my parenting code.
I have a NativeArray bob and for each entity I iterate in a system I access the data via an entity reference (otherEntity). e.g. someData = bob[otherEntity.Index];. This random access is pretty painful performance wise. As it's very predictable - are there any cunning tricks to getting this data into cache with the other component data? Like a component that has a pointer into the NativeArray or something?? waves hands about vaguely
not sure I understand - for clarification, it's not otherEntity.Index that's time consuming, it's bob[idx]
not much you can do about it, really
but just accessing the stuff from linear (on the index thing) shouldnt be an issue
the cpu can prefetch those kind of accesses fairly well
hmm I need to work on a simple example but pretty sure with 100k iterations (which is a lot), that read alone adds about 1-2ms
have you thought of having that array on a per-chunk basis?
that way instead of having a 100k long array, you have many of them, and they are chunk-local, so memory is less spread
hmm... I was wondering if there was a way to e.g. associate a buffer with a chunk (I know there's chunk data) so it would be loaded in on a single cache line (or I'd hope) but I'm not sure that's possible
thats what stuff like chunk data is for
you can also have an array of arrays
and store the index in the chunk data
I'm still pretty new to ECS, and i'm not sure i'm doing this right.
I'm writing a nameplate system; I have 2 different Entities, one being a character entity that has a bunch character components, and the other being a nameplate entity. The nameplate entity exists as a pool of nameplates and one can be fetched and bound to a character entity.
In order to bind the two entities i'd need to have the nameplate entity reference the character entity and get it's Health Component. I'm not quite sure how to structure this relationship.
var namePlateEntity = GetComponent<GameObjectEntity>().Entity;
var entityManager = World.Active.EntityManager;
var healthComponent = entityManager.GetComponentData<HealthComponent>(character);
entityManager.AddComponentData(entity, healthComponent);
I can't tell if i'm just trying to force object oriented programming here or if there is a better way to have 1 entity reference another's component data or if I should just be adding the nameplate components to the main character entity. I worry that as I build this game the character entities are just going to have hundreds of components.
Im checking out the first example in ECS the class RotationSpeedSystem_ForEach : ComponentSystem inside the function OnUpdate where it uses:
Entities.ForEach((ref RotationSpeed_ForEach rotationSpeed, ref Rotation rotation) =>
...
I kind of get that the first parameter is the component data, but how does it know about the second argument ? Does it automatically scan each RotationSpeedAuthoring_ForEach : MonoBehaviour, IConvertGameObjectToEntity and extracts its rotation value ?
What is the optimal way to learn ECS ? I jumped into the examples without knowing anything about it, would it be better to practice ECS without using the ConvertToEntity behaviour ?
@hollow jolt RotationSpeed_ForEach and Rotation are components. Entities.ForEach iterates over all entities with the given components, in this case over all entities with both RotationSpeed_ForEach and Rotation.
To learn ECS/DOTS: Jump in the examples, docs, and sometimes the source code ๐ Ah, and read discord and forums!
ah i see, how could i find out the list of all the components that are present in the Entitie by default ?
Hm, you could look at the Entity Debugger
Just noticed the pin and found few articles on the official website will make sure to look into that
ok thanks
@silver dragon regarding performance wise is it better to reference all the components in a simple foreach loop or is it ok to separate them ? Also what is the limit of the amount of arguments i could use in foreach ?
@idle steppe You could add a NameplateRef component to the player entity which holds a reference to a nameplate entity. And a PlayerRef component to the nameplate entity which holds a the player entity.
@hollow jolt For performance you should use one IJobForeach and Burst ๐ Limits... huh... you have to look at the overloads to find out... i think 5 or 6 components are doable. Additionally a buffer and monobehavior. Not sure...
I have a question for Unity ECS experts here, what's the most perf efficient way today to sync entities with gameobjects transforms? Right now I just poll the pos and rot from entitymanager each update via component data getter using entity id but is there any more efficient way?
example snippet: cs transform.position = entityManager.GetComponentData<Translation>(EntityToTrack).Value; transform.rotation = entityManager.GetComponentData<Rotation>(EntityToTrack).Value;
hybrid renderer would be nice but it doesn't play ball with DXR atm and it has some other limitations as well
Not an expert by any means but ill throw in some thoughts. There is some overhead in the checks in EntityManager.GetComponentData that adds up doing it one by one. So if you could grab all the pos/rots and targets that need updating in advance and process them together it could see improvements.
yeah, when polling one by one just feels it could be faster
Another idea i've been meaning to look into is using the UnityEngine.Object m_CachedPtr. Since the c# classes like for Transform are just wrappers for fixed layouts on the native side it should be possible to figure out the layout and update the pos/rot manually from a burst job with direct memory access, but obviously you've got a can of worms with that one.
it could also mess up with some of the internal optimizations they do as we don't know everything that happens on their side
last time I asked the staff of being able to access transforms from native api (I can see the access points on IL2CPP code), I got warned it could screw up their GC etc
but you can also set the gameobject transforms in jobs too, so if you can somehow get these things in some list / array etc from entity side, it could be a lot faster
last time I looked into that was when I was trying to optimize bullet physics transforms for Unity GO's
yeah, its an interesting area that i've seen very little around. I was thinking about it facing the lack of MaterialPropertyBlock support in the current renderer. Having to replace the material currently is a huge problem.
I'd really really want to use the raytraced reflections, I don't really care that much of the rest of DXR (but could also use the shadows as they are nice)
but right now it might take anything from half a year to year+ for Hybrid Renderer to get compatible with DXR, I seriously doubt it's happening with 2019.3 at least
The other option is to stuff all your GameObjects into a dictionary and look them up by Id, which is what im doing for all my UI elements. So the menu panels can get switched by ECS side events. The instanceID is stored during the ConvertToEntity process when it has access to both the GameObject and Entity.
is there a reason why you cant access public const variables externally in an CompSystem?
do you mean from within a job?
well its a public variable in a jobcomponentsystem
I can access an ordinary float using GetExistingSystem<system>.somevariable
but I cant access it when its defined as a public const
Uh, constants are static meaning you acces them by the Class directly, not an instance
class SomeClass{
public const int Constant = 1;
public int Variable = 1;
}
//Accessed like:
SomeClass.Constant;
var instance = new SomeClass();
instance.Variable;
Oh yeah I see now, thanks Hodhandr
Is it an acceptable design pattern to have entities referencing other entities and pulling components from their references? Seems like im doing something bad.
@idle steppe very common - using ComponentDataFromEntity? Of course nice if you can design things to avoid it in an ideal world but often necessary.
Ahh interesting - that was the call I was looking for. Thanks @amber flicker . A way to fix this coupling is I could just add all these nameplate components to the character entity instead - i'm worried a few months from now i'll have hundreds or thousands of components on that entity - is it better to break things up into smallers entities when possible?
Hmm... it's always a balancing act and there aren't many general rules you can apply. If you have a character entity with 100 components, yes you likely would be better off changing some of the design I'd say. Could probably offer more specific advice for a more specific problem.
Imagine a character with buff and debuff slots like a mmo - each debuff / buff bound to the character could add multiple components to the entity on top of the already thick stack of determining factions, level, health, mana, etc. These buff/debuff slots could have no limit to how many there are.
A large chunk of systems would just be running on the same character entities but with their own unique queries. It starts to look like object oriented programming to me at that point.
I think broadly you can go one of three routes (off the top of my head): 1) (my choice I think), debuff & buff Buffers per entity - essentially an array of buffs, 2) entity per buff/debuff with a reference to your character entity, 3) a NativeList or something independent of an entity but per character storing buffs/debuffs
but if they are buffs/debuffs it's actually probably a lot more complicated as to the best architecture - I guess they have durations, perhaps exclusive conditions and so on? - might be worth seeing if anyone else here has worked on a similar system
with unity model, its a great idea to split into multiple entities
the model generally doesnt like super-fat entities
for buff slots, multiple entities works better than you would think
How would you maintain that reference? a CharacterReferenceComponent on each of the buffer entities?
yeah
How would you store that reference in a IComponentData? the index of the entity?
yeah, the entity ID
{
public Entity Character;
}```
seems weird but i'll go for it - thanks for the help!
any idea what kind of numbers you anticipate? characters & buffs?
1000s
of both?
yes
absolutely entities as buffs then
the thing is that buffs are likel to have components like buff type, buff damage, buff time, etc. And adding/removing components is expensive
so better to leave the player entity mostly alone
and just "attach" entities to it
hmm... I'm thinking buffers would be better @vagrant surge ? I'm having to refactor a huge bunch of stuff that's per entity to buffers because at those numbers the out of cache really hurts?
with buffers its not so flexible for the buffs themselves
you can have it 2 sided
characters have a Buff component
that holds an array of entity IDs
of buffs affecting
and buff points to character
thats somewhat how i was doing it for a MMO pirate server i was prototyping
I guess it quickly gets into the realm of what data do the buffs need to access and where does that sit etc
thats the scary thing about buffs - a designer will try and make it access everything and nothing in the same breath.
thats why you might want them as entities
so they are configurable
can add more effects by adding more comps
I haven't been able to touch buffers yet. what's the limitations of that path? And why opt for a 2 sided approach when prompted?
just an array as a component
the 2 sided approach is so when the character dies you delete his buffs
ahh - makes sense.
Would all of these need to be in the same chunk? the coupling of entities seems to break what unity described as this magical place where everything sits tightly in memory.
ie. Should a entity with a component referencing another entity be in the same chunk.
nah
the buffs will be split into different chunks
by their type
so basically all "fire DOT" buffs will be on one chunk
all "ICE debuff" in another
etc
@dull copper wouldnt it make sense to use copytransformtogameobject component? any entities transforms are synced within a burst job
is it used by the old gameobjectentity?
no need to use gameobjectentity
no I mean, is that used internally by it
no
I don't see ECS sample repo using either of those things
they do the naive component data getters there
which is why I asked in the first place
i dont really understand the usage of gameobjectentity in the physics samples when they want people to use convert
i see the proxy still exists for them if you wanted to use that
the reason on physics samples is partially because they want to show how people can still use that from monobehaviours I think
if you look at the physics vehicle sample, most of the vehicle code is in single monobehaviour
which is totally unoptimized as well
you can still get the entity by way of conversion though
not sure where you are going with that?
you can get the entity that a gameobject gets assigned from conversion, so I dont see why they still use gameobjectentity
they don't
or at least I don't remember seeing any sample that does that there
but my memory also sucks ๐
the entity to track thing does i thought
nah, they store the entity id to monobehaviour and poll entity manager for component data with that cached entity id
anyway com.unity.entities@0.1.1-preview\Unity.Transforms.Hybrid\CopyTransformToGameObjectSystem.cs or CopyTransformFromGameObjectSystem.cs has the usage of those components
it doesn't use gameobject entity
yeah, I'm looking at those now here, thanks for pointing out those exist ๐
quick google got me into discussion which pointed out that those CopyTransform functions only work with GameObjectEntity?
no, it just needs to be added manually(unless you intend to use the proxy equivalents)
so need to feed in the GO ref manually?
well, I'll look into files, should be more clear then
docs are kinda useless on this https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Transforms.CopyTransformToGameObject.html
this is what I dislike on these new autogenerated docs
I'd prefer the old style Unity docs with proper descriptions and sample snippets
So if you have the ConvertToEntity script with ConvertAndInject selected, it should auto add the transform
yeah me too, do you know if they plan for docfx to replace the original manual at some point? i also dislike the narrower appearance
no idea but since most are going for packages, it's not a bright future for us
I totally get it's easier to keep the up-to-date this way
but this is #1 reason why competitors game engine docs are so subpar on API docs
and theres like virtually zero actual documents for any of the conversion or hybrid stuff so not really sure what the long term plans for how this all works is
there's some bare bones description here for transforms https://docs.unity3d.com/Packages/com.unity.entities@0.1/manual/transform_system.html#section-3-default-conversion-basic
but the rendering side isn't that great ๐ https://docs.unity3d.com/Packages/com.unity.entities@0.1/manual/gp_rendering.html
@dull copper so i decided to take a break from important things and had a look at this native transform idea, and actually got it to read the TRS fine! but setting the values doesn't work ๐ฆ bit of fun anyways. https://gist.github.com/jeffvella/6468cd84c3eccb7a57390bcd5b4ac7ac
that's cool tho
@mint iron nice
wonder how likely that is to break when they change things ๐
haha, yeah
so this kinda works in opposite direction which I'd need myself ๐
btw, for the CopyTransform stuff, this is really all I did to sync the translation/rotation -> the gameObject transform
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) {
if (CopyToTransform) {
dstManager.AddComponentData<CopyTransformToGameObject>(entity, default);
}
if (CopyFromTransfrom) {
dstManager.AddComponentData<CopyTransformFromGameObject>(entity, default);
}
if (CopyInitialFromTransform) {
dstManager.AddComponentData<CopyInitialTransformFromGameObject>(entity, default);
}
if (CopyScaleToTransform) {
dstManager.AddComponentData<CopyScaleToGameObjectTag>(entity, default);
}
}
for scale, I just wrote my own system to apply a Uniform/NonUniform scale back to the gameObject
@coarse turtle oh, that's simpler than I thought
I don't really care about scale at all
all I need to do is to sync dots physics to GO side
yea the scale thing was my own stuff, unity doesn't have that, just an FYI
I'm kinda fighting something totally different right now, I want entities package to show up in projects solution but it just refuses to pop up there
If you're on windows, you can try to leave it in ILSPY
the entities package
at least that's what I do so I can quickly view its references
I know I can get it there if I manually move the entities package from library/packagecache -> packages but it's PITA to update when next version comes
there's this editor setting that should gen all project files automatically
but it's not working, not sure if it's 2020.1 alpha issue ๐
ooo you're on the alpha haha
yeah, for no good reason tho, I'll try again on 2019.3
haven't looked into that yet, im still on 2019.3b lol
was just testing 2020 and figured I'd check this there
good pt
there really isn't any good reason to jump to 2020.1 for me right now
will see if they add some feats soon that I can't do without
if all the proj files have been generated i've just used add project to temporarily put it into the solution, it gets removed again whenever you restart unity but for that debug session it then lets you step through the code etc.
the issue is that this doesn't do those csproj files for most packages
it's like it just ignores that editor preference setting fully
it's same result as without the toggle
hmmm, sounds like a 2020 thing then
@mint iron that's a good tip ๐
I even wiped the library and let it process again
entities is in packages for me now because i got mad at all the private/internal methods and did a find-replace to make the entire thing public.
same goes for me with the transport layer
well, it's not working on 2019.3 either for me on this project
so I guess I'll just more the package again
it was so nice when this worked tho
"all I need to do is to sync dots physics to GO side" oh you will need to make your own mini system for this ๐ the CopyTransformToGameObject system uses localtoworld, which unity physics ignores(uses translation,rotation)
oh, that's a good to know lol
well, this starts to make more sense then
like, that must be the reason why they just poll the entitymanager for the translation and rotation data on physics samples
I'm sure they'll come up with more elegant setup out of the box at some point
those copy components, they were initially used in GameObjectEntity right?
I have faint memories of using those a long time ago
yes, the proxies/componentdatawrappers
and GameObjectEntity is going to get removed,right?
some of the conversion stuff uses part of gameobjectentity under the hood so ๐คท
ah, I just noticed that the samples moved away from it, so took that as a sign
dunno, afaik joachim said that should be going away "soon", but the conversion workflow will stay for a few more years on the forums
yeah, conversion workflow will be made production ready according to him
or at least that's what I remember reading
physics also completely ignores any child-parents you setup manually in code outside of a prefab Hierarchy ๐ฆ that was a complete pain in the ass for me.
probably just get rolled into the converttoentity script but i remember trying to replicate some functionality from it a while ago and found the dependency
I'm kinda sad that ecs editor took steps back
not fan of the conversion setup
I'd just want hybrid components and then editor support for the both sides ๐
i just want more dots compatible packages, i kinda dont mind the state of the editor(except for maybe the physics joint workflow)
missing proper editor is quite limiting workflow wise
especially runtime debugging is pain
it's just going back in usability, removing nice things we've used having
its why people think ECS is hard
if it was like entitas it would get a lot more usage
I'm sure they'll cover this topic at Unite to some extent
lets see
because it seems they are going even more into conversion workflow
given that Tiny editor got abandoned
what i wonder is why is it so hard
cant they just do what Entitas does? make a component that displays the ECS components on the hybrids
I don't think the tiny editor was fully dumped
like current version of it maybe
hmmmm reading the tiny thread again
well, if they can make the conversion workflow so that you still see the entities in the hierarchy, that's fine
apparently the hierarchy is kinda issue with ECS data layout tho
a visualization beetween "gameobjets" and entitities would definitely be useful
in such a case, then the game object editor is kinda the "edit only" mode?
and then you can link the GO with entity to see the entity vals
@safe lintel @coarse turtle just putting ConvertToEntity to "Convert and Inject GameObject" and adding that CopyTransformToGameObjectProxy to the same GO does update my DOTS physics rigidbodies
so, maybe they've changed that on physics package since?
I looked at the tranform copy system and it still copies the data from LocalToWorld
it also uses that TransformAccess that works on updating GO's on jobs
the translation is being updated by the gameobject?
it's updated by the copy tranform system(?) not sure if you asked that tho. all I want now is this to be updated by physics sim and mirror the rigidbody transfrom to GO transform
it seems to do that out of the box
so wonder what's the deal with the physics samples not doing it this way
oh wait, when I added the copy proxy, it adds GameObjectEntity there automatically ๐
well if its working its working ๐ my experiences were a windy road
well, I get a nag about having GameObjectEntity now ๐
it basically says it will be ignored since the conversion script is there already
but the copy component requires it
which is inheriting it from ComponentDataProxyBase
hmmm, maybe i'll just write my own version if its doing that lol ๐
yeah, it should be doable
but if this works, I'm totally fine by it nagging it on the inspector ๐
they will update Entities package soon anyway and chances are that custom things will break again
well if you wanted to use the converttoentity i would add like
public class CopyDotsTransform : MonoBehaviour, IConvertGameObjectToEntity
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.AddComponentData(entity, new CopyTransformToGameObject());
}
}
if you wanted to ditch the proxy stuff
Oh yeah I did the same, I think I misunderstood previously lol
yeah but they probably put more effort on the current scripts there
yeah...I think unity is just in that phase where they might be a bit everywhere and need to show something visually that 'works'
hmmmm, apparently "convert and inject to go" doesn't work with dots physics compound colliders
if I add collider to the same object with the conversion script it works
but if it's child go, it gets ignored with this setting
For what purposes we have ExclusiveEntityTransaction? There is no comments in code(
@sand cypress please use the correct channel, it is something for #๐ปโcode-beginner
Ok, Sorry sir.
@dull copper personally I created a clone of the copy to / from systems and a new set of components to work independent
this gave me way more control and until TransfromaAccessArray goes away this wont go anywhere
then you only pay for the number of total transforms you sync per frame
I think I have no problem up till 50k transforms but I'd need to recheck as its been a looooong time
Makes sense, right now there is no interpolation for physics either so could build a system that does it as well
yep, once you pay for the transformaccess copy once, just do absolutely everything else in ecs and life is good
@frosty siren can't help much except to say Joachim, verse 14: "ExclusiveEntityTransaction is more for streaming large amounts of data on a seperate world."
I'm trying to perform some calculations on vertex data and I'm wondering whether it's worth bringing the vertex data into a job-friendly format to try to parallelise the work, then take it back out to the main thread at the end to piece together the final mesh.
A summary of what I'm trying to achieve:
for all atoms (tens of thousands), check every vertex and triangle for intersection with another atom.
Save vertices and triangles which are not intersecting to a surface mesh.
There's some tricksy details buried in there but that's the overall gist of it
I have been using the hybrid renderer with batched RenderMeshes which is great for performance, but doesn't allow me to do a few things I really need to do. Thinking I may have to take the final rendering step outside of ECS but use jobs to do all of the up-front calculations that need to be done
Does this sound like a sensible approach?
It sounds ok to me - what's your main concern? Is this on-load of a castep file or something?
I think the issue I'm concerned about is that I'll be completely separating out the (previously batched) meshes into what could end up being a massive single mesh
But I guess that's probably just me not wanting to give up having 33k objects drawn on screen with just 4 verts and 2 tris ๐
I would save the mesh data within a component as well as I'll be using the verts later for things like calculating possible spawn positions
Thanks for the sanity check @amber flicker going to push on to a first version and see what it's like ๐
yea... struggling to reply with something useful. Are a bunch of instanced geo'd meshes more performant than a giant mesh? Almost certainly. Would you gain perf from jobifying & bursting vertex checking stuff? Yes - although gpu's also a consideration depending on the task I guess. As to what you're trying to achieve from a higher-level perspective - not sure ๐
Currently my level is a collection of spheres (atoms). Previously in my OOP implementation, I generated a surface mesh for each atom with a voxel-type calculation then morphing the mesh to effectively shrink-wrap the atoms. That meant I could then select surface atoms (those with surfaceMesh.vertices.Count > 0) and find spawn points for procedural stuff that way.
I'd like very much to have a smoother surface - less obviously-just-a-bunch-of-spheres (without going into raymarching, probably!), and also have access to what is on the surface and what isn't within the job structure. My levels are protein structures from public databases - I don't have control over the structure so need to work out what the surface is just from the atomic coordinates.
Now everything is super lean in ECS I definitely don't want a bunch of gameobjects with meshes on, and now that Unity has made meshes capable of holding more than 65535 verts, my options are a little better than when I did my first OOP implementation. Assuming a single large mesh is viable, but I can play around with the geometry to make it all right I think.
ouch!
its probably quite stressful right now organizing the event and everything that goes on.
sheeeit
@wary anchor not too familiar with how you are going about the smoothing
how big is the data set?
In other news, my gravity/collision system is finally working nicely
the mesh vertexes
awesome!
I'm about to make a sphere simple gravity system soon for my game for details on characters
should be pretty fun
uncoloured version as a rough 1st go ๐
oooo pretty
I can't believe how fast it runs! No colliders or physics helps
no smelly slow monobehaviours as well :)
yup!
So my plan is coming down to this:
1) get pairs of intersecting atoms as collection
2) for each atom, calculate vertices by scaling then translating a template 'mesh' (vertex positions scaled to 1f around the origin, eg an icosahedron or similar)
3) check each vertex to see if it's inside any of that atom's intersection partners via collection from step 1
4) write verts to master list (need to think about whether I can do this step in parallel or combine at the end?)
The tricky bit is number 4 as I will save all triangles where at least 1 vert is not intersecting another atom, then add in the other 1 or 2 verts to keep that triangle in the final mesh. Then transform the position of those 2 would-have-been-deleted verts to a shared position with the neighbouring intersecting atom's equivalent would-have-been-deleted verts (possibly deleting one set and sharing the verts at this point).
There will be another issue when at the intersection point of 3 or more atoms, I need to think on this a bit more.
makes sense
its going to be tricky with the ordering of what needs to happen before x and if you need to verify something
you might want to try doing it over a few systems and stages to make it more sane (with sync points)
then figure out how to remove the sync points later on
That's a good point, yes, syncing could be an issue
the complexity is a big jump from single threaded where you can confirm that something is done before other thing, but multi its very very hard unless you do everything always even if its not needed
I would look at this problem as not exactly within ecs bounds though,
think of it more of using the ecs world / data to run a process, that churns though some large data sets, with temp memory shared all inside of standard jobs
that way you can just focus on a to b
a chain of standard stock jobs should be much easier to manage, but still off the main thread, and still able to be burst compiled
yes, I was thinking probably keep it in a single system for now: I have the atom list data from my previous system so that gives me all the coordinates and scales I need. I can ensure sync points and sharing of data like in the boids example that way
use some native array temp memory inside and just work though what you need in that small tight area
hellz yeah. Thanks @low tangle
quick question, because I don't know up front how many verts I'll be dealing with, I think I need a resizeable collection like NativeList - is it best to use this while generating the data then for later access by other systems store it into a NativeArray of the appropriate size? Or is that microoptimisation. I've not use a NativeList yet, but I know they're slower due to the lack of up-front allocation
you can cast NativeList to NativeArray
I suppose if I brute force it, I know the max number of entries I'll need: template mesh verts * number of atoms. Might be wasteful though
I'm thinking... the key step is how to structure the data of triangles mapping to verts mapping to atoms
well, mostly talking about the size of the data last question
doing the math on say, tons and tons of float3's
how large is the template mesh, and how many atoms do you expect to load
you mentioned it was a icohedron?
If i have an icosahedron and 33k atoms, that's going to be a total possible size of ~ 390k
390k verts?
yeah that's about where I got to
verts 12 float3
triangles 12 int32
normals 12 float3s
float3 = 12 bytes
int32 = 4 bytes
288 for verts and normals
48 bytes for triangle indexs
336 per ico
336 * 33k = 11,088,000
always fun to calculate data size
so yeah, brute force away, 11mb is nothing for ram
hell you can ask malloc for that in one go for no time at all
the real fun part comes later after brute forcing that in culling the unused data. Anyway I'll worry about that when I get there!
I hate keeping track of mesh data
I'd say to, don't cull or chop the data
Not a strong suit for me
instead figure out whats inside vrs out
by passing over the data and marking it
then pass over that and take your final set and fix the triangle indexes (which you actually dont need to bother with till the end)
heh
you basically doing 3d minesweeper
hah yeah I guess it is kinda similar
if the verts were on a grid, you would just be selecting all that have at least one missing side
or rather, nuking all that have exactly 3 missing verts
something to think about
It will take me a while for sure. Structuring the data as it goes into the jobs is still something that I really have to ponder ๐ I'm getting faster at it
but still
all good
by taking that step and really thinking about your data first
makes all the difference when it comes to actually solving the problem at hand
yes I realise that is absolutely the crux of working in ECS.
I find I spend far more time being forced to think about my logic and data process than actually writing it
which honestly is a nice side effect
can't really hack it
yes, it makes sense when you take a step back and look at game dev in those terms! The actual implementation should be fast if everything is planned right
100%
I had to finish up a chunk of my games animations and IK back in monobehaviour land
and it made me miss ecs stuff so dang much
๐
but even then I was able to write my monobehavour like a ecs system with components that were nothing but data
its weird at first but strangely still fast as well?
it also made the logic super dang compact
that's how I started getting into ECS. I needed to refactor, so I decided to de-monobehvaiour everything possible and do proper unit testing
then I discovered ECS and was like... hang on
that's a much cleaner way of doing it
worth it
so fucking worth it
I've been doing it for 6 months now since unity first released it
not a single regret
wait
but oh my god the mental remodelling required to get even slightly competent with ECS has been HARD!
yeah sorry about that
its fuckin hard brain remodeling
๐
I went though it too
its like hold up, back to babys first programing, plus theres like a billion new things to learn about
but thankfully everything is just a simple claw hammer, does only one thing, but does it well
I quit my previous life nearly 4 years ago so have been re-training my brain solidly since then. I kinda didn't want to have to forget all that I'd learned, but it's not really like that, it's just extending my skillset and that is always always worth it
humans are always works in progress, so are our skills
I never intend to stop learning, I love it too much
change is good
Yup, couldn't agree more!
Although I can't see what's past my current goal: getting players to play a game I made running around a protein whose structure I solved! That is going to be epic. When I get there ๐
hell yeah ๐
combine my former life with my new one ๐
at least now I have a clear idea of what the game will be. but it is slow working on your own, at least I am slow working on my own
it comes in bursts for me
SO MUCh ^^^
slow skull dragging for awhile, then massive gratifying jumps
I've always been like that, back when doing lab work too, I'd have one epic week and get all my results, then 3 weeks of apparently nothing
Speaking of which, I have a good feeling about this mesh code. Thanks so much for the advice and the chat! Both really appreciated. I'm going to smash this today if it kills me ๐
and you ๐
Hey! So I have entities in the world (spawnPoints) marked for two teams by a Faction component. There can be multiple spawn points for each faction, and they can be occupied. (lets say marked by a occopiedTagComponent) I have an entitiy that triggers a spawn with a Faction component and what should be spawned. Is it possible to jobbify this code since I need to mark spawnPoints "taken"?
yeah, but you would have to use a hashmap to keep track of who took what, or a large linear array but I'm not sure exactly how to lock / use a semaphore for the atomic flipping of the bool to mark it as used
I haven't really used any normal multi threaded stuff so far with jobs, usually trying to find a different way to do it with jobs works
usually I just use a hashmap like a locking hashset to check if its been taken at this index
Ok ,I haven't used hashmaps in ECS yet, so I'll have to look that up : )
also I finally got around to make visual studio snippets for ecs stuff
newjobsystem
//which expands to this, placing cursor at end
class NewJobComponentSystem : JobComponentSystem
{
end
protected override void OnCreate()
{
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
return inputDeps;
}
}
newsytem
class NewComponentSystem : ComponentSystem
{
protected override void OnCreate()
{
}
protected override void OnUpdate()
{
end
}
}
newcomponent
struct NewComponent : IComponentData
{
end
}
ForEachEntity
Entities.With(query).ForEach((Entity ent) =>
{
end
});
Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets
they go into this directory
That's neat, I use ScriptTemplates : )
I've been suuuper lazy for a long time
wrote every single lambda and system, all 120 of em

oh they add the unity usings at the top as well
Unity.Entities + jobs for the job system
Those are neat : ) Just add to a ScriptTemplates folder * : ) I use a lot of Settings when prototyping ^^
also documents?
How do you mean?
I usually end up with like 3-4 systems in one c# file for a strain of logic so I'll probably get a lot of use out of the expand ones I made.
but really thank you for the templates as well, starting off with those is nice
this is going to save so much time I wish I did it a year ago
Haha yep ๐
Hmm struggling a little with the best collection to use for storing intersecting pairs of atoms.
I struggled with NativeMultiHashMap because it turns out that my entityQueryCount squared was too big for the capacity (that would be the maximum possible number of intersecting atoms). Can do it with a smaller max capacity but it's being a bit slow.
conceptually I see it as a variable-length list associated with each atom, but that isn't very job friendly...
maybe I should instead just reference the atom which the vertex was inside when storing the temporary mesh data
refrences are good
lots of linear arrays are good too, can you maybe do a max local sized native array/list?
I just always seem to be fighting against the possible data types!
theres probally a reasonable limit for each one of how many it can be inside?
totally get that
yeah there's definitely a reasonable limit, but it irks me that I will have to hard code that
nativehashmaps and running them in a bursted job is super fricken cumbersome
I tried writing every intersecting pair of atomID (int) to a NativeMultiHashMap in parallel. To be fair, that could be sped up if I reinstate my spatial hash code
I feel like the atoms / intersecting verts code is more of a volume flood filling kind of problem
I wonder if there is a better way to think about the problem
then later I'm thinking it's easy to get the collection out relating to each atom of interest as it'll all be listed in that hashmap
hmm goo dpoint
I wonder if you could create a SDF from the atoms (they are kinda like metaballs) and then mesh that surface instead of overlapping and overdrawing icos
it is very much a volume filling problem isn't it
I can see it now. I'm going to have to learn how to write shaders to make a raymarching shader to display them. ๐
its actually super super easy
but you might be able to solidifiy those meshes
but then the meshes uvs is a intresting problem
if you want them textured
nope
oh easy then
either flat shaded with a beautiful low-poly as-equilateral-as-possible mesh (LOL yeah right with no experience!) or just simple shaded. The colour will come from placeables and when I get there grass -like shaders
Quick question, can I add a GameObject prefab to a job?
not exactly no
pasting some quickly searched sdf stuff
http://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/
https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
One of the techniques used in many demo scenes is called ray marching. This algorithm, used in combination with a special kind of function called "signed distance functions", can create some pretty damn cool things in real time.
Tutorials and articles of Inigo Quilez on computer graphics, fractals, demoscene, shaders and more.
kinda like this, @low tangle ?http://www.gradientspace.com/tutorials/2017/11/21/signed-distance-fields-tutorial
I've been reading up and watching videos about ray marching. It looks amazingly useful and very very appropriate, but it's not something I have any experience of in practice yet
yeah its a whole different can of worms compaired to ecs and stuff
the funny thing is you could very much make these and trace them in a ecs system
I wrote a full path tracer in ecs w/ jobs
I can see it from the shader perspective (no need to modify any meshes to get nice smoothed joins)
burst was stupid fast
yep
basically you cover both your high quality rendering, and the inital how do I even render this data in one go
and if it's already in the job system, it also gives me easy access to surface point data per atom which I can use for environment spawnpoints and the like
hm
oh, the atom data is also a point cloud too
I've seen stuff on meshing point clouds
Hmm is exactly what I've had written on screen for a bit
thats totally marching cubes
oooh this one looks promising
oooh I need to save this for myself for later
so before I get overwhelmed with the magnitude and complexity of the task ahead of me...
I haven't done any C++ for a very long time. How possible is it to come up with something within C#/ECS to do this kind of job? Do I actually just need to take a couple of weeks out to learn how to write shaders first?
though it'll all be on the CPU rather than GPU of course
yeah, but its mesh generation, so the final result doesn't have to change
true
I can't tell you if its a good idea to go with that kind of route at all
unless it's not mesh generation and I just go all in for the raymarching for rendering as well
I would personally attempt to make either marching cubes (which I have before) in ecs and try to mesh that voxel data
yeah, you pay for that in having to learn all about shaders, sdfs, raymarching, and the performance you now have as a baseline on the gpu
that second one has way better surface results than marching cubes, but its much more complex
poisson surface
I did something before in OOP which I now think may be close to marching cubes... I made a voxel grid around the protein, then marked each voxel as being inside or outside an atom, then worked out which face of that voxel was an in-out boundary, then made a mesh on that face, then distored the mesh to match the nearest atom surfaces
I'm also not sure on how high res your voxel data
yeah thats pretty much a simple voxel mesher
it was the product of me working without guidance for a long time, but it seemed to work well. I'm sure it's VERY basic compared to the more sophisticated things out there. It wasn't without errors when I ramped up the resolution
although it did give me a continuous surface
yeah you could basically continue that with guidance if you would want to?
Okay I need to read up on SDFs and how to generate/structure/use them. I can't put this off any longer I think. Thanks again @low tangle . Every time I come here you challenge me indirectly to learn a whole chunk more stuff than I'd originally planned to learn. It's great. ๐
Oh I would LOVE to have guidance ๐
sounds good ๐๐ป
I've been working alone in my dining room on a piano stool for the last nearly 4 years
I mean, I've had toilet breaks
k awesome, thanks again. I'll need to read more just now so I understand precisely what it is I'm trying to achieve.
sdf / sphere ray marching to directly view the atoms on the gpu or
mesh the atom structure by treating it as voxels, or a point cloud, producing a mesh
you mentioned you wrote a path tracer in ecs with jobs, is that somewhere between the two?
I mean clearly it's not #1 tho
Hmm. Yeah I'm going to need the unity renderer for most things, but for the atom structure a shader that uses raymarching would be the best possible solution. Whether I can achieve it would be another matter
but then that would beg the question, how do I actually achieve what I set out to: a set of surface data within ECS that I can use for gameplay purposes
voxel mesh it imo
I can do that.
No reason why I couldn't later add in a ray marching shader and use that instead for rendering, but still use the meshed data for gameplay with ECS. Yes. Makes sense!
very true
might even be able to use it as a proper mesh collider too
it would be a enclosed volume
Ooh because I would have the SDF
Ahgh, so hate memory layout changing after Create/Destroy entities. I really want to have a method that just return next Entity and schedule create/destroy.
public static void FakeMemory(Entity entity, MemoryType memoryType, int factionIndex)
{
//Memory access
var memoryCategoryEntity = GameInfo.entityManager.GetBuffer<MemoryCategory>(GameInfo.factionsECS[factionIndex])[(int)memoryType].entity;
var memoryBuffer = GameInfo.entityManager.GetBuffer<Memory>(memoryCategoryEntity);
var memoryArr = memoryBuffer.AsNativeArray();
var index = IndexOfMemory(entity, memoryArr);
if (index != -1)
{
//Instantiate entity and write returned entity to memory
var fakeEntity = GameInfo.entityManager.Instantiate(entity);
memoryArr[index] = memoryArr[index].Faked(fakeEntity);
}
}
This code cause an error that said that native array is deallocated because memory layout has changed.
AsNativeArray maintains the same safety as the original and points to the same data so you're not gaining anything here by using it.
EntityManager.Instantiate creates a sync point and so all jobs are completed and all arrays are invalidated. If you want to still use that array you could use ToNativeArray(Allocator) and then you're working with a copy of the data. That strategy works fine if you're only reading it but since you're updating it, you'd have to copy put it back into the DynamicBuffer.
GameInfo.entityManager.GetBuffer<Memory>(memoryCategoryEntity)[index] = memoryArr[index].Faked(fakeEntity); should be able to write with a new buffer wrapper after the sync
Is it a valid approach to have like lookup HashMaps through singletons to find entities through IDs(integers)? My problem is regarding networked objects to parent and other things.
curious how are you storing them on the singletons? in a component or buffer or something else?
@mint iron i read somewhere that accessing through NativeArray is better for burst or something.
iv'e heard that too, supposedly there are additional optimizations that are hardcoded on burst compiler if you're using a NativeArray. Worth considering when you're at the stage of needing to optimize burst jobs.
hmm, does anyone know where Unity declares the size of the chunks?
Is there a way to say this inside a job?
if (EntityManager.HasComponent<FirearmData>(data.FirearmEntity)) {
var firearmData = EntityManager.GetComponentData<FirearmData>(data.FirearmEntity);
firearmData.IsFiring = Shoot;
EntityManager.SetComponentData(data.FirearmEntity, firearmData);
}
@prisma anchor u can use chunk.Has<T> inside IJobChunk. If your problem is using HasComponent<T>(Entity)
Well yea, its using the entitymanager in a job. which is a ref type. ok ill give that a go.
List of changes for Job
EntityManager.HasComponent<T>(Entity) -> Chunk.Has<T>()
EntityManager.GetComponentData<T>(Entity), EntityManager.SetComponentData<T>(Entity) -> Chunk.GetNativeArray(ArchetypeChunkComponentType) and then work with it; ComponentDataFromEntity<T> for randomly access
Thanks! Tony!
I didnโt fully look through your code, so I made changes to the text, sorry for that
This is a pretty interesting way of packaging up more complicated functionality for jobs. https://forum.unity.com/threads/how-to-work-without-interfaces-and-other-questions.742514/#post-4959302
interesting thanks, I've been wondering about using splines with jobs for a future project
How does blobAssetsReferences work? Could I have for e.g. lists n' reference types within one?
Why JobComponentSystem doesn't have PostUpdateCommands?
struct ListRefWrapper {
public IList<some_type> WrappedList;
}
// Create a BlobAssetReference<ListPtr> for a naive implementation
struct ListPtr {
public BlobPtr<ListRefWrapper> Ptr;
}
@mystic mountain
@frosty siren, I think their design methodlogy is to use EntityCommandBufferSystem that belongs to your respective UpdateGroup and create a EntityCommandBuffer to playback yourself (you can always playback the command buffer on the main thread too)
to add to that - I think it's because you'd have to wait for the job to be complete and thus you'd have no idea when it would execute.. so by using a command buffer you can be explicit
yeah i know, but PostUpdateCommands is comfortable
@amber flicker ok, this is what I did not think about
EntityCommandBuffer.Concurrent always returns null Entity when call Instantiate. Am i right?
I'm not sure (I haven't checked) but I could believe it. May possibly have to fill a nativequeue instead. That or add an additional component to created entities (I use this) that a system processes.
then at end barrier remove the component (bulk change to archetype = v cheap)
yes, i'm going to set components and use reactive systems but the little problem is i need access the same data twice this way and accessing is not so fast
possibly fill a nativequeue instead then I Iguess
then you can deque, instantiate and set what you need to
Doesn't matter what to use it's means that i will need to access data twice. I store categories in dynamic buffer which is entities that represents an arrays of some data (also implemented with dynamc buffer). Accessing data looks like
DynamicBuffer<Data> dataDB = category_BFE[categoryEntity][categoryIndex];
To minimize using BufferFromEntity i map all i need to NativeMultiHashMap. When i iterate through hashmap i want sometimes create/destroy entities and always need to modify dataDB (Data contains entities). And of course i want to use it inside parallel job. So using deffered create/destroy entities leads to iterate through hashmap in mainthread.
but if you want to create/destroy entities then no matter what you do, that needs to happen on the main thread right?
all command buffer or postupdate is doing is delaying until it runs on main thread
perhaps I'm misunderstanding something
Yes, work with entitiy must be on the main thread, but i want so much mechanism that will just return the valid Entity inside job)
to avoid all this extra data flow
I'm not sure I understand... it couldn't know in the job what the entity that was going to be created is right? Also, populating a nativequeue is pretty much a similar amount of code to writing to the command buffer no?
Yes, but after entity creation i just need to write returned Entity in dynamic buffer, that's it. And only to do it i need to populate queue/schedule ecb/use reactive system. I mostly complain, hoping that I donโt know any easy way
Question about buffers - is the only way to write to a buffer to use BufferFromEntity? I was operating under the assumption that an entities buffer and it's contents will be loaded into the cache line when processing an entity but this makes me wonder - does anyone know?
there are IJobForEach with buffer variants
Re-reading the docs it does look like the memory is reserved in the chunk. Iโll take a look at ijobforeach and see what it uses (Iโm using Ijobchunk)
At least the initial size anyway
The default reserve amount is quite low, but if you add the attribute and set it explicitly then you can make things fit in the chunk. Otherwise, when it overflows it allocates elsewhere on the heap and the component just has a pointer out to it.
BufferFromEntity is essentially a wrapper for the typeIndex, version and safety. When you use it, it follows the pointer into EntityComponentStore. Which is basically the same as using EntityManager.
So I'd be curious to learn more about how cachelines work because that sounds to me like every access is jumping through at least a few methods/pointers, and doing a costly second type lookup for IndexInChunk (looping through every component type) then calculating the needed offsets. But it doesn't sound in the same ballpark as iterating a sequential block of data like in an array.
Hmm a lot of my refactoring is to avoid the cache miss - at least for very small sized buffers - if it fits within the chunk I hope it's avoiding some rand access?
@amber flicker you dont have to overexcess so much that everything is perfectly cache friendly
even if stuff is a bit out of order, if your data is all in contiguous arrays and its predictable, it will be fairly fast
hmm.. I think it is actually hitting my perf quite bad. If I iterate e.g. 100k items my system takes e.g. 1ms. If I add in a line that indexes a NativeArray, that jumps to about 4ms. My assumption was that was due to the cache misses. I can't think of any other reason indexing a float in a NativeArray would add so much time?
well man, 100k is a LOT of items
for sure
have you thought of paralelizing it more, or just dont calculate 100k every update? like one quarter every update
but 100k indexes into a native array are slow. maybe the safety features are hitting you?
It's not that it's too slow, it's that I think it could be like 3x faster
im pretty sure ive done random access into one array from indices in other array much faster than 100k per 3 ms
you could try to access the buffers from an IJobChunk
public struct MyChunkBufferTest : IJobChunk
{
public ArchetypeChunkBufferType<SelectionBufferData> SelectionBufferDataType;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var bufferAccesor = chunk.GetBufferAccessor(SelectionBufferDataType);
for (int i = 0; i < bufferAccesor.Length; i++)
{
var buffer = bufferAccesor[i];
for (int j = 0; j < buffer.Length; j++)
{
var bufferItem = buffer[j];
}
}
}
}
so something is amiss?
yea accessing like that works but you can't write using a buffer accessor right @mint iron ?
i havent tried to write with it, but it gives you a DynamicBuffer<T> for the entity so i dont see why not
@vagrant surge take those numbers as very approximate - they're actually for looking up a nativearray<struct> where the struct has a few floats and a bool in
@mint iron the accessor seems write only to me when I try
*readonly
even if its random access, the cost looks too big i think
what are you doing once you access it? the cpu can pipeline the memory access if its array into array
well.. I comment in/out the line and those are the differences I see in a build attached to editor
im guessing all of the burst build options and the like are enabled?
yea
then i dunno
I can try and make a simple repro
but I'm not that surprised tbh
a lot of speed comes from the linear memory layout and cache right? If I add a random access in every loop...
it passes the readonly setting from the ArchetypeChunkBufferType, so i'm thinking u can do GetArchetypeChunkBufferType<T>(false). Guess i could test it.
@amber flicker not really. Lots of it come from predictability and instruction caching
each CPU core is pipelined inside itself
it can overlap memory loads and other operations
hmm maybe it's not that I can't write and that I'm just not sure how to set an element? haha... I can buffer[i].Add() but I can't seem to do buffer[i][n] = ..
Cannot modify the return value of BufferAccessor<myBufferElement>.this[int] because it is not a variable
maybe not the best idea, but maybe memset might be able to do? I imagine you can just grab the ptr address, increment it and then set it using that call
yeah because it returns a copy/value you'd need to buffer[i] = new or use the ptr to make a ref
hmm but Property or indexer BufferAccessor<myBufferElement>.this[int] cannot be assigned to -- it is read only so buffer[i] = new doesn't work
bit surprised to have to use memset? Is it safe (other than the usual NativeDisableParallel and being sure to never write to the same index obviously)
just a sec, ive got the example working
oh nice
hmmm... this is an asset to be sold.. was really hoping to avoid having to set a project to support unsafe
๐ฆ
wait.. the 'Normal assignment' works for you?
I need to get my head around something... doesn't that for(int i = 0; i < bufferAccessor.Length; ++i) belong within a for (int i = 0; i < chunk.Count; ++i){} loop?
oh wait hang on let me re-read
yeah its a bit confusing, i was thinking the same thing, its because its the same pattern as GetNativeArray<T>() where it grabs the whole chunk.
[BurstCompile]
public unsafe struct MyChunkBufferTest : IJobChunk
{
public ArchetypeChunkBufferType<MyData> SelectionBufferDataType;
public ArchetypeChunkComponentType<Translation> Translations;
public ArchetypeChunkEntityType Entities;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var entities = chunk.GetNativeArray(Entities);
var bufferAccesor = chunk.GetBufferAccessor(SelectionBufferDataType);
var translations = chunk.GetNativeArray(Translations);
for (int i = 0; i < entities.Length; i++)
{
var entity = entities[i];
var translation = translations[i];
var buffer = bufferAccesor[i];
var bufferPtr = buffer.GetUnsafePtr();
for (int j = 0; j < buffer.Length; j++)
{
// do stuff.
}
}
}
}
yea - I got there ๐ thanks!
@vagrant surge in my small repro it looks like you're right - not that big a difference... shoot... I need to investigate more.
Small aside.. how come I can write ```[BurstCompile]
struct TestJob : IJobForEachWithEntity<...>
{
public NativeArray<TestData> testData;
public void Execute(Entity entity, int index, ref ...)
{
testData[entity.Index] = new TestData() { Test1 = index };
}
}without testData requiring a [NativeDisable...] attribute? I've been using IJobChunk most places but does IJobForEach provide something extra for parallel writing? Or more likely have I misunderstood what it's actually doing? When I doreturn new TestJob()
{
testData = testData,
}.Schedule(query, inputDeps);``` that's not by copy right?
it does copy something like 20-30 bytes for the ptr, length, allocator label safety etc but it doesn't copy the actual array data, that stays exactly where it was.
cool.. just checking I'm not crazy... any ideas on why it's safe to write to it in parallel? in IJobChunk I'd usually have to add the [NativeDisableParallelForRestriction] tag
nah not sure ๐ฆ but IJobForEach is effectively sugar on top of an IJobChunk so you'd think it would behave the same!
er maybe I just had the burst safety checks off and that's the difference ๐
anyone know if there's been updates to the workflow to getting the update method to run in fixedupdate?
hopefully unite will bring something new
Can i store CDFE/BFE inside another struct like and use attributes?
struct SomeJob : IJob
{
public CDFE_Container;
public void Execute() {...}
}
struct CDFE_Container
{
[ReadOnly]
public ComponentDataFromEntity<C> C_CDFE;
[NativeDisableParallelForRestriction]
public BufferFromEntity<B> B_BFE;
}
Does it take several seconds to press play when using Unity Physics v0.2.2 for anyone else?
hi all, we're doing some collision detection and resolution a were wondering if Jobs has some sort of Multiple Producer Single Consumer process that we can easily use
the goal being that collisions will be processed by the consumer thread as the collisions are being calculated instead of just being thrown in a collection and calculated afterwards
@prisma anchor just as fast as it was in previous versions to enter play for me
Hmm. Not doing an accurate count, its like 15 secs for me to actually get in.
I just upgraded another project's Physics from 0.2.0 -> 0.2.2. There is a noticeable slow down.
all i can suggest is try to delete the library, if that doesnt work sounds bug report worthy
Is there any site to check for ecs changes?
It's been a while since i've used it and i dunno what changed
@slow epoch,
from Entities -package: https://docs.unity3d.com/Packages/com.unity.entities@0.1/changelog/CHANGELOG.html
from DOTS sample repo: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/ReleaseNotes.md
oh wait the samples changelog doesn't really tell much for the ECS changes anymore
it used to be super informative about changes in past
The first one works, thanks!
learning from this, I added the DOTS package changelogs to the pinned message on this channel
Hello, I started today with ECS and there is something that I dont undestand. If know that I can have x entities, with theis own parameters, but in the moment of the behaviout wont they work the same? Since the system tell to all to do the same
[SerializeField] private Material material;
private void Start()
{
EntityManager entityManager = World.Active.EntityManager;
EntityArchetype entityArchetype = entityManager.CreateArchetype(
typeof(LevelComponent),
typeof(Translation),
typeof(RenderMesh),
typeof(LocalToWorld),
typeof(MoveSpeedComponent)
);
NativeArray<Entity> entityArray = new NativeArray<Entity>(5, Allocator.Temp);
entityManager.CreateEntity(entityArchetype, entityArray);
for (int i = 0; i < entityArray.Length; i++)
{
Entity entity = entityArray[i];
entityManager.SetComponentData(entity,
new LevelComponent { level = UnityEngine.Random.Range(10, 20) });
entityManager.SetComponentData(entity,
new MoveSpeedComponent{ moveSpeed = UnityEngine.Random.Range(1, 10) });
entityManager.SetComponentData(entity,
new Translation{ Value = new float3(UnityEngine.Random.Range(-8f, 8f), UnityEngine.Random.Range(-8f, 8f), 0) });
entityManager.SetSharedComponentData(entity,
new RenderMesh {mesh = mesh, material = material });
}
entityArray.Dispose();
}```
For example with that, they just move up and down
how you can tell to one entity to move to the right without doing it to all
@gusty comet you would know which entity you want to change, and instead of looping through every entity, just do stuff for the ones u want to change... You could isolate an entity by making it have a component that the others don't have. Then you can use GetEntityQuery() to make a query that lets you filter just to entities matching a specific set of components.
Does anyone know of a public game of life/cellular automata sample?
I feel like the techniques used for that would be somewhere in the intermediate range, where we lack good samples.
this could be cool https://www.youtube.com/watch?v=9U0XVdvQwAI&feature=youtu.be
Marble Marcher is a video game demo that uses a fractal physics engine and fully procedural rendering to produce beautiful and unique gameplay unlike anythin...
also, list of games on github https://gist.github.com/roachhd/d579b58148d7e36a6b72#user-content-arcade
maybe http://hextris.io/ (https://github.com/hextris/hextris/) or a dirt simple tower defense?
I have already suggested tower defense to several people as a game/genre to try for getting into ECS, as it's mechanically simple.
But I was asking specifically about ECS game of life/cellular automata as a sample, becuase I have an idea which would use a lot of the same mechanics
yeah, and u could ramp up the projectiles/effects the towers shoot and the nubmer of enemies which would be cool
Still not made in Unity ECS, and that's what I'm looking for
I have implemented the game of life before
Just.... translating that to ECS...
oh sorry i misunderstood, i thought u were intending on creating some examples
Ah, no, I was asking if anyone knew of an existing one. Though if I do stop putting it off and actually sit down to make something in ECS, I'll be sure to make the repo public
i dont think game of life makes any sense in ECS
you implement it on a bitmask usually
good use case for Burst tho
Hello, what's the proper way to associate an array of matrices with an IComponentData (DynamicBuffer? BlobArray?). The size won't change but I need to read/write from jobs
i would assume you would want dynamic buffers for most situations needing arrays
I'm following some tutorials and in it you make an entity using EntityManager.CreateEntity, but mine returns an error, do we now always need Archetypes?
what's the error message?
'World' does not contain a definition for 'EntityManager' and no accessible extension method
how are you using the EntityManager? what's the code?
it should be the same as the tutorial but its from a few months back so I guess the tut is outdated
weird it should work fine like that
i even tried restart unity ๐ข
are you up to date for your entities package?
yeah, 0.0.12?
latest is 0.1.1
@prisma anchor in the forums they explained that the slowdown after updating unity physics, is due to the burst jobs used for collider generation being compiled on start instead of on demand, this should improve when they release an updated version of burst that cache compiled jobs
Lol. @wooden canopy That was me who asked the question. Thanks for the follow up!
ups ๐
Is there any way to load data to an entity like an image or sound without being a gameObject and converting it to an entity?
Or being referenced from a singleton monobehaviour
For audio you can store clips in a blob asset, also I'd take a look at their DSP Audio, for images you can also store images too in blob assets
Is there any docs about blob assets? I haven't heard of them
Does making a job dependent on another freezes the main thread ?
@unborn bear that doesnt sound right. @slow epoch theres nothing official afaik, only stuff in the forums if you search or from going through the package code. i think physics might have some good examples, also a file called BlobificationTests.cs might have some info
weird, I made a mesh slicer where jobs share the same NativeArray, and for some reason I am having some spikes whenever I perform a cut
@slow epoch take a look at BlobificationTests.cs in the package, it goes over the basic way on how to construct a BlobAssetReference<T> which you can store in a struct as an IComponentData
what's the best way to destroy a bunch of entity's? Destroy 1 roughly every 0.2 seconds or wait till they build up and destroy a bunch say every 5 seconds?
i think the most efficient way is to destroy using entitymanager taking an array of entities - but whether you really need to go this far for optimizing is another thing entirely
yeah I'm using an EntityManager in a component system, I'm destroying entity's when they reach a waypoint individually. So it could happen quite frequently
It doesn't seem to be impacting performance that much so I guess it shouldn't matter that much
What is the correct way to wait on a job to finish ? I am using a coroutine but it just feels wrong
JobHandle.Complete()?
that would freeze the main thread because it would force it to wait until job completion
if you need a flag, there's an IsCompleted field
yeah if you use the Iscompleted with JobHandle.Complete I think that's probably the best way
I don't think it freezes the main thread or anything it just jumps to the main thread
.Complete forces the thread to immediate evaluate
Yes, I know that flag. What I mean to ask is: How do you guys wait on a job to complete ? Do you guys use a coroutine OR something else ?
yeah you can use it to force the job to only run once or just make sure its completed before doing something else
I just schedule the Job and let Unity's job system handle the completion
There's a brief section abt 'Scheduling early and completing late.'
then you are basically "freezing" mainthread aren't you ? If you make a job a call complete right after it, you did not run anything a parallel
you just processed stuff with a job
me, i very rarely call JobHandle.Complete()
I only need to call it if I absolutely need to evaluate something immediately
You using jobs with ECS ?
Yes
Then that is probably why you have a different perspective. I am using only the job system, no ECS.
Ah, that makes sense - I never really used the JobSystem outside of ECS yet
I see. The only way I can think of waiting on a job to complete is whether polling it on an Update function (bad in my opinion) or using a coroutine to do that (better but dirty)
I noted some weird gotchas like, making IJobs share the same NativeArray (in other words, make an IJob depend on the completion of another IJob) freezes the mainthread apparently (maybe they call '.Complete' internally ?)
yea, since the entity manager is the one handling the jobs (I'd imagine), they just call Complete() on the job
for (int t = 0; t < m_TypeCount; t++)
{
((JobHandle)(&m_ComponentSafetyHandles[t].WriteFence)).Complete();
int readFencesCount = m_ComponentSafetyHandles[t].NumReadFences;
JobHandle* readFences = (JobHandle*)((byte*)m_ReadJobFences + (long)(t * 17) * (long)sizeof(JobHandle));
for (int r = 0; r != readFencesCount; r++)
{
((JobHandle)((byte*)readFences + (long)r * (long)sizeof(JobHandle))).Complete();
}
m_ComponentSafetyHandles[t].NumReadFences = 0;
}
back at it again, and straight back to ECS at that. Has been a while, did we get Boolean functionality yet or still just using byte vars?
Bool is cool now ๐
Should we avoid using ComponentDataProxy<IComponentData> (is it going to be deprecated, or is there some negative impact on performance)?
I know there's a bunch of different ways you can create entities - I've been using IConvertGameObjectToEntity
going to be deprecated,
yes
or is there some negative impact on performance
kindof, it didnt scale well in performance or development complexity
conversion workflow is the future, its also getting some love soon from what I hear
ooh that's very nice to hear, I'm curious as to what new things they'll add lol
Conversion workflow needs a lot of love before it's viable.
but what about being able to... yknow.. click on an object in the editor view and seeing its params
or a system being able to see its variables while running would be nice
doesn't the entity debugger already do that? if by variables you mean entities
but you cant find an entity easily by clicking on it in viewport
As long as it has a position, you could make a crude ray-marching/tracing 'what did I just click at' system
Some stuff like that should be standard, I think. Maybe not part of the base package, but a package with some helpful tools for debugging and/or general development of ECS wouldn't be a bad idea.
thats something that baffles me
there is tons of stuff they can do that would make ECS usable for development right now
but they dont
makes me think that the ECS team is just Mike Acton and 2 friends
hey man I've built my whole game on ecs
its rough but doable
that debugger is more than enough info imo
but its getting worked on, just gotta wait another week for their anouncements
What kind of game is that by the way? Like, genre and stuff. ECS fits certain types of games better than others...
im surprised they dont have rough data modifying on the entity debugger
really need some enterprising individual to make an asset store ecs inspector ๐ get in on that early user cashflow!
lol, potentially get hired by unity to build the editor ๐
win win scenario
too much work otherwise I'd be making more ecs stuff
I'm looking to just open source all my stuff in the end though
ecs is too good not to share
same except just a module of it
been working on making a 'primitive' UI system cause uGUI is a bit jittery
yeah UI is one I really want to port to ecs soon
I've gotta make it vr friendly though, in world
so far the two ecs UI's I've seen were 2d in screenspace
uGUI sucks imo
ah, which UI's were they, if you still remember?
uh I can find you one
This is the first release of the DOTS UI system (https://forum.unity.com/threads/showcase-pure-dots-ui-system-detailed-description-feedback.688531)....
just had a post
didnt even have to search
aw yis
all his info was in the previous one
source code released: https://forum.unity.com/threads/source-code-dotsui-open-source-ui-project-for-dots.715880/
Motivation
The current Unity UI...
ah very cool, I'll look into it for a bit
๐๐ป
most still doing hybrid, or is pure more feasible yet?
guessing a lot has been moved behind the scenes on a lot more of the standard tools/compilation and especially the newer packages
Hi, I have a question about what is destroyed when a gameobject is destroyed. Suppose I create an instance of a non-monodevelop class in a component (therefore create with new), then store a reference to that instance in a second component. If I destroy the first component that created that instance, would it destroy the instance as well?
My suspicion is that in this case only references to the created instance would be destroyed in the destroyed component and it would be GCed later if there were no references to it. Just need confirmation from the enlightened.
I removed hybrid for now, it is always breaking with bleeding edge HDRP api changes and it doesnt work at all with DXR
i can understand your frustration, im using hybrid with LWRP and its broken in a different way with pretty much every editor version since 2019.3.0a8 (like 8 versions ago). There's always packages trying to access editor API functionality that no longer exists or doesn't exist yet.
so you have to trial and error to find the magical package version soup that works, but then each package brings its own bugs that mess you up in other ways.
I can fix the HDRP API changes from the hybrid package (done that many times), but fixing raytracing is like totally another level thing ๐
that could like require engine level changes
@wanton girder a non-UnityEngine.Object class exists independent of where it was created, so generally it will be kept alive as long as there is a reference to it somewhere. I say generally because unity's garbage collector is different than normal .net GC. I am not certain it won't do something weird like take a while to figure out it can dispose of it.
If you have a GameObject that has 2 components, both referencing the same instance of foo; then you remove the first component. It will still exist because the second component holds a reference to it.
UnityEngine.Object derived classes act a little differently in that the class will start resolving to Null when it gets destroyed on the Native side regardless of if you have references to it.
anyone has an example of conversion scriptable object to blobAsset?
public class Bucket : ScriptableObject {
// some data here
}
public struct BucketWrapper { public Bucket Bucket; }
public struct BucketPtr { public BlobPtr<BucketWrapper> Ptr; }
public struct BucketBlob : IComponentData { public BlobAssetReference<BucketPtr> Blob; }
// The func that will create the blob
public void ConstructBlob() {
var builder = new BlobBuilder(Allocator.Temp);
ref var root = ref builder.ConstructRoot<BucketPtr>();
ref var wrappedBucket = ref builder.Allocate(ref root.Ptr);
wrappedBucket.Bucket = some_scriptable_object_of_type_bucket;
var blobAsset = builder.CreateBlobAssetReference<BucketPtr>(whatever_allocation_type_you_want); // Mostly you'll want a persistent one instead
builder.Dispose()
return blobAsset;
}
when you destroy the entity with the blob, you'll likely want to release the blobassetreference too unless you're managing the ptr yourself externally
thank you
Hi Everyone, I had a question. If I want to represent a ring buffer of IComponentData, how do I represent that? i.e
SnapShot : IComponentData {
int tick;
int[] createEntityIDs;
int[] updateEntityIDs;
int[] deleteEntityIDs;
}```
on the client & server i need to store an array of these 'Snapshots`. Would I make another component simply storing this data?
You can likely store them in DynamicBuffers, b/c you can't store managed types in IComponentDatas
@prisma anchor fholm#9083 has an unsafe RingBuffer on github that might be of interest. https://github.com/fholm/UnsafeCollections/blob/master/UnsafeCollections/Assets/UnsafeCollections/Collections/UnsafeRingBuffer.cs
Where are we with ECS these days? Is it likely to be changing much from this point?
You should wait a bit for the copenhagen
It's the next week
And i'm sure they'll announce new features
@urban rivet you going to unite? ๐
yeah, we've talked online for like 6-7 years without any IRL contact, why ruin it now ๐ค
to be serious tho, I'm kinda worried about not being the anonymous guy, I like keeping some distance to my online "personality"
its weird at first but its nice after the inital wears away
at least you already have something in common :^)
@trail burrow couldn't make it this year. Unity was really kind to extend an invite too
I probably won't come until I've got some headway done on my game out of sheer procrastinatic embarassment tbh
haha
can't turn up red faced without a decent demo!
wheres that game ;)
Clearly not here, since hippo's nowhere to be found ๐
๐ถ๐ป ๐จ
I dont suppose anyone knows why if I use the below code then the whole system just dissapears or destroys itself
public class CountRobotsatWaypoint : ComponentSystem
{
public Entity countent;
protected override void OnCreate()
{
if (!EntityManager.Exists(GetSingletonEntity<CountRobots>()))
{
countent = EntityManager.CreateEntity(typeof(CountRobots));
EntityManager.SetName(countent, "CountRobots");
}
else
{
}
}
Systems will disable when they have no more 'targets', if that's the entire system then they'd detect 'oh well, nothing more for me to do here' and disable it.
I think it was [AlwaysUpdateSystem] which stops that behavior. The ondisable or whatever method can be useful for figuring out when it happens.
that's not all the code I have a foreach loop as well, which seems to activate after but then the whole thing just disappears
its not even disabled its like the whole system is destroyed, its really weird behaviour
and using AlwaysUpdateSystem doesn't work
is there anything in the update loop for the system to actually work on?
yep, I'll post the whole code maybe that will help
also if you stick something in like Debug.Log("test"); before the update foreach does it force it to run?
[AlwaysUpdateSystem]
public class CountRobotsatWaypoint : ComponentSystem
{
public Entity countent;
protected override void OnCreate()
{
//if (!EntityManager.Exists(GetSingletonEntity<CountRobots>()))
//{
countent = EntityManager.CreateEntity(typeof(CountRobots));
EntityManager.SetName(countent, "CountRobots");
//}
//else
//{
//}
}
protected override void OnStartRunning()
{
//if (!EntityManager.Exists(GetSingletonEntity<CountRobots>()))
//{
// countent = EntityManager.CreateEntity(typeof(CountRobots));
// EntityManager.SetName(countent, "CountRobots");
//}
}
protected override void OnUpdate()
{
Entities.WithAllReadOnly<ToCurrentWaypoint>().ForEach((ref ToCurrentWaypoint dude) =>
{
if (dude.value == 1)
{
if (HasSingleton<CountRobots>())
{
var countem = GetSingleton<CountRobots>();
countem.value += 1;
Debug.Log("Why is this not working");
}
}
});
}
}```
Does any entities with ToCurrentWaypoint exist?
yep
Hm, weird
And the force update...
Sounds like you might have struck a bug, or at least a edgecase that should have a warning or documentation
I have to have some way of checking that CountRobots exists because if I did it in Onrunning then it created 2
i mean stick the debug before the ForEach and if it shows in the debugger as running, double check that the system does or doesnt have entities to process
Theoretically those entites could lose their components or be destroyed, though, are they still in the entity debug menu thingy?
just to say, the way it looks to me, if (HasSingleton<CountRobots>()) should be outside the Entities.WithAll anyway no? You wouldn't want to check it for each entity
unless you create it in the loop or something I guess
That's a good point too, a singleton check should definitely be outside of any loops (unless, as you said, the singleton might be created/destroyed in the meanwhile)
Then it sounds like aggressive optimization from the system-system (whatever keeps serial killing innocent systems)
It might just be a lambda thing they don't yet support?
yeah I'll post it as a bug for the Unity devs see what they say
You can also do RequireSingletonForUpdate<T> in OnCreate
It seems like I've found another bug, for some reason OnStartRunning is run twice
its effecting another system, making it run way to long and not in the way I want
I don't know if I'll use a singleton you have to use SetSingleton to set it and I'm not sure if that works for what I want
you have to be careful with OnStartRunning because every time a system is not run because of RequireForUpdate or from the queries used it will cycle both OnStartRunning OnStopRunning again. So you really can't use it for initialization. I've been bitten by that numerous times.
the trouble is I cant use OnCreate either as the Gameobjects don't exist or the other system doesn't exist
it's weird how oncreate runs before monobehaviours, but onupdate runs after monobehaviours
or other way around
i forget
i know what you mean, its messed me up where singletons from ConvertToEntity i needed hadn't been created yet in OnCreate ๐ฆ gets frustrating.
yeah I can kind of get around it but the Systems really are confusing how they are run
protected override void OnStartRunning()
{
if (MoveWaypointslist.Length != WaypointGameobjects.Length)
{
WaypointGameobjects = GameObject.FindGameObjectsWithTag("Waypoints");
for (int i = 0; i < WaypointGameobjects.Length; i++)
{
var tempwaypoints = WaypointGameobjects[i].GetComponent<Transform>();
var someotheval = (float3)tempwaypoints.position;
MoveWaypointslist.Add(someotheval);
}
}
}```
that seems to fix it for now
hmm just my curiousity
is it possible to just have a gameobject with a list of points, convert it and add the list of points to a buffer on an entity
is it possible to just have a gameobject with a list of points, convert it and add the list of points to a buffer on an entity
yep
yeah of course
I think the caveat is you'd have to write some scene view tools if you wanna edit them in editor time
yeah it woudl be more complicated if you wanted to keep them in sync or edit the entities directly from handles or something
that's what I'm basically doing except they are separate gameobjects and I'm adding them to a list instead
yea, jw
Does anyone else here use Rider? Does anyone know if it's worth using?
I tried it for a bit, it's certainly nice with a ton of features
local history view seems to be really nice for a lot of ppl
but the problem I had was that it slowed down a lot for me trying to query a lot of things i just ended up sticking with omnisharp + vim
I guess its worth trying, a guy is giving out free promo codes for six months
haha yea, i'd certainly give it a shot, it takes some time getting used to the hotkeys it has
In this Unity Tutorial, I'm gonna teach you how to use a tool that'll help you code faster in Unity and speed up your development workflow. #GameProgramming ...
if anyone else is interested
@pliant pike just in case you didn't know, in OnCreate you can use GetOrCreateSystem<> and if the system doesn't exist at that point, it will create it then and there. If you require that system to have run, then possibly you want your second system to require a Created component or something to be present on the entities you want to change. There are also [UpdateInGroup] attributes to specify order of systems where needed.
Oh ok, thanks @amber flicker
Edit: Figured it out, problem with other system, not with input system
Might be this issue here
PlayerInput input = inputs[j]; <- this might be a copy of inputs[j] which means that you're not modifying what's in the chunk
yea but in the end I'm writing to inputs[j]
oh totally didn't see that
so basically that's the only line I'm confused about, since the debug.log is firing correctly when there is input
hmm, it's the only system modifying the input right? you dont have a separate system zeroing it out immediately after I assume
I have another system which is ReadOnly accessing it
This is not using a job, so I'm less familiar with how to handle it
same here ๐ค
maybe there's some sort of timing issue going on, since the other system is using a job
๐คท
GetArchetypeChunkComponentType<PlayerInput>(false); <- false means you can read/write right?
yea
hmm, ๐ค yea i wouldn't know till I try it out, srry
Does anyone have any thoughts why modifying Translation component before CopyToGameobject runs would cause so much jitter?
@coarse turtle & @mint iron thanks for the info
@coarse turtle I figured out what was happening.
The Input system was doing it correctly and the chunk was updating.
In my movement system, I was switching from Translation + Rotation to LocalToWorld. However, I had left the old Translation and Rotation archetypes in the code (I had added LocalToWorld to the query as well), and there's a catch
https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/transform_system.html
User code may write directly to LocalToWorld to define the transform for an instance, if no other transform components are associated with the same entity.So after I completely removed the Translation and Rotation archetypes from the query and job, everything started working (it's confusing, since you can still see those types on the entity in the entity debugger....)
I guess the documentation means you can write to LocalToWorld as long as no other transform component is part of your query/job
Ah makes sense
I have a design question, if i'm working in a Console system with commands and stuff. I suppose the Console itself is a system and the commands are IComponentData, but where is the logic shared with a given command?
Can a component store logic and that logic be executed by a system?
a component could contain logic, but its sort of against the concept of having a clear data/logic separation.
What about having a delegate in the Component and executing that delegate inside a system?
Sounds dubious, can you tell us more about what you're trying to accomplish?
A Console system like CSGO where you write commands and does stuff
And i still get problems designing for ecs
I don't know if it's about not having enough tools still for ecs or that i don't know how to approach it
I assume you'll have a lot of different commands, so having a different system for each command would not be practical. Leaving you with switching somehow within a single system.
You could do a different component per command, or have a type within a command component.
The logic is still in the system, the component contains whatever info is needed to complete the command.
