#archived-dots
1 messages ยท Page 190 of 1
what animation package/classes should I be using with dots/ecs?
DOTSSample seems to have this "Animation" package, but it's not listed to download in my 2020 unity
not sure why this isn't listed in my package manager...
I seem to have a com.unity.animation@0.2.16-preview.5 folder...
I dunno what im doin ยฏ_(ใ)_/ยฏ
halp
ok so "Animation" is pinned but... I dunno why I dont' seee it in my package manager
AHA show dependencies
nope that didn't do it
that's dumb
I don't think the github exists anymore?
I dunno how to get this package ๐ฆ
@slim nebula yeah most experimental packages are really hidden and can only be added via pm.
just open pm > add pacage from git url > paste in com.unity.animation.
here's the full list of stuff that is now hidden from pm
oh
Whats the chances of that entities.17 to be released this year?
Having some major problems with the lighting in subscenes. This is happening in 2020.2 but not in 2020.1, is this a bug related to my hardware or am I doing something wrong?
Lighting appears to flicker on/off randomly. Does this in game, in scene, and in builds
just add a seizure warning to your game startup (cyberpunk meme, sorry I couldn't resist)
is there any way to obtain the old package versions required by DOTSSample?
it seems to download the package source files as random junk (xml, binary data, anything but source)
So I take it this is not happening in your 2020.2? (assuming you're using that version)
no sorry that was a new question, not in relation to yours sorry
I'm not quite far enough to be doing lighting and stuff sorry
NP - I posted it on the answerhub - I am not seeing any record of this happening to anyone else so it may just be my hardware. Especially consdiering its happening in .2 but not .1
hmm I might try this answer hub
is this what you mean? https://answers.unity.com/index.html
yea
I imagine some people just have certain categories set to automatically follow so they get notifications when they're posted
Is there a list somewhere that shows which gameobject components are compatible with convert to entity?
@slim nebula yo, I'm getting the same warnings as you on Unity not disposing stuff
ye
just uh
ur frames are too fast
add more work, and the jobs can finish within 4 frames
it's not a "real" problem. yeah
like it makes a job, then 5-10 frames go by cause ur not doin any work. your fps is prolly 400+
I limited mine to 240 FPS and it fixed it
hmm I donno then
using System;
using System.Threading;
using Unity.Entities;
using UnityEngine;
class TargetFramerateSystem : ComponentSystem
{
/// <summary>
/// Singleton component to initiate the connection after initial startup systems are created
/// </summary>
private struct InitGameComponent : IComponentData { }
/// <summary>
/// Called when the system is created
/// </summary>
protected override void OnCreate()
{
// Create singleton
EntityManager.CreateEntity(typeof(InitGameComponent));
// Require singleton for update so system only runs once
RequireSingletonForUpdate<InitGameComponent>();
}
/// <summary>
/// Called every frame
/// </summary>
protected override void OnUpdate()
{
//// Destroy singleton to prevent system from running again, since this system was created with RequireSingletonForUpdate above.
EntityManager.DestroyEntity(GetSingletonEntity<InitGameComponent>());
Application.targetFrameRate = 240;
}
}
I just added this and it's fixed for me
I dunno
it's a well of despair problem
u get like a bunch of frames quick
then it stalls
then more frames quick
repeat
need to reduce that fps spike I think and it should fix
for the internal stuff at least
I think it happens when I switch between scenes
ah, if it's just a couple then it's fine
mine were happening like constantly. causing GC spikes from the log messages
a few jobs takin a bit longer isn't the end of the world
it's only a problem if it's happening regularly
as it affects performance at the time it happens
72 lol
I need help with this: https://cdn.discordapp.com/attachments/497874081329184799/789658607451897917/unknown.png
๐ฆ
Looks like you just need to add the skinning node to your HDRP shader?
iirc that's how the Basic_Vertex_Skinning shader graph looks like
you just need to copy it and add basic albedo/color properties
@slim nebula are you using dots?
well, you could tell that in the forum post
seems to work
the shader doesn't support it out of the box. need to make a graph to support vertex animation. I didn't know that
I guess I could reply and say it's solved
thanks
@deft stump (I love your name)
I've just started with DOTS, Jobs and looking at meshing examples. From what i understand is i can't use burst with using shared mesh data RenderMesh. Does that mean i effectively need two systems in ECS to do meshing?
I'm looking to burst the vertex calcs then combine them into a mesh but i don't see how this could be eaily done using ECS (SystemBase)?
You don't necessarily need two systems. You can process your mesh data (native arrays or MeshDataArray) inside a bursted job. You assign that job to a jobhandle and check jobHandle.isComplete every frame. Once it's complete you then copy your mesh data into the mesh in a main thread non-bursted job
@zenith wyvern This sounds like a job not part of the Component System? (SystemBase)
Both jobs can run in the same system. If you want your mesh processed and updated in the same frame then yeah you would want two systems, probably one that runs in InitGroup and one that runs in PresentationGroup
All job examples I've seen exist outside of Systems.
I think this is why I'm getting confused.
Thanks for your help @zenith wyvern this documentation provides a much clearer intention using the latest Systems https://docs.unity3d.com/Packages/com.unity.entities@0.11/api/Unity.Entities.SystemBase.html
You should also check the manual, it's pretty decent at this point https://docs.unity3d.com/Packages/com.unity.entities@0.16/manual/ecs_entities_foreach.html
Ah your right 16 is the latest x.x
@zenith wyvern Up to this point i've been watching old YT videos to get started obviously lots have been quickly outdated.
Don't think I've seen a single one mention System attributes lol. But this gets me on the right track.
everything has such similar names... is "Animator Controller" part of com.unity.animation?
oh wow. kinematica looks awesome
hopefully the package versions required by the demo are still downloadable from the package manager...
@zenith wyvern verticesList is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing, attempting to use NativeList (to process mesh data). I can't seem to find a reason why this doesn't work vs a native array?
NativeList<float3> verticesList = new NativeList<float3>(Allocator.TempJob);
I think a list is meant more for dynamic purposes. since it can be resized, any job accessing it could be a race condition
Having a couple crashes on Android, so I decided to build a release build with force debug information enabled. Now I'm seeing a bunch of:
```The method Void _mono_to_burst_Hash64Long(Byte*, Byte*, Int64, Byte*, UInt64 ByRef) must have MonoPInvokeCallback attribute to be compatible with IL2CPP!
Unity.Burst.BurstCompiler:Compile(T, Boolean)
Unity.Collections.xxHash3:.cctor()
Unity.Physics.Authoring.HashUtility:Initialize()
Unity.Entities.ComponentSystemBase:CreateInstance(World)
Unity.Entities.World:AddSystem_OnCreate_Internal(ComponentSystemBase)
Unity.Entities.World:CreateSystemInternal(Type)
Unity.Entities.GameObjectConversionUtility:AddSystemAndLogException(World, ComponentSystemGroup, Type)
Unity.Entities.GameObjectConversionUtility:AddConversionSystems(World, IEnumerable`1, Boolean)
Unity.Entities.GameObjectConversionUtility:CreateConversionWorld(GameObjectConversionSettings)
Unity.Entities.ConvertToEntitySystem:Convert()
Unity.Entities.ComponentSystem:Update()
Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
Unity.Entities.ComponentSystem:Update()
UnityEngine.LowLevel.UpdateFunction:Invoke()
(Burst 1.4.3 physics 0.5.1-preview.2)
The bug with no debug information just happens after like 10 minutes of gameplay and not "on start" like this error ๐ค
Anyone spontaneously knows what's causing this?
How is this valid syntax?
Obviously float float; is not valid, why is this?
[ReadOnly] public PhysicsWorld PhysicsWorld;
PhysicsWorld is not a C# keyword
generally, you can't use C# keywords as variable names
float @float; <- this would be valid tho
@zenith wyvern verticesList is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing, attempting to use NativeList (to process mesh data). I can't seem to find a reason why this doesn't work vs a native array?
@fair stirrup
I would need more context to see what's going wrong. It looks like you're trying to write to a nativlist in a multithreaded job. You'd need to use ParallelWriter for that
For IJobParallelFor you need to use NativeDisablePatallelSafetyRestrictions to disable parallel safety checks on the container if you're writing outside the given index - as long as you're sure you're not overlapping indices
anyone know a good NetCode tutorial?
I'm starting to make a youtube series where i literally just look at the github repo on examples and read documentation and talk about it
Feel like no one knows what's going on with NetCode and I'm not exception
okay
is this a bug?
a ijobparallel for takes 0.21ms to finish it's job
but the wait takes 5.46
look at the collision modules on top (right under the part you highlighted on red)
it's basically waiting for those
so it also waits for internal jobs to complete
Is there a way to constrain rotation in Unity.Physics? seems that if I convert a game object to an entity it ignores Rigidbody constraint / Rotation Conostraint GO components
@lost umbra the working but somewhat cheaty thing I do to do that is just set the entities rotation to zero every update. Though that constrains all rotation
It was on track for this month, but some notable bugs have pushed it back. Last I heard, the new target is mid-January.
https://forum.unity.com/threads/entities-0-17-changelog.1020202/#post-6641668
so not only we don't have enable/disable but 0.17 has been pushed back.
cruel 2020
:pepehands:
When an entity is created by command buffer in a system job, does it return a value of -1 when following in debug mode? I am getting an "Entity does not exist in command buffer" error, but since it is created later when the command buffer completes then it would make sense to me that it isn't created yet. https://i.gyazo.com/262f9c158ae3b861f4f2d93731bd32b1.gif
ecb instantiate returns a temporary entity id which is negative - they then later get remapped - it returns a temp id so you can do more manipulation of that entity with the same ecb.
ok thanks
Is there a way to run a system after the -end fixed step simulation entity command buffer system- in the fixed step simulation system? I have a system that removes entities at the end of the fixed simulation group and that is the only place I destroy entities but still getting entities do not exist errors from command buffer
oh duh, latesimulation group update is fixed too
I really like how it is split between simulation and presentation
If only there was some sort of official communication channel they could use to keep people informed of this...
And their "secret" DOTS slack channel doesn't count
So im having another architectural dots issue... this time a combat system... my game is some sort of top down point and click game. The player/mob is its own entity with components... and the items aswell. Therefore i have a player entity which has a inventory component where i reference a equiped item-entity. My biggest problem here is to come along a good "damage dealer" system. The item entity ( weapon ) should be used for getting the attack speed and damage... but the player entity itself gets marked for executing an attack... my biggest flaw here is that the weapon and the player are two entities, not one. Any ideas or tipps for a flexible system that throws damage events ? It should be flexible enough to either take the damage from a referenced entity or from the entity itself ( Player's weapon, Area that damages ... ). Kinda stuck here because i cant find any good sources on how other games implement this :/ So im glad for any help
@stone osprey
maybe have another system that sits in between the player and the weapon.
when the player recieves / reads that it's time to attack.
it sends it to the weapon (through the system I mentioned),
and do magic or whatever
That's my biggest complaint about DOTS right now, the lack of communication. Everything we get is from people asking questions on the forum.
We shouldn't have to ask to know what the plan for the next ~2 months looks like.
Planning stuff ahead is extremely difficult with the current way unity handles their communication with us.
What communication? ๐
@deft stump Thanks ! Thats a good idea ๐ Even if its some extra work... Probably this is also a good use for events, like "player_attack" and then the weapon looks if its equiped and sends the damage event
Thats the only flaw so far in an ecs... relations between entities
It can be a bit verbose.. and removing rand access from hot paths can be a challenge but generally, CDFE/GetComponent etc works pretty well I find. My sense is you're maybe working on a system that is more complicated than intuition may lead you to believe. Having fire on the ground that does damage over time, that is maybe done by a member of your party but doesn't injure you (even though it wasn't caused by you) that will transform when an area ice spell is cast over it, with poison also there doing damage over time and then someone using a reflect spell... I'm obviously taking this to a bit of an extreme but just wanted to make the point that this comes up a lot and I think its useful to add constraints where possible and not build a system from the get go to do everything.
i.e. maybe there isn't such a thing as environmental damage or else its handled separately. Perhaps a weapon only changes your characters single 'attack' modifier and that's it. Not necessarily what you want, just some thoughts.
Thanks ! Probably im just to scared of having too much systems... I currently have over 70 different Entities.ForEach loops for different compositions... Most of them are running event based :/
I'm inherently generally wary of an event based approach in ecs.. it feels quite object-oriented to me.
@stone osprey #archived-dots message
Theres no reason to avoid something because it's like oop. But you should be weary of using the same hammer everywhere. You might be making things more complex and harder on yourself
Don't be afraid of lots of systems, condense when you can later on. Systems and the foreach in them are the encoding of the logic in your game. That complexity had to be somewhere for it to behave how you want. One of the pluses of ecs is the fact it's all easy to find and manage where it is. On the other hand ecs does make some things take more lines to do, but I personally find the complexity per line way way lower, so in the end it has been helpful in core areas of the code.
i would recomend the revese, were you start with fat systems and split them once it makes sense
using the ECS as event system actually works pretty damn nicely. Its one of my favourite patterns to use
the main fun stuff with ecs events is that you can do absolutely ridiculous stuff, like if the target entity has "deflect" component, then you swap source with target in the event
fat systems and split them once it makes sense
do it also with components too. splitting them up is far better than making a monolithic one
the problem is just how tied it is to system order, and that it creates far too many sync points
something ive done is that the event ecs is on a different "ecs world"
and the event systems are also their own "event loop", separated from the simulated loop
Yea to be clear, I'm not at all of the mind "events are bad". I think maybe one common friction point is related to recursion - how it's quite natural with events to have one thing trigger another which triggers another etc. Without events it's something like running systems multiple times. One area of event usage I feel that can get pretty messy.
To chime in on the discussion: How would you guys handle an "event" like an enemy died. There would be some system that decreases health and checks if it dropped below zero. What then. How trigger a die SFX, VFX, die animation (increase kill count) and finally get rid of the entities representing the enemy?
Can the weapon entity just have a component that points back to the player who owns it?
@gleaming plank yeah you could reference the player entity. You just need an Entity field for that
One way I could imagine doing this:
Entities have a DynamicBuffer<ModifyHealth>, where each ModifyHealth element is +(heal) or -(damage).
Have one system process this buffer and apply the overall change to health at once.
If the entities hit or drop below 0, tag them as "Dead" with an empty component.
Then you can just process those entities and trigger all the death animations and cleanup.
@pulsar jay Couple of other options (there are many I guess) - the enemy entity could have an ISystemStateComponentData - the SFX/VFX systems could look for any enemies that still have that tag and then respond. The System that kills the enemy could have a 'PlaySFX' tag that fires based on an enum (born, killed, hit, whatever) that has a reference to a sound (or id into sound db).
The thing that often bothers me with this approach is that you can only have one sound effect (only one component per enemy) and the system that kills the enemies would have to "know" about the other systems (e.g. SFX System)
I think that was more or less the way the guys from unity did it in the fps sample
Good to know. @gleaming plank was thinking more about the "what happens after death"- part here
idk an exact code example off the top of my head, but once you've isolated the entities that are dead, shouldn't it be simple to do stuff with them?
I just tag my entities with a BelowZeroHealth component and let everyone that needs to do processing on them do that. (spawning ragdolls, counting kills etc)
I understand the concern. Part of that is me simplifying. Avoiding inter-system dependency is good imo. A lot depends on how and where you want to author sounds as well. If you have many enemies, it might make sense to have sounds that trigger when e.g. entities exist with specific tags (Enemy tag + Dead tag) for example.
you can attach some kind of "died" component. But then there is this whole "who is responsible for removing it" and "does every system get notified" thing going on
Who is responsible? Generally the system that added it as a rule of thumb? Systems have a frame to query it.
Thats actually a pretty solid idea ๐ค
I don't like to think about systems as event-based. Systems process entities that have (and or don't have) certain components.
You can run systems as soon as the components are ready. Systems that handle entities with some kind of "BelowZeroHealth" component should follow the dependency chain and run after all systems that add it.
"Responsibility" feels like an OOP concept.
I am kind of unsure of why this is happening
wait
nvm
I had a problem but I found it by scrolling down once lol
Some system needs to remove it though? And you have to make sure that the other systems dont trigger multiple times
why would systems trigger multiple times? Unless mixing fixed + update?
nonsense psuedocode:KillSystem() { DestroyAllEntitiesWith(DeadTag); // This happens a frame after the below AddDeadTagToHealthlessEntities(deadedQuery); }
if you add a "BelowZeroHealth" and no system removes it
just said some system has to be "responsible" to remove it
sure, you'd need a system to do that
Well you add a system that runs last to remove it, everything else that needs to process that tag + entity can run earlier
^
With the above example, it doesn't matter where you put that system - just a sensible place for a sync point.
or as psuong says, you can have a system that does the actual deletion of entities as e.g. the last system that runs in a frame (the implication being every system that wants to know about Dead entities is between the system that adds the tag and the end of frame)
I highly prefer the system that had evaluated the condition to do the work in absolute entirety right then
Or to trigger a event (full blown entity if desired) to then cause it to happen
Deferring or splitting the action into multiple descrete steps when not needed is how I usually run into unneeded complexity.
Kinda like procrastinating in the logic
Multiple discrete steps does feel like the ECS way though
Don't overdo is all I'm saying
Do more per each system
When I was starting out I had a tendency to really really fracture things out
Oh I see
I'm not talking about absolute ways of working with ecs, your gonna have to learn where you can move the balance
That comes from actually hands on learning how to solve these questions you have
Not just being handled the best solution (there's always assumptions about the problem domain)
The Overwatch GDC talk has a good examples on when deferring or dividing work into multiple systems is useful to reduce complexity.
And I can confirm they do as well. But make sure the problem of actually that complex
intersesting. Do you have a link?
Their ecs works slightly different then uecs
thx
What's a good way to store or get a reference to a specific child entity after conversion?
or is the most efficient way to store during conversion
important detail on overwatch ECS. Their system doesnt work well with many systems and many components, so they just have relatively "big" systems and components
you can see they basically have 1-2 systems for all rendering
they use ecs more for the architectural pattern than for perf or similar
yeah, I was wondering if that was actually all of their systems or just a subset to show the example. Because he talks about having the RESOLVE_CONTACT component but I don't remember seeing it on the chart
things like this makes me think there running at a big higher level of abstraction, not breaking it down as much as UECS
I mean, you can totally have character controller components just fine, but I hope you understand what I mean when I say thats more of a oop thing
is it worth it to use dots in my project with no prior knowledge of dots?
It's not something you can easily integrate without experience. Go through examples, read the docs, then decide
Well, ECS is not easy to integrate. Jobs on the other hand, you should be able to get performance boosts from bursted jobs in performance critical areas without too much trouble.
How would I move an object in the direction it is facing?
I'm making a 2d bullet hell demo and I want all bullets to move in the direction they are facing according to their velocity
I can't figure out the quaternions in mathematics, so I have no clue what to do in my system
You can get their direction from localToWorld.Forward
What component holds that?
LocalToWorld
Thanks
So all of the projectiles are disappearing too soon (they stop rendering before they are fully offscreen)
how do I fix this?
Example screenshot
the purple things are shot in a perfect circle
but there are noticable gaps at the edges
wait
I think I know whats going on
Nope
OK I don't know what's going on now
I have no logic that deletes them and they show up in scene view
Plenty of things it could be. Are you spawning them based off deltatime? If so it's unstable so you could see gaps like that in that case
The gaps don't form naturally, they suddenly appear when the things start dissappearing
When you say they show up in the scene view, you mean there are no gaps in the scene view?
How are you rendering? Hybrid renderer?
Yes
These are my components
bulletcomponent stores an unused enum and a velocity
They are also scaled to 0.5
Did you update renderbounds to match the scale change?
The expected workflow for this would be to make your bullets a prefab. Like a gameobject prefab. Then you can use the conversion system to convert it into an entity prefab, and you can instantiate that instead of using an archetype you build in code. I only mention that because it takes care of things like that - if you set the scale of the gameobject the conversion system will generally set up all the relevant data for you so you don't need to do it manually
So when it spawns copies, it spawns them as entities directly and not as objects which it then converts?
Otherwise you need to call SetComponent<RenderBounds> and set the proper size
It spawns them directly as entities, yeah
The converison system just creates a canonical prefab you can spawn from
It is awesome, unfortunately annoying to set up right now
wouldn't I just need to put the GenerateAuthoringComponent attribute on my components?
Or are there other steps
oh right I don't actually know how to convert it
Yeah, you would set up your authoring scripts on your bullet like you would with a normal entity, then change that gameobject with the scripts on it into a prefab. You then use a second entity to reference your converted entity, then query for that second entity any time you want to spawn the prefab
Like I said, annoying right now
Basically you want to do what they're doing here
A smoother process is in the works supposedly, but as far as I know this is how we're meant to handle prefabs right now
Hmm alright
I'm using this for a bullet hell type of game, but I'm planning on only using ECS for the bullets since it seems like more work than it's worth atm for anything else as the performance won't be noticable
If you don't want to bother with all that you could just set up the prefab yourself in code, than call Instantiate on that
By set it up yourself do you mean like manually add all the components like I was doing?
Yeah, but as mentioned make sure to set the renderbounds manually - and I still don't even know if that's for sure the problem, hahah
yeah it's scaled down so idk why it would dissappear before it goes off screen
Oh also is there better way to do rendering with sprites? Or is it just quads
Are you sure they're not leaving the game camera's frustum?
When you have the camera selected in the hierarchy the frustum is the shape it shows where everything gets rendered
You should verify in the 3d scene view that all your sprites are still inside that shape when they disappear
Unity crashed when I tried that lmao
Nope, there's no proper 2d in ecs yet, except in Project Tiny
If it continues to break on you I would honestly say just use regular sprites. I doubt you'll see much difference in performance since most of the "work" should be happening in your movement system
Just the rendering part. If you convert a sprite I believe it will create a hybrid component so the sprite is "attached" to the entity and moves with it. You can still write to entity components but the rendering is done via sprite renderers - which are still very efficient
I guess?
I'm not sure about the stats lmao
Would it add any extra work to instantiating them?
I used object pooling in my last game and it caused a bunch of issues
I guess in your case it would since you're not actually using prefabs...
also these are the ones that are dissappearing ingame
seems like the renderer picks a point in the middle of the quad
for some reason
Yeah it looks like me like the render shape is incorrect then
Alrighty well I'll do more work on this tomorrow
RenderBounds I mean
but thanks for your help
how would I do that with an AABB?
EntityManager.SetComponentData(e, new RenderBounds
{
Value = new AABB {
Center = whatever,
Extents = whaever
}
});
I mean like what do I put for the center
I might just use sprites
I made the bullets reflect off the edges and wow ECS is pretty fast
Center and extents are both generally half the size, in world units
I'm in case when i have converter (IConvertGameObjectToEntity mono) that creates additional entities which are linked to converted entity.
I want to make this entity as prefab. To do this i use ConversionSystem.GetPrimaryEntity() which is super easy. So converted entity has Prefab component which exclude this entity from any query.
But even with prefab conversion created additional entities has no Prefab component which is expectedly.
Can i somehow get primary entity hierarchy? Of course i can create additional entity only when entity actualy exists (not prefab). But maybe there is some useful tools
Hi! Is there any conensus on how to do an inventory system where items can have complex functionality (regular uses, weapons, consumables, throwable grenades, etc.) in DOTS?
a quick ctrl + f in this sub for dots shows no mentions for "invento" so I don't think it has been discussed here
So for a typical inventory system where you have a base item class, something like a weapon or potion class that inherits from that, and then a script for each item, how would you approach this in ECS?
After reading on DOTS personally, I think there is simply no way to do this other than making everything that would have been a field in OOP (such as healthRecoverAmount) a component
So instead of Bandaid : MedicalItems : BaseItem, you have like Item with that component
Instead of Shotgun : Weapon : BaseItem, you got something with a ton of components, etc.
You can try to treat an inventory like a database
You're storing records of information, so a player can have a collection of Item IDs
and each item ID can be mapped to a specific table
or each item can refer to multiple tables
I do an approach like that with cards - which you can treat as my inventory.
So unlike OOP you can compose different records from tables instead of inheritance
So, if I understand, a player does not store an entity, it stores ids for whichever entity might exist?
Well you can store an Entity if you choose to - depends on implementation and your design
I just chose not to store an entity and just used an ID for my needs
I'm really new to this DOTS approach so sorry if I'm being slow, but you're suggesting for each Item, you compose it out of many different things, instead of inheriting them from a parent right?
The issue with simply using ids that refer to templates is that you might want to change some values, such as having a weapon that can get damaged/worn out
Yet, if I'm understanding DOTS correctly, there is no weapon. There is simply an entity that contains an item component, a worn component, a damage component, etc.
Well that's why I said it depends largely on your design, since my example was for my own needs.
Let's call your feature "Maintenance" and we have a Weapon Entity. Your weapon Entity can be associated with a Maintenance component that stores a float. For simplicity, let's say you store entities in your inventory. Because you store entities in your inventory, you can access the "Maintenance" struct and update the float value.
Your float values can be:
- 100 - fully maintained
- 50 - worn out
- 0 - destroyed
Depending on the float value you assign to the Maintenance struct can tell you the state of your weapon effectively
I'm not really sure what you mean by templates here.
What I thought you meant was that you had a database of immutable things like cards and your inventory merely stores IDs that refer to those things you can use
Ah - yea you dont have to design it to be immutable
But what you said lines up with what I took from reading about DOTS, I won't have Shotgun : Weapon : BaseItem, I won't have Bandage : MedicalItem : BaseItem, I merely have an entity, and that entity has components in it.
Yep
I shouldn't care or even know high level concepts about whether something is a weapon or not. Something in DOTS is, what it's made out of
Is that it?
Like if an entity is a weapon?
Yes, what I take from this is that in DOTS entities aren't really concepts like Boat, entities exist, and are composed of things like "ItemMaterial" and "Buoyancy". Whether that is a Boat or not doesn't really make sense like in OOP
Or maybe I just don't get it, which is more likely
Yea that's correct
Yeah I just had to ask that question to make sure I wasn't misunderstanding your statement
but yes - you're right about that. The idea is - the composition of data describes the entity, the entity itself doesn't describe what it is on a higher level (since by default entities is just another form of an ID)
How would I check if a dynamic buffer contains something?
Thanks for the input here. I don't think I'll try DOTS just yet, I'll design my objects with DOTS in mind, and not use inheritance, and migrate to that system later, because this seems like it will come with quirks later on.
I believe NativeArray<T> has an extension method called Contains (I'll need to double check that later - if that's the case you can do DynamicBuffer.AsNativeArray().Contains(some_var));
Otherwise loop through and find the value would be the most basic way
yeah np
NativeArray does not have a Contains method
Loop through and check, it's going to be O(n) which isn't that bad
@odd cipher your struct must implement IEquatable
if you want to use the Contains extension method
Doesn't seem to work even with IEquatable.
unless that Contains method is in some other class
should just be in Unity.Collections
but that static class is NativeArrayExtensions
yeah you will have to include collections
nativearray is in the base unity namespace now, but not the extensions
I see, getting this confusing mesage though.
looks like you got good feedback on items, but one thing I can tell your doing is still thinking in one object, inheritance mode. most people start from a oop background and that's totally fine, but one thing you might ponder is that there is no reason the item entity needs to also include the durability entity, maybe multiple entities is what you would want @shrewd lion
Oh btw, one last thing, are you familiar with the performance of entities with many components? So if I want a complex item, of course in a DOTS game that conceptually doesnt exist, just an entity with many components. However, what is the performance of having an entity with say, 100s of components on it?
the performance isn't a issue with that, but there are several things to be aware of
also 100s of components on a single entity would be concerning from a design pov
I think in DOTS you would simply have one entity, and freely add the components you'd like, if your item is an entity without durability, I would simply not add that component right?
Complexity (in terms of developing and debugging) of understanding comes to mind as an obvious problem
yes, but weapon/item durbility doesn't strictly have to be associated with the item description? the item icon in inventory?
theres a lot unrelated data that would all be grouped together in a traditional item class
For an item in a game, I'd probably split it into the logical representation of an item (what you have in your inventory; just an id) and the actual data (in a data store).
if you think of entities, ID's as pointers to data, and can freely update and store them within components, you can create any sort of structure, tree or otherwise within your entities
yeah, in my old mb based games I ran with a ItemData which was a key'd scriptable object, and simply had a item in oop land with the id for lookup
Durability is one attribute that you might want on a logical representation, but you you don't need all, say, swords to hold their max durability
I would also like to comment on entity with 100 components:
It should be a GIANT red flag if far before you get close to that amount
durability = 100% omit it, durability = 0 remove it add broken
thats the more common data processing idea ecs can teach you
For example, yeah
allows for cpu savings, but thats not what we were trying to get at
same goes for health, healing over time etc
highly recomend the DOD book by richard
think its pinned in here
oh maybe not
Yeah, there's no way I'm getting into DOTS for now
Data-Oriented Design
Though for simplicity you might want to keep the durability even at max, to represent that the entity can lose durability.
So no Durability = indestructable, with Durability = has durability, not broken, with Broken = has durability, is broken
^DOD is useful to know even if you're not doing DOTS
Expand your mind, broaden your horizons.
Also that kind of thinking is used in many projects even in languages that are traditionally OOP.
Same with functional programming, really; by understanding the concepts and "why" and "what" lets you use the knowledge in other contexts
For an item in a game, I'd probably split it into the logical representation of an item (what you have in your inventory; just an id) and the actual data (in a data store).
@tawdry tree
Isn't this what storing your items in your inventory as entity references effectively does?
Oh I see your point, you want to have a base representation to build instances from for relevant per instance data
You know, I actually gave that a look
Basically, you're building a game, but the logic will operate like that of a relational database
avoid null checks and stuff
yep, dont have to check for null if you only work on a live set of data always
you do have to check refs to other entities, but thats much faster due to the entity manager
Btw, I have to wonder, do you get any benefits from using ECS even if you're not using DOD? I want to ease into it, and I thought about first simply moving to ECS but keeping the underlying rationale as it was, and then doing it with DOD. So would you recommend a first time user to ease into ECS like this? Keep in mind I have very little experience with relational databases
can I ask what your motivations for playing with ECS/DOD are?
Sure. I want to potentially have millions of entities in a game. I realize there's no way that's going to happen with GameObjects + Mono, so I must use ECS at least because GameObjects are too heavy
millions of what kinds of entities?
Of items, which can be very simple, or very complex. Even "abilities" in my game are items, which you can click and will do logic and apply effects, and that allows me freedom
I already had to use Jobs because I have some tasks which absolutely require multithreading
thats good
juggling a pc atm, almost done
how was the port to using jobs? if it wasn't too much of a challenge I would say try to make a MVP of your item system, if its the main driver of performance loss in your game design
you dont have to go all in on DOD, and can write it much more oop like, but you are leaving a lot of performance on the table by not simplifying the data to simplify the logic/processing cost
There was no port to using jobs, I designed the critical parts of the game from the start to work with jobs since I knew they would clog up the main thread.
ah yeah true, jobs have been out awhile now
my current game was started before the job system was shipped, sorry forgot not everyone has to port to it
And as for this, thank you! That's what I'm going to do, rewrite using ECS and then gradually move over to DOD
It can't perform worse than GameObjects
I hope
Again, thanks for the input on this, and that link you posted helped a lot as well
glad to help, as are most people in this channel
Hey guys, I have written my own A * Pathfinding algorithm and am in the process of converting it to DOTS, but I am having some issues. I was wondering if there's anyone familiar with both DOTS and A * that might be able to help me out. It actually doesn't crash now, and everything is I think indexed properly, but I maybe am missing a logic error somewhere.
I'd be willing to send it over discord, if anyone is willing to help. It's fairly well commented and all contained to a single script.
I maybe have accidentally used a data type not compatible with Burst Compile somewhere or something, I just want to make sure that the issue is not with DOTS but rather with my loops or parenting of nodes or something.
@vagrant tulip Sure, hit me
DOD and ECS is basically the same
or very similar
ECS the way unity works is kinda like "training wheels" for DOD
should empty entities (no components) automatically get deleted?
trying to use unity netcode to send RPC commands, but it's leaving empty entities behind
(i can't scroll up on the matching chunks; there's no tags associated with it)
I don't think there's any reason they would get automatically deleted - what if you wanted to remove all components and add a different one for example.
hmm
not sure how i could delete these ones it's left behind
guessing i can't use .WithNone<IComponentData>
that probably wouldn't be safe anyway
Ideally you don't let them get empty without a reference to them I'd say. One tactic is to make one of your ICDs/Tags/whatever inherit from ISystemStateComponentData instead of IComponentData - then it won't actually get removed and your cleanup system can require the presence of it
yeah, it's not my code removing the components though
there's also the UniversalQuery to find all entities which you can use WithNone on as well I guess
I haven't messed with netcode at all - that sounds really odd netcode itself would leave this floating around - perhaps someone else here knows more about that
hmm it calls DestroyEntity
so not sure what these are :/
i'll try and reproduce it in something smaller (or see if i've got something else creating them)
np - glad you sorted it
I have 2 inputs in my job struct and an output. The output is set in the Execute function, however it says Job.output has not been assigned or constructed. All containers must be valid when scheduling a job. - Well I have to schedule the job to set the output value, what??
Ah I found a youtube video explaining how to set it to an empty value first
wah
looks like burst 1.5 lets us call burst functions without function pointer boilerplate
https://docs.unity3d.com/Packages/com.unity.burst@1.5/manual/docs/CSharpLanguageSupport_Lang.html#directly-calling-burst-compiled-code
uses il post processing so prob still the same thing under the hood, but nice to be able to just call a burst function directly
hrmmm
is it any better than running bursted ijob.run?
It's a lot worse I'd say. Function pointers are slow by comparison and the syntax is really awkward for a normal function call
I wonder why they wouldn't wrap an ijob instead actually
maybe it's an alternative without doing the setup of jobs?
but there's also a setup for burst functions... sooo...
should be pretty easy to do a test compare
https://hatebin.com/jmqzwpzvyq in this situation the job is 3x slower most of the time.
Wow, I would not have expected that. Good to know
How does it perform if you move the loop inside the burst compiled utility?
Ah wait, just noticed this is comparing job vs burst function.
Though it was burst vs non-burst
This is cool tho! I have lots of code in places that would benefit from burst, but I cant make the whole thing burst due to some non-burstable code
yeah i wouldn't call this test conclusive yet. i moved the loop into burst and the job goes way faster now.
Best most up to date tutorial/guide on DOTS & ECS recommendations welcome.
"up to date" is very relative
Yeah that looks like what I'd expect
Hmm, if you move the for loop into the function call does it win again?
mmm thought i did, maybe i made a mistake
Oh yeah you did
OK Relatively upto date, where I can actually make something without too much of a detective job to piece together the correct info
They have samples on the Unity github page that are decently up to date
In the pinned messages, the github samples
Yep saw the samples were only a month out of date (well some of them ) which is super recent (kinda)
That sounds about right
don't forget all of this is super preview, and can change on a dime
(And has... several times)
I know I last dipped into it a couple of years ago when it was super x10 preview
@flint schooner I used the "recent" videos from Game Academy school youtube channel, very nice to start. I found a couple of interesting videos on the Turbo Makes Games channel as well
Still haven't figured out how to use Contains on a DynamicBuffer. I don't understand this error.
It wants an int as a parameter?
yeah it is an int
Actually, where does that Contains come from? I cant find it in the docs
Unity.Collections
Are you sure? DynamicBuffer is from Entities
It seems to try to use Contains from FixedStringMethods
Yeah I'm sure. I suppose they won't work together. Someone else in here recommended me to use it.
yeah thats the one
But you're using a DynamicBuffer, which doesn't have a Contains so its confused
Did you try AsNativeArray().Contains? Since that was what I put in my example ๐ค
Convert it to a nativarray and use that contains
Oh yeah, tried that too but gives the same error.
Write an extension which iterates over it and checks if the value is there
yea that's the other option
converting it to a nativearray is just a waste
AsNativeArray doesn't do any copying. It's not wasting anything
Ah you're right, I missed that
I'll do a loop instead. Seems to be the easier option here.
using AsNativeArray will probably be less work
public struct Comp : IBufferElementData
{
public int Value;
}
void Find(DynamicBuffer<Comp> buffer)
{
buffer.Reinterpret<int>().AsNativeArray().Contains(10);
}
It's Contains extension method will just do the work for you
a function wrapper on job gets pretty close, if you need to run burst functions outside of systems.
though the calculation is wrong, thats odd
which is basically this generic job https://hatebin.com/oqpnstzprw
Why can't my Job struct not contain any reference types? I need to pass it a Dictionary
I can pass it an int2, but not a Dictionary
because everything in burst needs to be struct/unmanaged
How do I pass it a corresponding list then? a NativeArray?
you can use NativeHashMap or UnsafeNativeHashMap instead of a dictionary
I need to pass it a set of tiles as int2 and a bool showing if it is a walkable tile
Oh sweet! That looks like a Dictionary Thanks @mint iron
It says it has not been assigned or constructed
{
startPosition = start,
endPosition = new int2(i, y),
gridSize = new int2(20,20),
walkableMap = inputMap,
path = path,
finalGCost = finalGCost
};```
walkableMap is the only one it says has not been assigned, just because it is a NativeHashMap type? I am assigning it
Did you allocate it? new NativeHashMap<TKey, TValue>(capacity, allocator)
You could also not burst compile the job
Not familiar with Capacity, maybe it is the Capacity of the list I am using to populate it's KeyValuePairs? Also I did not put an allocator because it is an input value, not something I need as output.
I am going to pass the same map to many jobs, so they can use it to see which tiles are walkable
Then I can dispose of it
I tried creating a new map for every call NativeHashMap<int2, bool> inputMap = new NativeHashMap<int2, bool>(map.Capacity, Allocator.TempJob);
You should still declade allocator. Persistent
Still says its not constructed or assigned
Capacity is the same as in non-dots containers. Max length before it has to resize internally
foreach (GroundPosition p in map)
{
bool occupied = false;
if (p.occupied != null)
occupied = true;
inputMap[new int2((int)p.position.x, (int)p.position.y)] = occupied;
}
NativeList<int2> path = new NativeList<int2>(Allocator.TempJob);
NativeArray<int> finalGCost = new NativeArray<int>(1, Allocator.TempJob);
FindPathJob findPathJob = new FindPathJob
{
startPosition = start,
endPosition = new int2(i, y),
gridSize = new int2(20,20),
walkableMap = inputMap,
path = path,
finalGCost = finalGCost
};
JobHandle jobHandle = findPathJob.Schedule();
jobHandle.Complete();
output.Add(new int2(i, y), ((float)finalGCost[0] / 10));
inputMap.Dispose();
path.Dispose();
finalGCost.Dispose();```
walkableMap is the only variable it says is not constructed
InvalidOperationException: The UNKNOWN_OBJECT_TYPE FindPathJob.test has not been assigned or constructed. All containers must be valid when scheduling a job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.Schedule (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters) (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
Unity.Jobs.IJobExtensions.Schedule[T] (T jobData, Unity.Jobs.JobHandle dependsOn) (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
Pathfinding.Get_SingleTileMoveCost (UnityEngine.Vector2 startPos, UnityEngine.Vector2 endPos) (at Assets/Scripts/Pathing/Pathfinding.cs:28)
Character.Set_Position (UnityEngine.Vector2 newValue, System.Boolean ignoreAP) (at Assets/Scripts/Character.cs:186)
PartyController.AddCharacter (System.String type, System.String name, System.Int32 health, System.Int32 AP, System.Int32 Exp, UnityEngine.Vector2 pos, Item startingEquipment) (at Assets/Scripts/Controllers/PartyController.cs:84)
PartyController.Start () (at Assets/Scripts/Controllers/PartyController.cs:24)
I simplified this by just trying to pass a test variable ``` NativeList<int2> path = new NativeList<int2>(Allocator.TempJob);
NativeArray<int> finalGCost = new NativeArray<int>(1, Allocator.TempJob);
NativeList<int> testInput = new NativeList<int>(Allocator.TempJob);
testInput.Add(1);
FindPathJob findPathJob = new FindPathJob
{
startPosition = start,
endPosition = new int2(i, y),
gridSize = new int2(20, 20),
test = testInput,
path = path,
finalGCost = finalGCost
};
JobHandle jobHandle = findPathJob.Schedule();
jobHandle.Complete();```
It will not take anything other than an int2 as input, yet it takes array and list outputs no problem
{
//Inputs
public int2 endPosition;
public int2 startPosition;
public int2 gridSize;
//Outputs
public NativeList<int2> path;
public NativeArray<int> finalGCost;
//Testing one more input
public NativeList<int> test;```
If I change the type of the input param to just an int2, it works just fine. It just will not accept any input paramaters which are of type NativeX. I don't even know how it knows my Output parameters are being used as output, but it takes those just fine.
FindPathJob findPathJob = new FindPathJob
{
startPosition = start,
endPosition = new int2(i, y),
gridSize = new int2(20,20),
walkableMap = inputMap,
path = path,
finalGCost = finalGCost,
test = ?? <- you're likely missing this based on that error message
};
So the error says: The UNKNOWN_OBJECT_TYPE FindPathJob.test has not been assigned or constructed. I don't see you assigning FindPathJob.test in this job struct ๐ค
The errory says FindPathJob.walkableMap when I was using that name. I updated my code above where I am using a simpler List called Test
Uh oh I might have figured it out, another function was calling the FindPathJob as well and it did not have the new input param. Could that cause it? Normally my code would not compile if I was missing an input param
But since it is a struct and not a function......
well you're doing struct initialization, not a function call
usually if you have a default implementation of a constructor for structs all fields will need to be assigned and you're initializing the struct through the shorthand - so fields can be assigned optionally
Oh I should create an initializer function and use that, IE public FindPathJob()
Sure if you want, or a default constructor for the struct so you can do new FindPathJob(... /* Put params here*/)
Ok, that way I wont make the same mistake, trying to update now to verify
I followed a video to get started on pathfinding with DOTS instead of coroutines and it was shown this way.
Whew that was it! It was complaining about another call! I will use constructors to prevent compiling, thanks!!
Usually you can just click where the error is in the console, so you can bring up the line(s) that have an issue, since there's nothing preventing you or anyone else from using the initialization list of structs/classes
Man this IConvertGameObjectToEntity / MultiList iOS bug is quite the elusive little ๐ฉ ... ๐ฑ https://forum.unity.com/threads/ios-runtime-crash-in-unity-entities-conversion-multilist-of-convertgameobjecttoentitysystem.1026364/#post-6648460
if I need to edit code in a package, what's the easiest workflow to do that?
(i need to change 3 lines in kinematica to support the newer unity.collections library)
move it from your Library/PackageCache -> Packages, edit the files
ok
yea you would get a development package and unity won't revert the packages to its src version
aight
Hello! is there a way to have a trail renderer converted with an entity (imagine a bullet having a trail when fired) or is it not supported yet?
Yes, something like this:
public class PrefabRegistryEntryAuthoring : MonoBehaviour, IConvertGameObjectToEntity {
public void Convert(Entity entity, EntityManager entityManager, GameObjectConversionSystem gameObjectConversionSystem) {
if (TryGetComponent<TrailRenderer>(out var trailRenderer)) {
gameObjectConversionSystem.AddHybridComponent(trailRenderer);
}
}
}
Ohhh thank you!
Is there a way to get an EntityArchetype from an entity and/or a prefrab?
Like extract all the component types? What are you trying to do exactly?
Nvm, I had some trouble creating an entity in a job, and I wanted to use commandBuffer.CreateEntity, which takes an entity archetype, but I found commandBuffer.instantiate which takes an entity directly, so my problem is solved!
Ha, I was gonna say it sounds like you want to clone/instantiate something ๐
how do you schedule a job? i was following the unity docs and they dont seem to work? After creating an IJob and instantiating it, there is no ".Schedule" method that I can call on it...
you're probably in a componentsystem, for .schedule you'd need to be in a job component system
componentsystems are moree geared towards main thread execution
jobcomponentsystems are more geared towards creating jobs
@buoyant ivy
Don't use jobcomponentsystem or componentsystem. Just use SystemBase
It replaces both of them.
oh
@buoyant ivy That's weird, can you show the code?
You should just be able to call .Schedule() on your job struct
i just tried to post it but it didnt post lol
do i need to install a package ?
yea i guess you cant post code here
ill msg you
You can definitely post code. You need to surround it in triple backticks. Or just post a link to pastebin/hatebin
public float a;
public float b;
public NativeArray<Stats> result;
public void Execute () {
result[0] = result[0];
}
}```
void Start () {
Stats stats = new Stats();
NativeArray<Stats> result = new NativeArray<Stats>(1, Allocator.Persistent);
result[0] = stats;
testJob = new TestJobThreaded();
testJob.result = result;
// testJob.Schedule(); // this line doesn't work
}```
oh ok the discord code button doesnt do the triple backticks lol
Do you have using Unity.Jobs; in the file where you're scheduling?
they should put that in the guide
there is no way to access gameobjects or anything inside jobs right ?
so like if you wanted to be able to check for example the distance between some gameobjects, you'd need to actually set the positions in the job via floats from all the gameobjects before scheduling ?
i wonder why its not able to have maybe just read only access or something to gameobject data
well the main thread has read/write access to it
so you now have concurrency problem
main thread writes.
job thread reads.
but in the middle of a read, the data changed.
Job thread be like : "yo wtf"
so it's better to give a copy of the data to the job thread to avoid this problem
oh i see you mean like litterally in the middle of the reading
yup
oh ok
is there any case when jobs would not be worth it due to the overhead of setting and updating values before and after the job ?
multithreading is great when you need to compute multiple stuff. in large batches.
Although right now, there's .Run which runs a job on the main thread and bursted if you so desire
what is bursted, i thought that was just the multithreading jobs thing
using the Burst Compiler to speed up the job
oh I see so it runs faster than it would in normal monobehaviors ?
like if you had the logic outside of a job
Anyone know of a rough timeline when DOTS will be fully released? Can't seem to find anything about it on the Unity road maps (which worries me)
Can I get a sanity check on this idea ๐
Currently I have a PrefabRegistryAuthoring ( IConvertGameObjectToEntity, IDeclareReferencedPrefabs) which basically holds a list of prefabs to be converted. In the Convert method I convert all the prefabs and then store mapping from PrefabIdentifier -> Entity in a NativeHashMap inside a small System. This conversion happens at runtime on a GameObject with Convert To Entity.
My Spawner system looks up a Entity by said PrefabIdentifier and instantiates it via EntityCommandBuffer.Instantiate(...).
All this works without problems.
Now, I'm thinking of putting the conversion into a SubScene, because that should be more efficient to load, instead of doing the runtime conversion every time I'm opening my game scene.
So I'm thinking of storing a NativeHashMap in a BlobAsset (someone wrote a BlobHashMap already, yay) where I'd store the same PrefabIdentifier -> Entity mapping. Since I want this in a SubScene, this conversion happens in the editor. So my question is would I store this NativeHashmap-BlobAssetReference mapping as a PrefabRegistryMapping component on entity and just fetch it for lookup with GetSingletonEntity?
Does that make sense?
I'm wondering if this approach is solid, aka will the Entity references be usable at runtime.
@lilac harness current year + 1
So... not even close?
wasnt machiene learning package was like 0.15 and bumped to 1.00 ?
DOTS packages are hidden by default in the package manager because they're still so experimental. they're nowhere near 1.0
Shameless plug to the forum version of this question, if anyone is interested in it: https://forum.unity.com/threads/baked-prefab-registry-editor-conversionsystem.1026994/
can i make a struct scriptable object? or something that can be used in jobs?
I don't think so.
but...
you can turn it into a blob
which can be used in jobs
it's code
ok
iirc I think that was the old way of defining a GameObject to be associated with an entity, pre conversion days
believed it would execute in the editor so that it can write the entity into a world, and you'd get an entity you can now process
mhm mhm.
I found it when I was playing around the samples for the latest 2D animation. There's an option now to make use of burst.
and then I saw that there's a Sprite Skin Entity : GameObjectEntity and it seems to be talking to ECS world or something. Not sure what it does with all the preprocessor directive
I hope there aren't new samples being put out with year-old ecs stuff
hmm has the 2D stuff been updated? @deft stump
It's been a long time since I looked at that and I'd probably want to revisit it
they wrote a blog about it.
I haven't investigated the rest of packages yet
We recently shared our roadmap plans for 2021. Now we invite you inside Unity to meet some of the teams working towards these goals. In this third post of the series, we introduce you to the 2D team. Our Unity 2021 roadmap explains some of our focus areas for next year. Weโre committed to updating [โฆ]
Oh I guess I missed the updates for 2D entities lol
isn't 2D entities for Tiny?
Yea essentially
yep
So... I have a weapon entity with components like { Weapon, AttackDamage, AttackSpeed... } and a player which owns an inventory that references that weapon. When my player gets marked as "Attack{ List<Entity> entities }", i actually wanna have the weapon itself fire the damage event, not the player. But heres the problem, the weapon does not know if the player is marked with "Attack", because its an seperate entity... any clue how to solve this issue ? :/ Or any other tipps regarding my combat strategy, ways i could bypass this ?
Damn... i have no clue whats the best solution for this... this drives me crazy. I actually just wonder if this is the right way at all, having a weapon entity that contains stuff like the damage event, attack speed and a player entity that is using it.
its been a while since i was immersed int his but i gravitated towards entities with lots of components for that reason. And as soon as you start keeping references between children back to their parent to check if state exists you're going into random access land. But that solution is to have the weapon know what the player entity is, and then lookup the component with the entity.
@mint iron Thanks ! So we should basically reference the weapon to its player like... {Equiped( byEntity ) }, then iterate over Entities.ForEach(Weapon, Equiped ) => {} for checking if the referenced player entity is marked with that combat component ? ^^
Well it looks like this would work, the only downside i see so far is that it would check for that component every frame... due to the loss of marking
i was thinking that if you're in a foreach for your weapon already, you could Get/HasComponent<Attack>(ParentEntity); parent entity the weapon could get access to by in Entity SomeRelationshipComponent parentRefs.
Ah ok, we mean the same ^^ I also thought about some sort of event system, but im not sure if this would work better or properly at all... Or some system that copies components to "childs" of an entity like events...
another option could be to have some sort of lookup you can pass in that contains the targeting data like a hashmap indexed by weapon entity id. another option could be to have the player set the attack component on the weapon instead of player, so the weapon only fires if the component exists.
I don't suppose anyone knows how to use this dynamicbuffer with ReadOnly csharp var tempbuff = GetBuffer<ObstacleCollisionVerts>(colliderents[i]);
I need to get the buffer inside the job but have it Readonly so it can be multithreaded
hey anyone using the dots editor get the prefab options(apply changes, revert etc) in the inspector? not sure if they moved that stuff to a rightclick menu only in the hierarchy or if its dots inspector hiding it
var tumpbuff = GetBufferFromEntity<ObstacleCollisionVerts>(true);
var tempbuff = tumpbuff[colliderents[i]];```
that's the solution to above if anyone is interested
true being the part where you tell it to read only
is 2020.2 going to be LTS?
in unity.physics, why does SimplexSolver.Solve no longer require a physics world parameter? how does it know the world?
(changed in 0.4)
thanks
perfect
I think it meets my requirements
assuming this preview dots shit gets LTS support too
nobody external knows - some of DOTS, maybe not entities
Hopefully this isn't too dumb question, I tried getting into ECS last year, but it was a bit of a mess and every resource I looked at was out of date so I put it off. i want to give it another crack, where's the best place to start??
I had a look in the forum but it's so messy and so many pinned things, where's like, some code samples 101. I get the concepts and have watched all the videos.
From back when DOTS used to be named Unity ECS. Ah, unity and constantly renaming things.
Although the one package they should rename they never did. Ever tried googling "Unity Jobs"?
depends on your design? Why do you need a game manager entity?
coz I have a 6 x 3 grid, and instead of scanning the entire the grid, check, and then move.
I figured I would turn it into a hashmap and store it at attach it to some game manager entity
to avoid the scan
yeah doesn't sound like a bad idea tbh
or I could tag each panel with their respective ID's as type
no wait, that's inflexible
okay so burst is complaining
how would I go about retrieving data from a hashmap inside a system?
there's NativeHashMap<T> iirc
about what
NativeHashMap aint blittable
ohhhh right
there's a ParallelWriter (or something similarly named. i don't remember the exact name at the moment) property of the hashmap that you can use
like myNativeHashMap.ParallelWriter
oh wait sorry it's myNativeHashMap.AsParallelWriter()
@deft stump Is GameManager the best name you can come up for it?
GameManager to me always feels like a naming issue.
is ECS more performant mostly because logic is no longer contained on the Entities?
if so...does that mean i could get a performance boost with non-ECS by taking a GameObject as my "Entity", sticking some blank MonoBehaviours all over it as my "Components" that are nothing more than data containers, then having "Systems" act on them by just using Manager Scripts somewhere?
nevermind i just stumbled upon the answer
you can, and its called Hybrid ECS
I don't think that is what Hybrid ECS is though
idk lol thats what this brackey's video just told me (4:09) https://youtu.be/_U9wRgQyy6s?t=269
This changes everything! ECS is here so let's see how it works!
This video is sponsored by Unity.
EDIT: ECS can now be obtained via the package manager.
โ Manifest.json Text: https://bit.ly/2xE4pTA
โ ECS Documentation: https://bit.ly/2J9YvLe
โ More on Pure ECS: https://bit.ly/2H9ResT
โฅ Support Brackeys on Patreon: http://patreon.com/brackeys...
Oh wow. Didn't realize it was literally that and always thought it was just a name for a setup that uses pure ECS in a Monobehaviour environment.
I've only used ECS with Project Tiny ๐
You're not going to get performance using monobehaviours, even with ecs
ECS is fast when it can lay out your data in chunks. It can't do that with class based components
not really lol.
I just name it like that since it's easier to conceptualize
@crimson smelt Don't cross post, especially to unrelated channels.
you won't get it here
then where
ok
how would I go about retrieving data from a hashmap inside a system?
@deft stump
You call World.GetOrCreateSystem().GetHashMap(). And that function would get your container, or some struct that wraps your container. But then you need to manually manage the jobhandles for any job that touches the container
so I should go the ijobchunk route?
Do IJobChunks have any advantage over typical Entities.ForEach loops? Or do I not understand what an IJobChunk is
Ijobchunk is what Entities.ForEach gets converted into after codegen
Writing it out manually is quite a lot more typing but gives you more control and lets you do some things you can't do in a ForEach
not dissing on the result. but the three systems aren't even bursted. (also using ComponentSystem too)
The post date suggests the post is a year old, tho
Reading that thread to the end, the author redid their tests once they learned about JobComponentSystems (now obsolete) and the Burst Compiler options and got a ~40x speedup over the Update() way.
what's the difference between the different counts in the IJobChunk?
Count, BatchEntityCount, and ChunkEntityCount.
I assume Count would be all entities that matches EntityQuery right?
Thought chunk.Count is the number of entities in the chunk.
I dunno lol I'm gonna debug log
so even with ijobchunk
it's still getting complaints that I can't read NHM
what are my other options?
I haven't worked on ECS stuffs in a while, but I remember you can just read NativeHashMap no issue.
did you mark it readonly
yeah
Error message?
and the type is NativeHashMap<T>.ParallelWriter, right?
thing with AsParallelWriter
I can't read
it assumes I want to add to it
I just wanna read my nhm T_T
no wait hold on
I think the error was pointing to somewhere else
It says the error is GridPanelManagerData having non blittable data though.
It doesn't seem like it has anything to do with NativeHashMap.
i thought Unity had fixed incorrect stacktrace links with Burst but i guess not ๐ค
I would seriously kill a dinosaur for some NET STANDARD 2.1 right now.
why 2.1?
go for .NET5
That might be a bit much to ask for, but of course it would be better.
I'd like them to just move to a decent version of mono
Did they ever fix the issue where their version used doubles for floats?
yo 2021 is in beta
and I saw alot of new features for burst
Burst: Added support for calling Burst code directly from C# without using function pointers.
Burst: Added support for creating profiler markers from Burst code.
Burst: Added support for exceptions thrown from Burst to contain a callstack.
Burst: Added support for LLVM 11 to bring the latest and greatest code generation benefits to Burst.
Burst: Apple silicon support.
Burst: Experimental support for some ArmV8.2A intrinsics (dotprod, crypto, RDMA).
Burst: Full support for ARMv7 and ARMv8-A Neon intrinsics (out of experimental).
Burst: Preliminary support for loading additional burst compiled libraries in play mode/standalone - for modding support -.
Burst: Support for new intrinsics.
Modding support...hmm
Scripting: Changed NativeArray limit of 2GiB in size, and now it can contain 2^31 items instead.
I guess no dots blog post this year..
Is there a way to use SystemBase methods like HasComponent or GetComponentDataFromEntity in a static method for use within burst jobs?
You would need to pass in a ComponentDataFromEntity
Gotcha, was just trying to hide some of that logic in a method, thanks
when will NetCode be available for production?
Do we have the office roadmap for dots anywhere
I know Joachim mention a while back that one was being worked on but I never saw it
a question on conversion
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.AddComponentData(entity, new PanelData
{
offset = offset,
type = type
});
Panels.AddToGridPanelMap(index, entity);
}
so i need to store the converted entity into a nhm.
but I'm getting a null error when I try to retrieve the entity
is it right to assume the entity here is from the Conversion World? and not in the destination world?
Yes. I believe conversionSystem.GetPrimaryEntity(gameObject) would refer to the entity in the destination world. I haven't tested it though, not sure it will work in that case
Since the conversion probably isn't applied to the destination entity until after that script runs
welp
didn't work.
one thing I can do is make system that only runs OnCreate on initialize group.
what is panels and is your conversion happening at runtime? i'm guessing you're adding it to panels at conversion time, but if its a subscene or a conversion system that world will get shutdown and not exist at runtime so there's not going to be anything in panels anymore.
wut
my message got deleted. sorry if I broke some rule?
was just saying reimport subscene got me again
word of warning haha
I don't suppose anyone knows how I get all of the types of a dynamicbuffer converted into an nativarray?
I have this csharp EntityQueryDesc queryDescription = new EntityQueryDesc(); queryDescription.All = new[] { ComponentType.ReadOnly<ObstacleCollisionVerts>() }; TerrainObsQuery = GetEntityQuery(queryDescription);
which gets all the dynamicbuffer but when I do this
var tempterrainobs = TerrainObsQuery.ToComponentDataArray<ObstacleCollisionVerts>(Allocator.TempJob);```
it does not work
I just get the error ObstacleCollisionVerts cannot be used as a type parameter etc
@pliant pike Did you solve this?
@robust scaffold nope
Right, okay.
Your main problem is that you're trying to create a "ComponentDataArray" from a type designated as BufferElement.
You cant do that.
If Im reading this correct. ObstacleCollisionVerts extends IBufferElement right? It's a dynamic buffer.
yep
What you need to do is get the component data that the dynamic buffer is attached to.
Then get an array of that component data then request the dynamic buffer of that component.
Will you be doing this inside a ForEach / IJob or in the main update chain?
in a foreach, I need to compare buffers from two different sets of entitys
Right, you probably know to add "in DynamicBuffer<>" in the parameter types
The other comparison will need to be access by entity query yes.
This is in a systembase right?
yeah
Use EntityManager.CreateEntityQuery(typeof(<Whatever component the ObstacleCollisionVerts is attached to>));
You dont need the ComponentType.ReadOnly
You can set read only as.. Wait, give me a sec to check the syntax
well it is readonly so that would make it more efficient
I dont think you need entity query, I believe you can generate a component data array directly
The read only should be assigned in the creation of the component data array and the Entity.WithReadOnly(<ComponentDataArray>)
EntityQueryDesc queryDescription = new EntityQueryDesc();
queryDescription.All = new[] { ComponentType.ReadOnly<ObstacleCollisionVerts>() };
TerrainObsQuery = GetEntityQuery(queryDescription);```
I can get the enitities with that just not the actual buffers
Wait, how are you comparing the entities in you Entity.ForEach lambda code?
Is the opposing entity found within the initial entity? Then you can use GetComponentDataFromEntity<>(true); If not, that'll be a little more rough trying to inject data.
I'm not sure what you mean by the initial entity, but I'm getting them currently using var tumpbuff = GetBufferFromEntity<ObstacleCollisionVerts>(true);
I was wondering if there was a faster way using an entityquery though
Are you using an actual ForEach(var entity in TerrainObsQuery) or Entities.ForEach?
Entities.ForEach((ref CellData cooldata, in DynamicBuffer<FlowfieldVertPointsBuff> flowverts) =>
{```
I'm using that for a different dynamicbuffer
Yep. And you're comparing this entity with every other entity that has ObstacleCollisionVerts?
yep
Hmmm, that doesnt seem efficient.
that's what I thought getbuffer is random memory access surely
What is being compared? Floats == Floats?
Yep
If it's Floats or some other type equals the exact same type, you can instead populate a hashmap with one Entities.ForEach with all ObstacleCollisionVerts then use that as a lookup in the next.
If it's a range, that's a little bit more difficult.
Its kind of a range
Depending on the possible variations in that range, you can repeatedly sample the hashmap for possible values.
If it's an infinite range, then I cant think of any other improvements then without knowing the reason you're comparing these values.
I'm not to familiar with hashmaps to be honest
They're dictionaries. You've used them before?
Some of them are key only, some of them have key, value, others are key, many values.
I've used dictionaries
They're used like arrays with non-continuous indices.
From your variable names, you're attempting to determine if an object collides with another? Is there a reason why you're not using the built in physics engine? Their literal job is to optimize this lookup.
Dont try to reinvent the wheel and build a physics engine from the ground up.
there's is to complicated and I don't think its really finished
I just need to do a simple AABB comparison
Yeaaaaaaa. That's DOTS, the whole thing is not finished.
Hmm then yea. If you have a specific reason, use the entity query to get all entities with ObstacleCollisionVerts.
Does an entity with <FlowfieldVertPointsBuff> compare against all <ObstacleCollisionVerts> or a select few?
against all
If it's all, you can populate a NativeArray/List before the <FlowfieldVertPointsBuff> ForEach
yeah I'm trying to figure that part out
Then use that NativeArray and do an actual foreach(){} loop for all values of the NativeArray inside the Entities.ForEach.
Is the dynamic buffer of ObstacleCollisionVerts of constant singular length across all entities?
yep it should be
Then you can use something like this:
I'm going to have do it manually arent I
Yea
I did attempt that before but got a bit lost in it to be honest
var comparisonArray = new NativeArray<ObstacleCollisionVerts>(<number of entities with ObstacleCollisionVerts * length of each buffer>, Allocator.TempJob);
Entities.WithParallelRestrictionDisabled(comparisonArray).ForEach((in <Some sort of ComponentData containing a unique index>, in DynamicBuffer<ObstacleCollisionVerts> OCV) => {}).ScheduleParallel;```
Then you do the Entities.ForEach((ref CellData cooldata, in DynamicBuffer<FlowfieldVertPointsBuff> flowverts) =>{}).ScheduleParallel(); comparison.
Using Entities.WithReadOnly(comparisonArray).ForEach()
Should be slightly better than doing a random access .GetBufferFromEntity(true);
Yep. You should aim to make everything into a job.
I've been looking at that its similar but using Ijobchunk, I haven't really used IJobchunk before though
Ehhhh, dont use IJobChunk if you dont need the specific custom chunk declaration and joining.
Entities.ForEach is basically IJobChunk. Has some restrictions but it's like the difference between using ShaderGraph vs handwriting HLSL.
oh cool, I'm glad I dont have to use Ijobchunk ๐
ShaderGraph might not be able to get deep down into the GPU engine but it's a hell of a lot easier to read, code, and change than raw HLSL.
The only dinosaur from the old days of DOTS you might need to use is IJobParallel. The Lambda Jobs is not parallel and I dont believe there is any plans to make it such.
If you're doing just number crunching with arrays and not touching the entities side of the DOTS, use IJobParallel. I use it occasionally when I'm modifying one of my 16k textures.
cool, simpler the better for my small brain
thanks a lot for the help @robust scaffold
Yea, the dinosaur struct based IJob code is rough. Although, looking at the Entities patch notes, it might be coming back with a vengeance with burstable systems.
No problem. This was all questions I had back when I started. Trial and error isnt fun.
oh.
So I'm screwing myself over by having my panels in a subscene?
so I switched to SystemBase. What am I supposed to pass in for the parameter of Run() and Schedule() for when I want a job handle from them (to pass to AddJobHandleForProducer)
is this correct? cs Entities.blahblahblah().Schedule(); EndSimulationEcbSystem.AddJobHandleForProducer(this.Dependency);
thanks man. You wouldn't happen to know of any guides/tutorials/direction for doing IK with kinematica would you? Seems that nobody in #๐โanimation responded and I"m not sure ๐ฆ
Are there any good articles on ECS pathfinding?
I've been out of the loop for a while and saw ToComponentDataArray got removed. What is the suggested replacement?
It didn't get removed. You call it via an EntityQuery
Ahh ok, I saw it got removed in 0.11 - Removed expired API EntityQuery.ToComponentDataArray<T>(Allocator, out JobHandle). - is that just a static method from EntityQuery then?
They renamed the async version to ToCompoentDataArrayAsync. That's what that is referring to
ahh ok, got it. Cheers!
So. Lets say I want to do procedural terrain with dots. Any resources to get me started? I want to generate smaller self contained areas rather than endless terrain
I'm not sure if this question would fit in here but it uses ECS stuff so I suppose it is, Each BufferElement in my DynamicBuffer has a ID, which until now has been used to find it's location in the Buffer. However, I want to be able to remove the Element from that list. Though that makes everything else break when trying to find the correct thing in the Buffer. I've tried doing some sort of 'offset' that would increase when a Element is removed from the Buffer, and when a new Element is added the Buffer length + 'offset' is used as the ID. but I haven't gotten that to work.
I hope I described it correctly
Has anyone worked with DOTS and 2D? I'm just wondering how well Unity's ECS systems work with 2D tilemaps.
Well it was definitely worth putting the buffer into a more efficient nativearray it basically halved the time it took
to calculate 1 million entities with getbuffer took 226ms
1 million with nativarray took 118ms
is there not some button I can press to stop unity, I'm stuck in a loop where its drawing 1 million entities now
anyone?
I don't think buffers really work like that are you sure don't want a hashmap or something like that
I don't think that would work either.
when working with buffers I think it's best not to work with a specific element if you are going to change the structure of the buffer
huh? structural changes work fine.
using HashMaps might have been better but you can't have those in Components anyway.
There are no tilemaps in DOTs, you have to make your own. It's pretty straightforward though
You can do it with sprites or meshes
oh. neat ok
can't have a managed ISystemStateComponentData?
I need to dispose some things ๐ฆ
oh no never mind old error
seems to work
@zenith wyvern do sprites convert to entity correctly?
I'm just confused with what rendering implementation I'd be using
They attach to entities as hybrid components. If you use Project Tiny they have actual proper entity representations of sprites
For non-tiny you need to use ECS-friendly rendering data and convert it to your sprites/mesh on the main thread as needed
getting errors trying to do gameobject stuff in a foreach that is using an entitycommandbuffer
had to switch back to ComponentSystem instead of SystemBase so that I could use EntityManager instead of a EntityCommandBuffer
not sure what that's all about
hmm thanks I"ll have to look closely
Anyone else have know something that could help with this? Or some code for it?
So you have some DynamicBuffer<ElementWithID> and you want to remove elements from it based on their ID?
Yes that's what I've been doing, until now, as I need to be able to remove Elements from that Buffer. Which causes all of the other Element IDs to be wrong.
Can you describe more of the surrounding use case for these IDs?
Whatโs Dots?
well I only use the IDs so I can figure out what position they are in the Buffer.
Well, if the ID is based on the buffer length at the time of insertion, removing an arbitrary element will invalidate the IDs of all elements following it, and you could also end up with duplicate IDs. You could maybe just increment the ID of the last element or use a generational index (like DOTS uses for entities).
I'm just wondering why you need this bookkeeping in the first place?
Well, it's kinda hard to explain, it's for a Neural Network and each Neuron in that network needs to know what synapse is connected to it, and that's why I need IDs.
And yes, what you suggested there is what I attempted to do but didn't get it to work.
Are the neurons not entities?
No, they are Buffer Elements as well, just like the synapses.
A different way to do it might be a NativeHashMap but I'm not sure if that would work since it would be unable to be used on a Entity as a Component.
I'm not sure what you meant by "generational index" by the way.
In ECS, each entity needs to be a unique array index. A "generational index" is basically an (uint index, uint generation) tuple. Every time you delete an entity, you increment the generation, which solves the problem of invalidating any stale data of deleted entities when you need to reuse those indices.
Hm I'm not exactly sure how that could be used in this case, since Buffers only use an int to get the Element. What I have tried doing is every time I remove a 'synapse' Element I increment a integer stored on the Entity and then later use that integer when accessing the list, such as doing a = buffer[i - offset] though that barely works. As for example, if i is 0 then it would be -1 if the offset is 1. Which would not work when accessing a Buffer. And I don't really know how to make it any better.
How do I correctly share mutable data between multiple entities?
I thought it was BlobAssetReferences, but I can't create these on the fly.
It's not SharedComponentData either, because that is functionally immutable.
Do I put it on another entity and store an Entity reference in a IComponentData? But then I'd always have to get these components; so much boilerplate.
(this is for a floating origin system, with a moving point of reference - that point needs to be shared between groups of entities whose systems decided they want to use that particular point of reference)
@odd cipher
I meant that assuming these neurons were entities, you could just have DynamicBuffer<Entity>.
Then removing, a neuron would be easy:
- Get the neurons connected to the neuron you want to delete
- Remove this neuron from their buffers by removing the element that matches, no need to track indices
- Delete this neuron
https://docs.unity3d.com/Packages/com.unity.entities@0.16/api/Unity.Entities.Entity.html
That said, whatever you're trying to do with this NN sounds pretty foreign to me. This is first time I've seen a scenario where it's important to remove individual neurons. Usually, you've got a static structure, where the number of layers is fixed, the size of those layers is fixed, and the layers are all fully-connected.
namespace Jovian.ECS.Components.Space
{
public struct Instanced : IComponentData {}
public struct SharedInstance : IComponentData
{
public BlobAssetReference<InstanceData> data;
}
[Serializable]
public struct InstanceData
{
public byte id;
public int tenants;
public double3 origin;
public double3 extents;
}
}
Because this gets read a lot each frame in various physics and motion/transform systems, I'd like a lightweight way to share at least the id, the origin, and the extents - in parallelizable Jobs.
(and the BlobAssetReference seems to be the wrong way to go for this)
@gleaming plank Yes I understand what you mean, However neurons are not Entities and it would be very annoying to change it to be so, and most likely wouldn't work for how I want it to. And yes, typical NNs have fixed amounts of layers but NEAT (NeuroEvolution of Augmenting Typologies) neural networks don't. They are dynamic. Which certainly complicates things.
error CS0246: The type or namespace name 'GameObjectConversionSystem' could not be found (are you missing a using directive or an assembly reference?)
I created an asmdef file and now I can't compile anything. The reference to Unity.Entities is there, it's visible in the solution explorer in .NET, Unity.Entities is recognized, it just doesn't compile and I don't know why.
I've got to admit I have had nothing but trouble trying to get anything ECS working out of the box. I can even download a Unity Tiny project from the demo github, install the exact Unity version, and I still get burst errors trying to generate a DOTS C# Solution
I really don't understand how people are able to work with this
For conversion you need to include Unity.Entities.Hybrid in your asmdef. If you're using tiny it needs to be in a separate asmdef that is not referenced by your root asmdef too.
And yes, technically all ECS stuff is still early preview. Usability is definitely not their top priority right now unfortunately
@zenith wyvern is there a reason why burst doesn't like nativehashmap (unless it's readonly)?
Depends on how you're accessing it I suppose
I mainly use NativeHashMaps with read/write capabilities on a single thread
if it's across multiple threads then its exclusively a NativeHashMap Parallel Reader/Writer w/ Burst
System.InvalidOperationException: Type 'ApplicationIdentifier' is missing / is not derived from any type in build pipeline 'GenerateDotsSolutionBuildPipeline' UsedComponents list.
This is preventing me from generating a DOTS C# Solution. Not a clue what it's for. The project has almost nothing in it but assembly references.
I've never had an issue using a NHM in burst. Just make sure you're using the ParallelWriter if you're trying to write to it in a parallel job, and pass it as ReadOnly for parallel reading
System.InvalidOperationException: Type 'ApplicationIdentifier' is missing / is not derived from any type in build pipeline 'GenerateDotsSolutionBuildPipeline' UsedComponents list.
This is preventing me from generating a DOTS C# Solution. Not a clue what it's for. The project has almost nothing in it but assembly references.
@gusty comet
Not sure what would be causing that. Double check your build configurations and ensure they meet the requirements for project tiny - there are a lot of obscure requirements
I get the same error trying to compile the Tiny Spaceship demo without any custom changes
Do you have the C++ and .net dev packages installed via the visual studio installer? Like I said, obscure requirements
You can't use mutable static data inside burst.
Assign your map to a local variable then pass it into the ForEach
What's the error message
no wait. it's working. I didn't clear console.
How do I share mutable data between entities?
Currently building a NativeArray with the data (not sure how to safely share that across systems...yet) and a SharedComponentData with the index into that array.
It just feels wrong.
I must be missing something here ๐
Only one system/entity writes the data, and that entity is disjunct from the entities using the data.
I don't know if there is a good way that fits in well with how they made their ECS. I guess you could have managed components that have a reference to an instance of your shared data
Yeah... it also needs to be kind of fast.
I will be looking into Managed Component Data for other things.
Hahah....good luck
I wish they hadn't tied SharedComponentData to chunks. Or have a ChunkComponentData for that.
But I guess it makes sense for cache locality.
Yeah shared mutable data is pretty antithetical to the whole chunk design
Thing is, it's only mutated by something else entirely. I would just be fine changing the SharedComponentData ... if I could, haha. It's actually the exact behaviour I would expect.
But no, what it does instead is move entities over one by one, it seems.
If I had control over the hashing of SCD... hmm.
I wish a HashMap version of DynamicBuffers were a thing :p
Apparently there is https://docs.unity3d.com/Packages/com.unity.entities@0.16/manual/ecs_chunk_component.html @warm panther
Is that not what you want pretty much?
Huh.
Not really but actually might be useful for something else.
Well actually.

I don't quite understand chunk archetypes yet, to be honest.
What happens if I have multiple chunks?
(i.e. more than fits in one chunk)
It creates a second chunk and that's how you get parallelism from ECS jobs since they only run parallel across chunks as far as I know
But if I set a chunkcomponentdata for an entity in that chunk... will it change it in its related chunks, or really only THAT one chunk? ๐
But actually I could do it with the Query as described. Which is close to what I actually want to do, hmm.
Yeah I would have thought it would change it for all entities with that data but that's not right. It is a bit confusing
This looks like I can only read it through EntityManager.
Weird. I need a Write-Seldom, Read-Often component. Reading very very often, actually; and updating at most once per tick.
It says you can read and set it inside an IJobChunk
You just can't add it inside a job
That's fine.
