#archived-dots
1 messages · Page 92 of 1
Hello everyone, I am struggling with ECS Physics. How can I detect colliders touching each other? I am using this https://docs.unity3d.com/Packages/com.unity.physics@0.2/manual/collision_queries.html#spatial-queries-and-filtering but I am still confused. How do you detect colliders touching?
I am not sure, I am testing a lot right now, a very easy example would be nice
I am just missing the days, where I just wrote a collision Enter in Monobehaviours, good old days
Easy should be readable, human friendly. I already trying to get this thing running.
This is my simple collision detect job, but it doesnt work
Any ideas?
Error log
ähm, Nani? I am spawning an Entity with physics components on it. There is nothing special
Yeah I already tested this too, thats why I changed it, same result
what do you mean? I have to run it in a job, I just want to get the collisionEvents
BTW I am using latest unity beta and latest entities and physics stuff
2019.03.b9
I know what causes the issue, but I dont know why
please wait a second, I just want to be 100% sure
I compared the unity example again and I need to take this line into the job. After that it runs without errors.
I think it changes something beneath
If you remove it, it makes error
well, the name of the method is only GetComponentDataFromEntity and not change Read-Mode or what ever
ok, I will keep an eye open on those
I have a component being used by a system and inside the system I’d like to edit data on the entity referenced in the component
I’ve done this before but lost the code I was referencing. If I recall there was an efficient way to do this and a really really inefficient way 😀
Basically I have a Wallet component on Entity A which contains currency balance and a PurchaseRequest component on an entity which has a reference to the wallet entity
I want a PurchaseTransaction system which edits the wallets balance and awards the references item in the purchase request
EntityManager.GetComponentForEntitity<Component>(entityId)Or something? Check intellisense auto-completion
Looks great, thanks! I can use this directly in my ForEach?
That reminds me I need to figure out why my intellisense isn’t working 😦
No autocompletion, or no documentation information?
I get the former, but not the latter with packages
It’s not so much knowing what I can do but more about knowing what the best way to do something is
Accessing an entity like that breaks the normal linear accessing of memory that ECS benefits so much from, but keep in mind that while not optimal, it might not be worth optimizing.
How often does it happen, for one?
Also, watch the entity interaction talk if you haven't, it's about similar topic
https://www.youtube.com/watch?v=KuGRkC6wzMY
Interaction is fundamental in games, both in how players interact with a game and receive responses, and in how parts of the game interact with one another. ...
Only when the player chooses to make a purchase. So very rarely, once per few frames maximum
Talk looks great, thanks!
Then it should be absolutely no problem
Also, you might be able to do it in foreach, I just don't know
So I had another idea about how to do this...
Try! The perf impact should be neglectible if it's only initiated by a player. Could add a small comment along the lines of // Look into optimizing if triggered often/automatically
Each time the player makes a request, create an entity with a purchase request component which references the item for sale.
Also attach the wallet component which would be a shared component
And then access the data as part of the system
I'm not sure I understand you here, but if you haven't watched the talk, i advise you to do so - you will probably find some new ideas
Will do, thanks! Was thinking of treating the wallet like a singleton so I can attach it to any entity and read from any system
Thanks guys!
Should RaycastCommand be used with ECS physics?
Could someone enlighten me? Why is this not working?
public class SomeSystemGroup : ComponentSystemGroup
{
}
public class SomeSystem : ComponentSystem
{
protected override void OnUpdate()
{
var commandBuffer = World.GetOrCreateSystem<SomeSystemGroup>().PostUpdateCommands;
var e = commandBuffer.CreateEntity(); // Throws NullReferenceException: The EntityCommandBuffer has not been initialized!
}
}
I can access PostUpdateCommands from within Update from "SomeSystemGroup", that works just fine. But when I try and access it from elsewhere, it throws the exception above.
You should use CreateCommandBuffer() from one of build in EntityCommandBufferSystem or create your own buffer system
Cool, thanks for the pointer, I'll go investigate how to do that 😋
now CreateCommandBuffer is throwing null reference exceptions.
I am using barier = World.Active.GetOrCreateSystem<BeginSimulationEntityCommandBufferSystem>();
in OnCreate() and barier.CreateCommandBuffer().ToConcurrent() in OnUpdate()
Aah ToConcurrent() maybe that's what I'm missing?
Hmm, so CreateCommandBuffer is supposed to be called each frame?
I think my problem is that I'm trying to cache it.
Which to me, sounds like an appropriate thing to do with buffers -_-
In all examples buffers are created each frame, they are just structs.
Yeah, there's probably not any reason to cache it then. Thanks for the help!
I'm trying to achieve the following:
Have an entity spawned, then updated once by all systems between the two command buffers, and destroyed immediately after. All in the same frame.
var beginCommandBuffer = World.GetOrCreateSystem<SomeCommandBufferSystemBegin>().CreateCommandBuffer();
var endCommandBuffer = World.GetOrCreateSystem<SomeCommandBufferSystemEnd>().CreateCommandBuffer();
var e = beginCommandBuffer.CreateEntity();
endCommandBuffer.DestroyEntity(e);
Right now DestroyEntity(e) is causing errors, I'm guessing that creation of entities doesn't happen immediately, and there's no entity do destroy?
Does anyone know if that's possibly to achieve it somehow, or something similar?
You do not use asynd/await, if that's what you thought. You can start a job and just hold on to its jobhandle. The tricky part is making the engine not wait for it to finish the same frame, but I'm not entirely sure how to do that. Default behavior in systems is definitely not it.
I guess your system is in a simulation group. and destroy is called on EndSimulationEntityCommandBufferSystem and create is called on BeginSimulationEntityCommandBufferSystem
so it is executed like this current frame OnUpdate, then EndSimulationSystem, next frame BeginSimulationSystem
Is there a way to only let a job run if something has changed i.e Screen.width/height?
can i make one mathematics.random class instance with one seed and then be done with it for the rest of the game? or should i keep updating it every so often?
When using RaycastCommand, will the order and number of the commands you send to the batch equal the order and number of results in your result set?
Or put another way, will the indices in the arrays match if maxhits == 1
its my current belief that is true, but I'm unsure
@prisma anchor you could create an event entity when the screen has changed and then use that to start the job
Event Entity? Is there any docs on that?
an event entity is something you produce so that a system can pick it up consume it and do some kind of action
hrmm, I'm having trouble accessing EntityManager from a system. Can anyone link an example? I'm finding it tough to find anything online
found it in the options for entity interaction talk 🙂
@rare umbra you get a reference from the JobComponentSystem which get it from ComponentSystemBase as a reference
public EntityManager EntityManager { get; }
Is there a way to use RenderMesh in a job with burst, its not working because Material/Mesh inheritance from Object which is not bitable?
can use 2D arrays or jagged arrays in jobs?
or do you have to do the flattening technique
rip okay
Hi. I'm pretty new to ECS. Applying what I learn through tutorials, I get stuck in missing assembly references. InjectAttribute an GetEntities is not working for me, although I installed the Entities package in latest preview, running project in 2019.3b.
@prime cipher it's possible you're following some old tutorials - [Inject] was depreciated quite a while ago - would recommend checking out the pinned links and starting with some of the examples
@amber flicker Probably, this is what I found looking for Hybrid, as Entities.ForEach is not working with my MonoBehaviour, although I have GameObjectEntity on the GameObject. Maybe I'm on the wrong track here, as Entities.ForEach works for all my pure ECS Components. Thx
Well, the MonoBehaviour is going to be destroyed after conversion
@slow epoch thx, but shouldn't that result in a corresponding component I can query for? And the error is a compile time error.
If the Entities.ForEach is in other place and the Convert method converts correctly the monobehaviour to the intended IComponentData then it should work yes
Can you show us the Compile time error?
Sure: The type 'PlayerMovementComponent' must be a non-nullable value type in order to use it
as parameter 'T0' in the generic type or method 'EntityQueryBuilder.ForEach<T0>(EntityQueryBuilder.F_D<T0>)' (CS0453) [Assembly-CSharp]
Where PlayerMovementComponent is the MonoBehaviour I want to update through my ComponentSystem (which reads the Input from user)
Well then yes, he should recheck the whole idea of ecs again
Just trying to get a hang on Hybrid ECS. From samples it was using GameObjectEntity and can partially work with MonoBehaviours. I'm not convinced, that Hybrid is a good idea, but it is featured though.
The solution was to create a struct and a MonoBehaviour, using ComponentDataProxy<the struct> on the Monobehaviour. With GameObjectEntity, the data is interchanged
I have a question, formalized on this forum post - if anyone knows how to answer it
https://forum.unity.com/threads/controlling-physics-tick-on-unity-ecs-physics.771635/
you can convert monobehaviours straight to entitys though, the node example does just that
I'm not a fan of this conversion setup
it requires a bunch of boilerplate code
you write fields twice, and write a converter
yeah there is too many and they are confusing
I'd love to stick to pure ECS, but how do you currently handle animations then?
Animation api for ecs is comming "soon"
There is no actual date but should come with the networking demo
Which, as well, is comming "soon"
exactly ... not so reliable solution today 🙂
Also is here already the new version of entities with the auto conversion stuff?
It was supposed to be the next week to Copenhagen
Working on getting my monobehaviour to convert and destroy properly - what's the way to handle multiple of the same mb on a single gameobject? I don't mean the entity/dynamic buffer side but rather avoiding the GameObject .. has multiple xxx components and cannot be converted, skipping. error - is there a pre conversion method? A way to remove the component beforehand or something?
Using Subscenes
I don't know if it's what you need but it caches the entities and their components on edit mode
unfortunately I want to support non-subsene workflows
i think you might need to figure a way to reorganize whatever you have on multiple monobehaviours
Maybe using ConvertionSystems but that doesn't guarantee that runs before other systems
possibly, not sure if conversion systems follow the logic of the converttoentity class though
Maybe an editor tool that checks the active gameobject or a set of gameobjects to remove the duplicated components
hmm.. yikes..
so I guess at the moment you can't, for example, add two joints to a physics body?
Nope since an entity cannot have two of the same component
or rather, it will let you but then through a conversion error
(i think)
well.. you could easily solve the entity side by making a dynamic buffer or something.. in my case I don't even need to keep the data on the entity so I could just throw away the component
but thank you for the input - good to know I'm not missing something
well you need to setup the joints manually
A new week has started... waiting for the entities package update..😎
<insert meme image of skeleton at keyboard>
Maybe its linked to the release of 19.3?
Its definitely linked to 19.3. People from unity have mentioned that 2019.3 is required for the next package.
2019.3 being required doesn't automatically mean 2019.3 release version tho 🙂
but it's very likely that 2019.3 is going to get released this month
w00t
last two years .3 have been on december I doubt Unity wanted it to take that long for either 2018.3 or 2017.3
and 2019.3 is pretty good shape and doesn't have as huge late minute changes on the core engine side as 2018.3 had for example
main thing I could see stalling 2019.3 right now are some packages that are supposed to be released along with 2019.3
The release schedule has basically been consistent since they migrated to the Year version model
like, HDRP and UPR for example
1 major version and 4 minor versions per year, approximately every 3 months
sure, but the initial target for 2019.3 was end of October even
I guess you could argue its kinda 3 minor versions
I just want to see the 2020 ball rolling, lots of really awesome features in 2020
SerializeReference FTW
I really want HDRP's better DX12, DXR and virtual texturing
these are coming during 2020 cycle
and we'll probably get better dots hybrid rendering by then too :p
I wont be upgrading to a ray tracing card until the next generation comes out atleast
yeah, it's pretty good idea to wait at this point
which would probably be in 2020 anyways I suppose
just want that dots animation package 😦
I'm sitting around waiting for the new shooter project they showed at Unite. Maybe with .3?
which new shooter project?
well i guess too bad as it seems like conversion is here to stay for a long time
?
dots shooter isnt out
it might come along with the new entities release but maybe after
its based on the fps sample project, not the one you linked but the other that uses hdrp
the one that uses HDRP isn't entities at all though right?
im assuming its just a small slice of doing everything in pure dots
its classical style?
well its a mix
This new one is more DOTS based. I believe it uses the new animation stuff as well?
yeah
I really want to rework my parametric modeler for DOTS, but it seems DOTS isn't ready for that
https://youtu.be/P_-FoJuaYOI this one
Dive deep into the networked future of Unity using DOTS. Hear how we made the DOTS Sample a networked game, and what we learned on the way. Speaker: Tim Joha...
it shows off the subscene workflows with live entity conversion which fpssample doesnt do any of as of yet
I could probably do it all in jobs...
yeah think i was reading a thread this morning on the hybrid renderer not working so great with procedural meshes
really? I wasn't even aware of that
:/
I suppose I shouldn't be surprised, Unity never likes when you do procedural stuff
Anyone have any suggestions on how you would sum a value from a component attached to several entities and save it to another entity with a different component? An example being updating the health of a fleet of ships based on the individual ship health?
@rare mason You can use IJobForEach to process those components in a job and return the resulting sum in a 1 capacity NativeArray, then use that result to set/add a component to that entity using a command buffer.
@deft niche Thanks for the response. Just to make sure I am understanding correctly. You can store the fleets in a command buffer and then update the health of the fleet after processing the health sum of the ships?
Oops.. not like that.. use EntityQuery to query the entities that you want.. so in this example, when you are scheduling the IJobForEach job, you can pass the EntityQuery that queries for health component and individual ships.
Once that job is completed, use another EntityQuery to get the fleet entity and add/set the healthcomponent on that entity using command buffer calls.
maybe a hash map might work good if you have a lot of ships assigned to different fleets
So, the key could be the id of the fleet and the value could be the resulting sum
Thanks @deft niche I may need to read up more on the command buffer. I think that is where I am failing to understand. This was a great help and gives me a more focused direction to do some more reading. Thanks for the help!
@deft niche It took a min but I got it working! Thanks again!
Awesome!!
hey guys, really dumb question - I was asking about how to use EntityManager in a system last night. I'm still not having much luck, I think because it can't be statically referenced
all of the examples I've found seem to be old too so they're not helping
GaaammmlerYesterday at 10:53 PM
@rare umbra you get a reference from the JobComponentSystem which get it from ComponentSystemBase as a reference
public EntityManager EntityManager { get; }
not sure quite where to use this
haven't seen it in any of the examples
weird, compiler was throwing me errors
I'll try it again
if it still doesnt work, what does your code look like?
ok that works!
turns out I was putting it in the Execute function
turns out I need to do more reading about how jobs work 🙂
I was using it in Execute since that's where my entity reference is
yep, I'm totally confused. Hah! So OnUpdate runs once first and then OnExecute runs once for each set of matching entities?
sorry once for each entity that has the matching components?
doh
Execute, not OnExecute
nah, I need to find a component of a certain type that's not a component that's part of the system
ok so full explanation:
I'm creating an entity with the component "transactionrequest" as a "message" when the user purchases something. It contains fields: WalletEntityReference and ItemReference
My system needs to run on the wallet component (to deduct the currency), but it needs to read data from the item (the cost)
finding the item data is what I'm struggling with, since I don't know how to fetch it from OnUpdate without the entity reference, which I can get from the job
yes, entities that contain WalletComponent and ItemComponent respectively
yep, exactly
yup
ok, I'll try that
I've probably missed a fundamental concept somewhere
derp
ok, and does the walletData field have to be [ReadOnly]?
yeah, I deliberately left it out but I'm getting an InvalidOperationException "walletData is not declared [ReadOnly]"
yep 2 secs
normal job will be fine 🙂
I just used the editor "create" option under ECS-> System
so it's just the default
thanks! I really appreciate it
simpler is better!
assuming you have all safety checks and leak detection on, using the NativeDisableParallelForRestriction attribute and you do have a situation where multiple threads attempt to write to the same index, will it give you an error?
are you just overwriting data or will it cause other issues?
@digital scarab that works great! Thanks 🙂
@digital scarab like I said I really appreciate it! adding the functionality now and it's working great! Until that is I have multiple PurchaseRequestComponents. Looks like the data on the wallet is never being updated on the wallet component, just copied locally. Is that correct?
i actually dont know what happens? im trying to make a system that specifically causes one to see the result but it seems like nothing bad is happening?
oh ok, i can live with that (personally :D)
but one last followup if i am always using the entity supplied from IJobForEachWithEntity and setting ComponentDataFromEntity[entity] (with the disable parallelfor restriction attribute) that wont cause a race condition right?
oh if i also need to set the data of another entity not from the same query set in the ForEach
@digital scarab you lost me on the last step there, but I gotta turn in unfortunately
thanks again for the help
great, thanks!
dont suppose it can cause any issues with job scheduling stability? like largeish stalls?
ive been using it liberally, without much thought until just now
thanks @digital scarab 👍 was trying to think of more oddball questions before bed but coming up short
is i job chunk faster than i job foreach with entity?
even after watching a few unity talks, reading the docu, and searching this discord i cant seem to find the purpose of ijobchunk
sorry if i overlooked something obvious
"Skipping chunks with unchanged entities"
yes, and only this strikes me as a possible usage
i know thats wrong but
ohhh
ok im starting to get it thank you
I’m of the opinion that IJobChunk should be the first jobs you make. Then foreach, IJobxxx... all make sense and are much less magical. Too often it seems to be the last type of job people learn/are taught. I wonder if anyone else shares that opinion or if it’s just me?
I'm confused about how IJobChunk pass the chunks that you need?
Oh okay sorry i've seen it
It's in the last part of the link you have pasted
haha wow, that's an extreme analogy. It could be quicker to get up and running which has value - but I think it quickly makes more complicated things feel mystical ¯_(ツ)_/¯
Depending on the person it's better to start in a more "magical" but easier way and once he has a better knowledge jump to more controlled but complicated stuff
It's in a different magnitude, but both (IJobChunk and making an engine) are about low level and high level api
I think if the comparison was the ease of mb Update() and IJobChunk...sure.. but I really don't have the impression you can get that far with ECS & ForEach without having to understand a lot. Like how far can you get before you have to understand why you can't use CDFE as well as IComponentData of the same type. Or why the read/write rules for containers etc are as they are. It could be that you can get a lot further than I presume. My perspective is given I think you're going to learn mostly the same things in the end, I'm of the opinion that it'd be quicker and more straight forward to start with what's needed to understand IJobChunk but I appreciate others opinions on this.
I have created a System which inherits from JobComponentSystem, implementing a Job with IJobForEachEntity. No compiler nor Runtime errors shown. The OnCreate() method gets called, but OnUpdate() is never called, nor is the System in the EntityDebugger. I'm killing myself trying to find the reason, but probably lack some experience. What can be reasons for this behaviour?
A job will only run if it thinks it needs to - usually this is implied from an entity query - if your job schedules on a query then if there are entites it will run, if there aren't, it won't. I don't know but I suspect this could be why. Basically you either want to add either something like an [AlwaysExecute] attribute (I don't remember the exact name) or else make the job run on a query. Others might know if there's an alternate way or other potential issue.
@amber flicker That is what I also thought initially, but entity debugger shows during runtime, that I have an existing entity for the IJobForEach<entity>
@prime cipher maybe just try adding [AlwaysUpdateSystem] above your system and see if it runs
@amber flicker Indeed, it does. Weird
@digital scarab nope, just using '''struct BirdManagerJob : IJobForEachWithEntity<Birds>'''
I have an additional query, to get the count of other entities then <Birds>, but thought declaring the IJobForEachWithEntity would be enough for the system to fire up the job, as the query for the others is only used during job execution and not a dependency for the system
@digital scarab This seems to be the reason, if I remove the query, the system runs w/o AlwaysRun. Weird, intention was to check for a specific count of entities and if not reached, spawn new ones. This means, initially the query will yield an empty result.
@digital scarab @amber flicker THX
(sorry, took a call) - glad you got to the bottom of it 👍
It looks like the Conversion only auto converts MeshRenderer but not yet SkinnedMeshRenderer. Or did someone got the latter one used in a prefab or subscene yet?
Only meshrenderer is supported atm.
And ~70% of cpu calc in my project are in SkinnedMeshRenderer/Animator/NavMeshAgent
with skinned mesh renderers?
Yes
soon™
Hi guys
I have a question:
In unity 2018 I was able to Inject a serverside system into a clientside system to share functionallity between the two like so:
[Inject] CellGridSystem m_CellGridSystem;
now since Injection has gone the way of the dodo is there a recommended way of sharing functionallity between server and clientside systems? (systems residing in different worlds)
Has the dots sample been released yet?
anyone?
so I have two worlds and I'm trying to use a method from a system that runs in WorldA in a system that runs in WorldB
so World.GetExistingSystem() does not do the trick since the system im trying to get is in another world
okay I'll try making the method static thanks
Anyone familiar with the conversion workflow? I need my children to have been converted before the root GO's conversion - how do you specify order? I'm also a bit surprised the children being created first isn't the default.
I think you may have to create your own ConversionSystem to go through the children first and then reconstruct the hierarchy in its entities' format
I'm curious about that as well if you have several Conversionsystems how do you define the order
thinking about it.. my issue may be solved through creating data placeholders for all the initialization and then having a system run after the conversion that does the second step/instantiation - I wonder if more broadly this is the better way to think about it - order dependency in Conversion Systems sounds like a nightmare good to avoid
afaik there were attributes so you can add ConversionSystems in
- GameObjectBeforeConversionGroup
- GameObjectConversion
- GameObjectAfterConversionGroup
I havent tried adding multiple conversions in the same UpdateGroup yet
hmm I see from TransformConversion that there's e.g. [UpdateInGroup(typeof(GameObjectBeforeConversionGroup))]
yep - those were the attributes - sorry I couldnt remember how those system groups were named exactly
huh, using GameObjectAfterConversionGroup was actually much more straight forward than I expected
How do you guys store strings in IComponentData?
Damn it...still no update for entities package yet!! 😐
@amber flicker Just posted a video about ECS that introduces IJobChunk first, like you say. I agree that ECS especially requires a decent understanding of what's really going on, and starting with convenience constructs is actually a harder learning experience, especially long term. https://www.youtube.com/watch?v=3r4aFWqXY_8
@night cargo Short answer is you can't have strings in IComponentData structs. I believe they just added IComponentData classes, which do allow strings and any reference types, but these class components are not stored directly in the chunks and so require relatively expensive lookups. There's also shared components which allow for reference types, but the docs say that may change in the future.
Awesome - looking forward to taking a look at the video - I was getting tempted to make something myself 😅
If anyone spots a mistake in the videos, please let me know.
@old pulsar I see you using World.Active.EntityManager, is there a reason you're not just using the accessor inherited from ComponentSystemBase?
@icy quartz no reason other than I probably copied the basis of that example from old code
Ah okay, was just wondering if there was some bug that I'd missed that ruined perf or something haha
hey all. im getting back into DOTS and am having some trouble. the magenta object in the image has a mesh filter+renderer, a Physics Shape (which i think is pretty much a DOTS-based collider?), and a Convert to Entity script attached. the top screenshot is how it's supposed to look, and the bottom is what happens when i enter play mode. it seems that the mesh filter converts properly but not the material. i've tried removing the collider just in case it was that for some reason and i got the same result. also, before i messed with the mesh in Blender a bit, the entity's rotation was reset (i'm assuming it would have reset the translation and scale too if i used those). i'm using the latest Unity 2019.3 beta (b9) and all of my DOTS packages are up to date (afaik). i'm also using the URP and haven't checked if it works without the pipeline. the material for the magenta object has a shader made in Shader Graph. any ideas as to where i could be going wrong? please mention me so i don't miss it. thank you 🙂
forgot to mention that this is what appears in the entity debugger. an error also appears when i click on the entity in the debugger. here's the first line:
InvalidCastException: Specified cast is not valid.
and the entire error in the console:
https://hastebin.com/lesipuvadi.pl
though from what i can tell, it might have something to do with the debugger
suddenly getting shader errors when entering play mode, even though it compiles fine for editing purposes 🤔
another update on the situation. i tried just changing the master node in the shader from PBR to Unlit and it works. no error magenta. isn't the Hybrid Renderer supposed to support lighting and such?
ah i wasn't aware of that when i started. thank you for confirming my suspicion 🙂
with the entity debugger error make sure your properties package is at least 0.6.4
how do i install properties 0.6.4? it is shown on dependencies but can't find it on package manager
is it built-in?
just to be sure, if it's in your dependencies already you know it's in your project
Open the manifest file (/Packages/manifest.json) and add "com.unity.properties": "0.6.4-preview",
@solar spire i meant 0.6.2 is on dependencies but can't upgrade. @stuck hatch thanks will try
I had the same issue 😉
thanks a lot, no more errors
whats the ETA on dots animations?
soon
@old pulsar best videos I've seen so far - good job👍 - tiny tiny thing (I guess you already know and choose your explanation for brevity) but I think entity (0,0) is reserved for null so the first entity you create will be entity(0,1)
When doing "one time runs" through systems, like events. Do you usually duplicate data needed to run this, or use a combination of components?
My current thing that I have is , ClientData { long clientID}. But I do events like FindServerData() { float time, flong characterID) , - which is only used for triggering a sendSystem, but needs ClientData as well for the clientID. Would you duplicate the clientID for that event? (ClientID is used in other places as well, and is not changing during it's lifetime).
Hey guys!
Anyone knows where can I find an up-to-date code-snippet or documentation or tutorial or anything that explains how you are supposed to use EntityCommandBuffers from jobs? I find a lot of code using the outdated [Inject] stuff and would like to find something simple and up to date.
thanks in advance for the help 🙂
ah I see. so this BeginInitializationEntityCommandBufferSystem is something provided? Because I saw a lot of talk about barriers etc but no example of code for them.
thanks for the help btw
DynamicBuffers vs creating new entities for events that are consumed? What are the arguments for using which?
@digital scarab I see. I will take a look into it to find which one suits my use case best. All I want to do is add a component to an entity from a job 😄
good to know 🙂 thank you!
I want to make a random spawner. Is it possible to have component data containing an array of entities to be randomly created. or some other way of getting the data for the job?
an entity can have a buffer (which can be read by a job) and a buffer element can store an entity
So you randomly pick among some presets? Or random pick components to piece together?
sigh...no update today as well 😐
I feel ya
#archived-dots: entities update waiting room
this is a new subforum: https://forum.unity.com/forums/dots-physics.422/
hmm, is it possible to use the new unity physics in 2018.3?
I've been trying to mod Risk of Rain 2's baking system so that it uses jobs, but there is no OverlapCapsule or OverlapSphere commands like there is in the Physics class and Its caused me some trouble
On that same topic and in reference to the blog they state "You can switch between either solver without having to reauthor all of your content completely."
I can tell you the Gamecraft developers (FreeJam) recently have been making this transition, and the lead on that endeavor mentioned that he was pleasantly surprised by how easy the transition was.
Anyone who got some time for some input on this? Sometimes I'm not sure if the job should be split up or not. I currently have a job that will run when a client is connecting to it (so some net-dots stuff), which checks if it's spot is reserved and then sends RCP to accept or deny (I also have a HashMap that I want to place the connection into).
https://pastebin.com/KCkrLE8F
@amber flicker thanks! was unaware about any null entity, makes sense
@amber flicker & @tawdry tree I want to randomly spawn a list of enemies, and the buffer of entities sounds like the correct approach. Thanks.
What's the current best way to delete entities from within a system? It used to be using a barrier as far as I can remember (it was april since I last poked this)
still the best way? or other ways to do this from a job?
Oooh adding a dead tag is something I'd not thought of, doh!
and I'd need an ECB to add a component in the job?
Yea
Due to the LocalToWorld TransformSystem, shouldnt an entity move into the forward direction automatically, if I change the Rotation.Value and the Translation.Value? Earlier I tend to use Transform.TransformDirection() to accomplish this.
You mean with physics or something? If you set the Translation, it should move to that position (local space) by the next frame but it would only move after that if it had a velocity (rigidbody)
@amber flicker I set Translation and Rotation. What I want to achieve is, that the object moves into the forward direction (in which it is facing with its Rotation) and I assumed due to what I read about the Conversion LocalToWorld, that it should move in World automatically always in forward direction. But it is not. Example
If I rotate by 30deg and add to the current translation (0,0,0) a vector (0,0,1) the object is moving along the z axis only in the world, not considering the rotation.
@prime cipher perhaps it's easiest just to think of it as setting the position and rotation in the Transform component of a normal gameobject. If you set the position and rotation of a gameobject, it would move to 0,0,1 and the object itself would be rotated to 30 deg (which I guess is what you're seeing). If you want to avoid calculating this yourself, you can do the same thing that you'd do with GameObjects and create a hierarchy - set the parent to 30 deg then move the child to 0,0,1 for instance.
@amber flicker What would be the ECS preferred way to calculate a vector that is rotated by a quaternion (which is what TransformDirection was doing). Then I can change the Translation to the rotated vector
@prime cipher just the way you'd do it normally but using Unity.Mathematics instead - quaternion.AxisAngle(axis, angle) * pos or whatever
@prime cipher sorry, my bad - you'll need to use math.mul( quaternion.AxisAngle(axis, angle), pos) - the implicit * won't work
@amber flicker or var forward = math.mul(rotation.Value, inputVector); as the rotation is calculated elsewhere. Thx
Some1 having a good tut or video to get a hang on the new Physics thingy?
@prime cipher I'd recommend checking the official docs and DOTS sample repo first, it has separate physics samples
you can find links to both on the pinned message here
just figured out something about DOTS that was kind of an eye opener.
I've got a parent GameObject with child GameObjects that I convert to Entity, but I convert those children manually within a mono of the parent object (IConvertGameObjectToEntity:Convert...). The whole reason why: I need to build a dynamic buffer of the related child Entitys to use as look-up keys later (i.e. for ComponentDataFromEntity).
The problem came in because I was doing stuff in this order
-For loop
---Entity childEntity = Create child entity
---Setup child entity (add all necessary componentdatas)
---Add bufferelement to buffer, with value = childEntity```It gave me errors about a NativeArray being disposed, and I couldn't understand what was going wrong until I recalled reading about sync points
By creating & setup the child entitys, I was apparently invalidating the buffer accessor
So instead what needed to be done
```-Create a NativeArray of the buffer's bufferelement type, sized to fit the number of child entitys
-For loop
---Entity childEntity = Create child entity
---Setup child entity (add all necessary componentdatas)
---Assign to NativeArray
-Add the buffer to the parent entity
-Use AddRange(NativeArray) to add all of the buffer elements```After that I'd just destroy the child GameObjects
I'm curious why not just add a SharedComponentData that groups these child entities for lookup?
I'm not trying to access all of those child entities of the same archetype necessarily (the children may have different icomponentdatas), I'm trying to access them when they have the same parent. If I do that to split it up on a per-parent basis, I'd end up with a very large amount of chunks
yeah, that sounds like a good case for a ScD to me
ah I see, so you have many parents
i think i had issues where I couldnt do
var buffer = dstManager.AddBuffer<Child>(entity); buffer.Add(childEntity)
but instead I had to do
dstManager.AddBuffer<Child>(entity); var buffer = dstManager.GetBuffer<Child>(entity); buffer.Add(childEntity);
I have a quaternion rotation but I only want to keep the rotation around y (it shouldn't really rotate much in the other directions anyway). Normally I'd just get the Euler angles and get the y part, but the mathematics package doesn't seem to have a conversion from quaternion to euler angles.
Is there any way to check if an entity has a dynamic buffer of a certain type?
@solemn ice there is the RotationEuler(XYZ/variations) & PostRotationEuler(XYZ/variations) components which might be what you're looking for, transform docs have more info
Vector3 rotationEuler = ((Quaternion)rotation.Value).eulerAngles;
is what I've been doing
@slate breach i think you can query with EntityManager.HasComponent or you could use BufferFromEntity and query if(buffer.Exists(targetentity))
You can cast the ecs lowercase Unity.mathematics.quaternion to the uppercase UnityEngine.Quaternion which has the euler angles @solemn ice
I'll see is hascomponent works
is this mainthread or job check?
main thread
It seems to actually work in a job, even in burst. Probably suboptimal as hell, but I don't have to process it on many entities, so...
Haha, yeah I have no idea if that's the best option but it was I apparently came up with a few months ago.
Yeah, there's a thread in the forums that says it doesn't exists since there's no use for it, but I would beg to differ.
you could query for RotationEulerXYZ instead of Rotation
That does seem like it would be better.
It's not something I read/write on a converted transform, it's just something I need to calculate in a system
The cast to Quaternion seems to be the only way to do what I need, short of making my own method. Anyway, I'll use that for now, thanks!
@safe lintel yea that's another solution (getting the buffer), although when you do AddBuffer it already returns the buffer so there shouldn't be a need to do GetBuffer right after that. You probably only have to GetBuffer if you create/destroy an entity (and maybe even add componentdata) while you're trying to assign to that buffer, such as within a loop
it does return the buffer, but i get the nativearray deallocated errors when i try to use it that way, was just highlighting that in case that was what you were encountering(hmm maybe i should bug report that)
I have the same problem, I'm not sure what causes it to get deallocated, some cases it does when I'm working with a buffer and sometimes it doesn't.
Does anyone know if you can substitute UDP for another transport level protocol in the networking package?
i guess its my turn, another day goes by without the fabled entities release 😦
I use CopyTransformFromGameObject on my Hybrid Entity, but it seems system copy position directly to LTW and LTW has no auto sync with Translation. So i have 2 approaches: 1) Sync LTW with Translation 2) Get LTW instead of Translation in every job that need to know entity position
What way is more performant?
If you have an entity with a Parent component, is there a way to find it's absolute position? The translation gives me the position relative to it's parent.
@slate breach As i understand u can use LocalToWorld.Position
That didn't seem to work. But I can try again, I might have been doing something else wrong.
is it pure entity?
In this thread i see the same talk :D
https://forum.unity.com/threads/get-the-absolute-position-of-a-child-entity.745844/#post-4969136
I see the appropriate value in the local to world component in the entity inspector.
But when I log it or breakpoint it or try to actually use it its the wrong value.
can u post ur code?
it could be that the system responsible to update the LocalToWorld position hasn't ran yet on the child entity
That is entirely possible, this is operating on newly created entities. Let me see.
What the best practice to get entity position now? Using LWT.Position because it relative?
Wow that was it @coarse turtle
I used an UpdateAfter the transform group and it worked
@frosty siren I still use LWT.Position if I want to get the world position
relative positioning I use LTP
@frosty siren that thread you posted was my brother asking about the same problem months ago, and it didn't work then for the same reason. I guess I'll go update that post.
do not forget to mention the genius of psuong
What the differences between RequireComponent and RequireComponentTag?
RequireComponentTag is for components with no values
One's that you would never have to read or write from.
Just if you care that it exists on an entity or not.
thx
I would like to know if Tag components put archetypes into different chunks or not.
I just have no idea if there's any actual performance increase to using them or not.
While it defined like IComponentData it will
https://gametorrahod.com/tag-component/ @slate breach 5argon tried an experiment with tagging
its still worth benchmarking it in your own game tho 🙂
Tagging is still being handicapped by not able to be Burst compiled. It will be in the future. (And I will return to benchmark it, let's hope the benchmark project is still here at that time)
Is this still true?
I know that you can use them in ForEach loops now and you used to be unable to.
It works now
Might as well make another system to copy the data to the translation. Its what I did and its pretty easy to copypaste the built in copytransform system and mold it to translation instead of localtoworld @frosty siren
I decided to use LTW to get position
I haven't had a chance to look into DOTS yet, can anyone point me at some good starting resources?
pinned message ^
samples repo is the best starting point imo
is it possible that I can get an Entity that the component is on within a IJobForEach?
discovers IJobForEachWithEntity
whats the difference between IJobParralelFor and IJobParralelForBatch apart from the addition of a startindex in the ForBatch one. I mean, if i have an array of 64000 elements, Is it better to use IJobParralelFor(64000) or 4 of the IJobParralelForBatch(x,16000) where x will be 0,1,2 and 3 respectively. ?
wait, where x will be 0, 16000, 32000 and 48000 respectively?
Checking out the Physics tutorials ... is it really the case, that I need to go into Unsafe compilation to cast a collider? see https://docs.unity3d.com/Packages/com.unity.physics@0.2/manual/collision_queries.html Collider Casts
They'll have ref-based interface structs at some point so you don't have to mess with pointers as much, but when that'll happen is still up in the air
What is happening?
How far should I go to avoid archetype changes?
Having lots of components like this, means that an entity never stays in an archetype for very long, and be moved around in memory frequently as state changes and components are added and removed. But it does make it very easy to work with in ECS, it's almost like Unity is asking us to do this for everything with a one to one relationship.
public struct MoveTowards : IComponentData
{
public float3 targetPosition;
}
But if we instead did this we would avoid making changes to the archetype:
public struct MoveTowards : IComponentData
{
public Entity entityToMove;
public float3 targetPosition;
}
But then it becomes a pain to work with, as you would have to add additional systems if a third party system ever wanted to figure out if a player is currently moving towards a target or not.
I'm curious, what are you guys doing for cases like that and why?
changing archetypes every now and then is fine, what you should avoid for perf reasons is changing the archetype of a large amount of entities per frame
so if you want to add/remove struct MoveTowardsEntity {Entity target} on user input, or AI decision, that's fine
changing archetypes on the amount of thousands a frame is good
tens of thousands or more.... think about it very seriously
also if you change archetypes too much, you are also creating too many archetypes, and might be fragmenting stuff
its a case of "bench it"
Hmm I'ts hard for me to think about where to draw the line, though. Because there are so many systems like that,
Take for instance an "isGrounded" state, it would be really convenient to add that as a ComponentTag also, but if you keep going down that road, you just end up with constant memory copies. It doesn't feel right :p
thats kind of the thing. One thing that can be done is to have less monolythic entities
like a "child" entity that holds movement components
that way instead of shuffling aroudn the "main" entity, you shuffle around the "movement logic" entity
so a nativearray<uint> when allocated memory has 0 as initial value or nulls?
but anyway, one of the experiments i did in my own unity style ECS that i implemented, i was using tag components for culling and it was fine
and i was swapping on the orders of 50.000 a frame
the cost scales depending on your complexity of the entity you are shuffling
it does num-components x 2 amoutn of memcopy
its still just a few memcopy aroudn, so its not really that expensive
btw, is the Burst-ification of EntityManager in the next Entities release?
even with constant entity shuffling around stuff will still be much faster than old system
its mostly that atm people are using the ecs to run 50.000 of something
Hah @digital scarab That's true. But it's more out of curiosity than concern, I'm still just trying to get a grip of ECS.
Thanks for insight guys, lots of stuff to think about.
you just end up with constant memory copies. It doesn't feel right
Can someone explain for me WHY? I'm not really understand what does it mean. I just know that when u add/remove components it changes entity archetype and cause entity data copy to matching chunk. What is "constant memory copies"?
Wait less than 24 hours? 😀
for what?
Am I presuming too much to assume its the entities release? What Topher posted a few hours ago
Ah responding to someone else, knew I shouldn't have gotten my hopes up
hmm it appears that [ExcludeComponent(typeof(CompA))] works but multiple (i.e. [ExcludeComponent(typeof(CompA), typeof(CompB))]) beyond the first argument are ignored.. applied to an IJobForEachWithEntity - anyone else see this?
@amber flicker I've certainly ran into that before sometime ago, and I ended up using IJobChunk at that time 🤔
thanks @coarse turtle .. think I'll have to do the same (was trying hard to hold on to my last non IJobChunk haha!)
that is worrying
I vaguely remember seeing something about this on forums.. who knows.. the fix might land with a new entities package in the next couple of hours 😅
Half joking of course but I think if it's not ready by the end of the day a revised eta is in order? So many fixes and changes that it feels like a lot of people are hanging on for...
Any nice samples out there on UI and DOtS? E.g. building a menu / scrollable list from components?
@rare umbra https://forum.unity.com/threads/source-code-dotsui-open-source-ui-framework-for-dots.715880/ Can take a look at this.
Still no updates 😦 i was really hoping for something to happen today 😦
There’s still time!
Hi all, any advices on how to approach new 2D project - should i go with data oriented or object oriented? I want that my project is modular, so my thought was on object oriented with DI etc. But all the recent fuss about dod made me think and i don't really know if i should start with dod approach (dots). I'll be doing an app that will receive data from database and display it in AR, there will be also some c++ plugins and lots of loading different UIs and scenes (i do not need any physics or some other fancy stuff). Any tutorials/pointers on good dod or ood architecture in unity would be great!
dots is super modular, but there arent any builtin 2d things for sprites so that may outweigh any pros
yea - you'd likely do an interface w/ hybrid spriterenderers
or write your own one off soln
until there's official support - as for UI, @deft niche posted the DotsUI proejct which attempts to convert uGUI to its entities format
I dont think UIElements is coming to runtime till late 2020
which I've no idea if it'll support dots immediately
as for tutorials/pointers on good dods - i'd look at the Unite videos on youtube and the pinned messages/samples on this channel
i think uielements should be coming soonish
well soon like that entities release 😆 😩
well with dots i'm afraid that i will hit a wall and i'll be stuck. Maybe its just that i'm used to oop, dunno. So you guys are already transitioning your architectures to data-oriented design or sticking with object-oriented?
I have a 2D game im working on using dots architecture
the transition wasnt bad for me
as a lot of the old monobehaviours just became separated systems
and ordered that worked the same way as previous for me
Do you have some core logic which is accessible through more systems, for example logging? Currently what have i done is to have a Core scene and then load additive scenes. Core scene binded interfaces that all other scenes will use (logger, user management, etc.) which was then injected into other scenes (these scenes have their own bindings etc. which are also unbinding after scene is destroyed). Now in dots that DI is thrown out of the window if i'm not mistaken and i cannot fully wrap my mind around it on how to do this in dots.
I do have a core scene with gameobjects that get converted to its entities format - since the entities live in the same world - it's easy to access the entities from various systems
and I load additive scenes when levels change - which also get converted to entities
thanks for the link @vagrant surge, will take a look. Any other tips you can give me? I'll greatly appreciate it.
just that, really
@coarse turtle, thank you also 🙂
its not specifically ECS, but its the same mindset and has a big overlap
yeah, i'm guessing that i really lack that knowledge.
Maybe the real question is, is it too soon to shift to ecs in unity? Or should i wait till it gets fully released, dunno if people are using this in production yet
Picture this: Toward the end of the development cycle, your game crawls, but you don’t see any obvious hotspots in the profiler. The culprit? Random memory access patterns and constant cache misses.
thats the first blog I read which introduced me to dod years ago
i'm just reading this now 😄
@floral ravine any day now the new update pops
and that one makes ECS les horrid to use, with a bunch of syntax sugar
at that point, it will start to be viable for some "parts" of games
you would still have your main game on monobehaviors, but some stuff you can migrate to ECS, like say, projectiles
Its not any day..its gonna be Today!!! hopeful * fingers crossed *
Get ready to shout at Topher, eh?
Or hopefully not need to.
doesn't look like it
get the pitchforks ready!
⚔

the truth is the package was released 2 weeks ago and they didnt tell anyone
gotta go on a treasure hunt for it
gonna give up on today it seems... its close to the end of the day already now 😐
It's probably sometime next week.
Topher lied to us! 😦
and I said I would post an update to my entity utility package... last week.
It will probably be next week at this rate.
Life (and work stuff that took higher priority and needed to be kicked out faster) happens
Damn...what's the utility package ?
https://github.com/periodyctom/Hydrogen.Entities/
I have the beginnings of the Samples I promised in the unstable develop branch. Wrapping up one tonight and starting on the others this weekend where I have time.
Oooh... this is pretty cool
Sriptableobject Conversion
Thanks for the link...gonna keep my eye out for updates. It looks promising
thanks
I also have a minor math library (mostly bit utilities at this point): https://github.com/periodyctom/Hydrogen.Maths
I add to it when I need math functions that aren't already in Unity.Mathematics and such
Hello, how do you use Arrays in Components? I am trying to create a gridCell, but Unity is complaining with "which is neither primitive nor blittable."
I also tried making BuildGridCellData inherit from IComponentData
either make it a BufferElementData as a separate component
or create a blob
if you are not mutating it
do you have an example?
for buffer or blob?
i think in your case, you could have BuildGridCellData as IBufferElemntData
and keep row and column count in component
What about "InternalBufferCapacity"
i think you can omit that
if you are not sure at all about the size
it behaves like a list
ok, I try
@plain cloak Thank you now it works 🙂
so, if i allocate.persistant the nativearray i pass on to a job, and just keep using that in my other code, without CopyTo some other managed type Array, and i make sure nothing is happening to this nativearray simulataneously when this job is being, I can get away with using the same native array, or should i still copy the nativearray to a managed array and dispose of the native array?
for me, copying the nativearray to a managed array takes about 2500 ticks, while not copying and just using that nativearray takes about 2300 ticks. and this is across 740 instances. So im not really bothered about these 200 ticks i would save. But just wondering
why do you copy to managed array in the first place?
Hello, do you also get this error very often? "Recursive type definition detected" I am working with unity beta and after this error comes up, I have to restart unity
@plain cloak i dont have to, i can just keep using the nativearray with persistant allocation. But in all the examples i saw, i saw ppl copied the nativearrays to plain arrays and dispose() the nativearrays
also i keep getting the JobAlloc temp array is older than almost 4 frame, this is most likely a memory leak warning message in unity lol
if you intend to keep using it for long term, you should use persistent allocation.
I dont think there is anything wrong with using native arrays as is
outside of jobs
"In IL2CPP performance of builtin array and NativeArray is on par, in mono in a build, NativeArray is slower than builtin array" quote from Joachim
hmmm. so if my app will be IL2CPPi can keep using nativearray. but if they are going to be regular unity crossplatform apps then builtin array is the way to go
i dont know if it is worth to copy you should benchmark it imo
it might still be better to use native arrays
i personally do use native arrays instead of copying
i did benchmark it. using just native arrays, i save about 200 ticks
200 ticks, per 740 instances, mind you... so that much hehe
fine, i will go with nativearrays then, no need copying them over and over, thnx for the discussion magni 🙂
no problem man, here is the forum post about the topic if you wanna read about it https://forum.unity.com/threads/native-arrays-approximately-an-order-of-magnitude-slower-than-arrays.535019/
Is there a way to alter the ECS data from a monobehaviour? Specifically for Unity.Physics (with a convert to entity script)
Any script(including MBs)) can access entities via World.Current.EntityManager (Not 100% if that's the exact call, but the general idea stands). You are somewhat limited in how you can do things, compared to an ECS system, but should be able to do most things, one way or another.
Hey and happy Saturday. So I have a question about setting up NativeArray and Jobs. Is there a way I can delay the job from starting until the native array is created? Or just set the component data when I create the array?
@white agate There are the components PhysicsShape and PhysicsBody is there something more you want from there?
Yes, I'm not sure how to access its fields from a MonoBehaviour, is that at all possible? I'm considering refactoring the game to full ECS to get the most out of Unity.Physics. (We were using PhysX for our multiplayer, relatively competitive, physics game; which started showing its ugly indeterminism in our prototype).
Another thing I've considered is using Bullet, but I figure we might as well make the jump to ECS because the plan is multi year support for the game
I haven't gotten too far into the UnityPhysics besides movement and collisions, I do everything in ECS and really only use MonoBehaviours for setting values i.e IConvertGameObjectToEntity.
But if you're trying to change the component data during runtime you can just use the entity manger to set that data. i.e manager.SetComponentData(entity, new PhysicsCollider() {...});
Makes sense, thanks. I was told it'd be possible to use Unity.Physics without any ECS, but it seems like at least hybrid is necessary to get it going
Is ECS a good choice, in your opinion, for a project looking to launch mid next year?
I really like it but am afraid of its stability for production
I would say yea. I was going to start doing a 3d top down multiplayer shooter in ECS. Then I realized I want to finish a project in ECS. :/ lol. So right now I'm doing a brick breaker game.
I say its way more stable now, but I don't plan on shipping this game until ECS is fully released.
Is there any window for an ECS release?
not sure honestly ¯_(ツ)_/¯
Okay, thank you!
I would argue that you should at least keep ECS in mind for parts of a game where ECS is the most useful, ie. when dealing with lots of stuff of things.
If you're looking for a 1.0 launch (as opposed to alpha/beta/early access) by summer 2020, I'd say probably you should not use ECS unless you're already semi-familiar with it, because of the learning factor; at least if you're familiar with monobehavior development.
It's much easier to find help for MonoBehavior issues, its better documented, and if you're also used to it...
One exception would be for a small and mechanically simple game, something that been done before, and a lot. Think tower defense. But to which degree that'd benefit from ECS... Only for learning, really.
Interesting; so if I understand it correctly, I could use both MonoBehaviour and ECS (hybrid) + use Unity.Physics? Or would that introduce me to a whole other world of pain? My primary goals are to switch to a deterministic physics engine and be able to support the game for a while.
The current prototype I have (PhysX, no ECS) has a bit too many server corrections to my liking
I'm sure I could improve that a bit on my end, but having a deterministic physics engine should help us along a fair bit
Okay so, the current design-time model always uses MonoBehaviors. And from the sounds of it, it's going to stay that way. Then you have a conversion script that, on converts them to entities during build, and that's what they are on runtime.
You can make stuff that interacts between mono and ECS, and I believe the official packages, where applicable (physics...), do so.
It's generally easier (on the whole) to either go all in on DOTS (with some exceptions, such as GUI, which is much easier if you 'do work' in monoland and then communicate with ECS land), or only use DOTS, (jobs, primarily) for specific things ('lots of stuff' kinda things)
Note also the difference between DOTS and ECS
The Data Oriented Tech Stack(DOTS) includes ECS, jobs, and the burst compiler, so it's a superset of ECS.
Your input makes me think that if I want to have a public release in summer 2020, it may be best to use MonoBehaviours and Bullet right now
At least to achieve my aforementioned goals
If you have lots of communication between the two of them, you will give yourself headaches, but communication between the two is hardly impossible, and some things are better(easier, faster to dev, more perf, and so forth) to do one way or the other - for a simple game the primary consideration will be learning - It is nice if you want to, but will take time
It's a sequel to another game that was built in another engine, there's a community waiting for it and the improvements it'll bring to the physics and networking
So not a small game per se
So the question becomes: What are your primary goals (short dev time?), and what kinda game are you making
It's a sequel to https://store.steampowered.com/app/707680/Slapshot/
I'm okay with a longer dev time, but if the 'longer' comes from waiting for DOTS to be ready then that's not the best trade-off for the project.
My goals are to really get the most out of networking and physics before anything else, because the game really relies on those two to be viable.
I really like the idea behind DOTS, I'm more comfortable with that concept because I've always used non-visual game engines and that leans more towards that workflow
Seeing how it's still missing a lot of things makes it tough to decide if it's the right move at this time for what I'm making
Well, you can do any logical thing in ECS that you can in mono.
You don't have as many built-in APIs and features (yet), though. GUI for one can't directly communicate with ECS, but since it's mostly just one-way bindings (button was pressed, health is X) it's pretty trivial to make work.
And both networking and physics are among the features of ECS that does have built-in (well, packages, but ECS is also a package).
I would recommend trying to make a simple multiplayer prototype using DOTS - Nothing fancy, just give each player one physics-driven character, and a couple boxes they can push around.
See how long that takes to make you, compared to the time it'd take to do the same in mono. Extrapolate for making the game you want to make.
I'm guessing you should be able to make it in a day or at least weekend, and if you can't, then ECS is probably not ideal for your project, because learning curve and tricky features. In that case, still keep its features (again, primarily jobs) in mind, while working in mono-land.
From watching most of the first video on the steam page, your project looks exceedingly simple, mechanically speaking, meaning if you could do that basic work, you're like 90% there, but of course the last 10% is polish and tweaks that takes 90% of the time 😛
Yep, very true
But the bright side is that means it wouldn't take long to know that it wouldn't work out, hence the mini-project
Is it possible to create raycastcommands in a job if you need to schedule a large number of them?
Hello, I am asking myself is this a good way to go or not? World.Active.GetOrCreateSystem<WalkableAreaSystem>().Data
I just want to allow all entites access to a specific set of data
might be better to create an entity with that data, to reduce hard coupling with systems
also yes you can create raycast commands in a job, but when it comes to scheduling RaycastCommands.Schedule that can only be done on the mainthread
cant wait for dots netcode sample mentioned in copenhagen
Now that I've added [DisableAutoCreation] on my system and create it using World.Active, it has stopped updating. Any ideas? The data for the job is there
Have you verified that the system is, indeed created?
yea, i set a breakpoint on OnCreate.. that works
It doesn't show in the Entity Debugger under the active world, or any*
I meant in the entity debugger, that's the important one
Oh in that case, no I don't see it
How are you creating the system?
world.CreateSystem<BrickLayoutSystem>(brickEntities);
brickEntities being of type?
no, create system says: param object[] constructor args
public T CreateSystem<T>(params object[] constructorArguments) where T : ComponentSystemBase;
No, I meant what type is brickEntities? What would typeof(brickEntities) return?
oh, sorry. NativeArray<Entities>
I must admit I'm not familiar with creating systems with that constructor overload. Have you tried moving whatever code requires the argument to a separate method, and call an empty constructor, then the initialization method?
Yea, I tried that already. I was setting the entity array via the system's property
And that also doesn't make it appear in the entity debugger?
Yea, that way doesn't work. I saw in the FPS Demo that they were using Disable Auto create attribute to create there systems. Maybe look at that codebase to see what I'm doing wrong
Non-default system creation seems to be a tricky thing
lol I'll let you know if I figure it out!
@tawdry tree , and everyone else. you need to call update on the system. That was the problem.
You need to add the created system to a SystemGroup, otherwise it wont automatically update
the Initialize, Simulate, and Presentation groups are the only ones who's Update function is added to the PlayerLoop (and will thus be called each frame)
These groups will call the update of each system in those group.
So I have a system which adds a ‘Dead’ component to an entity and another system which deletes entities with the ‘Dead’ component. Only trouble is that they seem to run out of sequence. The deletion system seems to run twice for each entity that gets tagged with the Dead component
Any ideas for how I debug?
I can do some checks for null to prevent the exceptions but I’d much rather figure out why it’s firing twice. It’s as if it starts running again before the barrier delete is fired
actually that's not the problem, it's the opposite way around...
The entities are being flagged for delete twice, and then I'm getting an error that the component "Dead" has already been added
which is weird since it should be destroyed first
Hmm I guess you could ensure that you only add "Dead" to entities that don't have the "Dead" component tag already
I think another way is to reorder the jobs so that - you clean all entities with dead component first - and you add dead component tags to new entities that need to be marked for deletion
so the former would have the [ExcludeComponent(typeof(Dead))] on its job
Ah, I see @stiff skiff. Thanks.
@coarse turtle I tried the second option, as to me it's an order of execution problem... problem is that I'm trying to flag them for delete twice before I do the delete.
Here are my logs:
Flagging for delete: Entity(3:1)
Flagging for delete: Entity(4:1)
Flagging for delete: Entity(3:1)
Delete Entity: Entity(3:1)
Flagging for delete: Entity(4:1)
Delete Entity: Entity(4:1)
EXCEPTION: The entity does not exist <-Seems to be the flagging for delete that caused this
m_Barrier = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
That's the part in the flow where it's updating the entity
hmm and both jobs are using the EndSimulationEntityCommandBufferSystem?
yup
the jobs are chained too?
Dead Entity Cleanup has: [UpdateBefore(typeof(VendorTransaction))]
and the other one has [UpdateAfter(typeof(DeadEntityCleanup))]
I can put these on pastebin if it helps?
sure
var transactionComponents = PurchaseQuery.ToComponentDataArray<PurchaseRequestComponent>(Allocator.TempJob);
var walletComponents = GetComponentDataFromEntity<WalletComponent>();
var vendorOfferComponents = GetComponentDataFromEntity<VendorOfferComponent>();
So I think these lines might be the issue - so the CleanUp job is only scheduled and then you move onto your transaction job, so deletion hasn't happened yet. You're then grabbing the all the component data and associative entities immediately which may have the entities that need to be deleted to be copied over to its transaction job which is then scheduled to run
I do know that if you wanted to do a ToComponentDataArray or ToEntityArray you can pass an out var jobHandle to schedule the retrieval later instead of grabbing the componentdata/entity array immediately
since ToComponentDataArray(Allocator) calls JobHandle.Complete() internally
OKk 2 secs, need to get my head around this
lol
so VendorTransaction OnUpdate is happening before the cleanup job is finished?
So I think it's more like the data including the entities that need to be deleted are being copied over
for the VendorTransactionJob since you're only scheduling the DeadEntityCleanUpJob - so the deletion hasn't happened yet
so I thought that scheduling it in EndSimulationEntityCommandBufferSystem meant that it'll happen before all of the Update calls?
so when the VendorTransactionJob is being set up and scheduled, you have already copied over potential entities which may need to be deleted
Im not sure if it's played back immediately 🤔
What happens if you did a JobHandle.Complete() as the first call in your VendorTransaction system? I'm thinking that would perform the playback for the cmd buffers too and would "solve" the issue - ofc its not ideal as you're completing the previously scheduled jobs immediately
first call inside Execute()?
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
inputDeps.Complete(); // Immediately complete previously scheduled jobs.
var transactionComponents = PurchaseQuery.ToComponentDataArray<PurchaseRequestComponent>(Allocator.TempJob);
var walletComponents = GetComponentDataFromEntity<WalletComponent>();
var vendorOfferComponents = GetComponentDataFromEntity<VendorOfferComponent>();
var commandBuffer = m_Barrier.CreateCommandBuffer().ToConcurrent();
var myJob = new VendorTransactionJob();
myJob.PurchaseRequests = transactionComponents;
myJob.WalletComponents = walletComponents;
myJob.VendorOfferComponents = vendorOfferComponents;
myJob.CommandBuffer = commandBuffer;
var myJobHandle = myJob.Schedule(inputDeps);
m_Barrier.AddJobHandleForProducer(myJobHandle);
return myJobHandle;
}
so the first effective call in the OnUpdate(JobHandle inputDeps) function
Flagging for delete: Entity(3:1)
Flagging for delete: Entity(4:1)
Flagging for delete: Entity(3:1)
Flagging for delete: Entity(4:1)
Delete Entity: Entity(3:1)
Delete Entity: Entity(4:1)
Exception
hmm
it's as if the vendor system is running twice before the deletion happens
Would it make sense to reverse the order?
- DoTransaction
- Only add Dead component to entities that do not exclusively have "dead" component?
- Cleanup all dead entities after transaction
yeah, I'm being a little lazy by not checking if they already have the component - 1 because I don't have access to the entity and 2) because I don't want it to mask this issue
the first 2 lines of my logs are contradicting my UpdateBefore / After
Dead Entity Cleanup - On Update
Vendor - On Update
Vendor Transaction: [UpdateBefore(typeof(DeadEntityCleanup))]
Dead Entity Cleanup: [UpdateAfter(typeof(VendorTransaction))] ```
seems out of order, right?
yea
maybe I'm using those tags wrong, or in the wrong place or something :/
Certainly looks right
hmm what if you made your own CommandBufferSystem that's used for the 2 jobs 🤔
I'm wondering how much the CommandBuffer is recording
never done that
public class SomeCommandBufferSystem : EntityCommandBufferSystem { }
World.Active.GetOrCreateSystem<SomeCommandBufferSystem>(); // You'd use this instead of EndSimulationCommandBufferSystem
Hmm 🤔 okay
sorry, don't mean to be a pita
it's cool - Im curious about this too
seem to be in the right order here
command buffers seem to be before the systems are run
bah, I'm going to let this beat me for tonight
thanks for the help, going to head to bed o/
np - I'll sleep on it too haha
is including the writeonly attribute necessary
i know that readonly helps jobs go faster cause it disables some safety thingies
also is randjob.nextx(min, max) inclusive or exclusive?
cant find info on the docu
Are buffer elements supported by Visual Scripting yet? Can't seem to get a node related to them
Anyone know if there is a way to hook into the conversion pipeline on a per-world basis, and not a per-entity? An alternative to IConvertGameObjectToEntity, that doesn't require a gameobject.
@fair condor maybe look into how subscenes are created given that they dont need individual ConvertToEntity scripts
yeah maybe try using GameObjectConversionSystem?
Hey, guys. Trying to wrap my head around ECS by making a simple tower defence game. How should I approach this task in a DOTS way? I want to have a collection of waypoints that enemy characters should traverse, one after another. The way I'm thinking about the task now is:
- Make an authoring script (say,
WaypointCollectionAuthoring) with an array ofTransforms, so that I could assign them in the editor. - The same script should implement
IConvertGameObjectToEntityand in theConvertmethod make aList<Translation>out of theTransformarray. - Assign that array to a property of a
WaypointCollectionshared (?) component. - Each enemy will store the current index of the list, starting with 0, and will switch to the next one upon reaching current target waypoint via a dedicated system.
Is it a viable approach? Am I missing something? Thanks in advance!
yeah I'm using a blob for my waypoints
i dont think you want shared component in this case
Could you point me to an example or maybe post some code?
Uncover the process of converting GameObjects to Entities and how this can be extended and customized. Find the code samples on GitHub: https://github.com/Un...
thats what I used to figure it out they have the node project on github
Cool, thanks!
Honestly, in a tower defense with static routes (does not change during runtime) any kind of array will do, so the simplest that works in DOTS (including burst?) would be ideal. Haven't used arrays in jobs before, so don't know if 'vanilla' arrays work for that.
that's true I kind of need the nodes system because I have multiple routes
I want to see if I have the correct understanding: I want a job that handles collisions of two entities. So I make two EntityQuery's for each entity and use an IJob to handle the logic?
thats the straight use case of blob assets
and even the literal example for them (static level waypoints)
i tend to think of tower defense things as having changeable waypoints, to redirect the flow of enemies
there are 2 main kinds of tower defense games
those where there is a VERY fixed path, and then you defend it with towers (cant block)
and those with more freeform terrain that let you put barriers
the best tower defense game I saw is a Bad North by https://twitter.com/osksta
anyone ever play those old matrix defence tower defence maps in starcraft 1?
no news on the next entities release?
I did a game jam last weekend and was trying out https://github.com/Unity-Technologies/multiplayer but soon realized it is 3 months old. A lot of the...
I'm equally excited and scared of what the new entities package is gonna have/modify
I haven't touched dots since last Unite as been waiting for new release :p
I doubt the changes will be monumental but I don't like doing extra work all the time (like you do all the time when you use dots and new updates come along)
this should be the preview for the 1.0 release though right?
didn't they say in the last roadmap talk that ecs burst jobs would be 1.0 with 19.3?
well, jobs and burst have been released already
but I think they had some target like this for the actual entities package
it'll still take years for the other packages to catch up tho
@gusty comet it was for 2020.1
and of course, these are not set to stone
we've seen dates get shifted for over year from some earlier estimates
(not for ECS but in general on these roadmaps)
from same slides:
DOTS Netcode: 2020.1
DOTS Physics 2019.3
DOTS Audio 2020.1 (experimental)
Netcode 0.0.1 preview 4?
😯

"registry": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"```
😄
well, I noticed Unity stopped using old staging altogether
I guess too many people started using it
now they are on fully internal loop again
yeh
are you able to import those packages?
or is this just internal to unity devs?
I'm at work and haven't had a chance to try it out yet 😄
[UpdateInWorld(UpdateInWorld.TargetWorld.Default)]
Is this new too?
Can't say I've seen this before
I think so
RequireSingletonForUpdate<InitGameComponent>();
Nice filter simplification in ComponentSystem. Not sure this was here earlier either.
[GhostDefaultField(10, false)]
Access to 'https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates/com.unity.burst' was denied
bah
What GhostDefaultField is supposed to do?
It populates the ghost collection I presume
on the Netcode Alpha you had to go to the prefab of what you wanted to ghost, and add the fields there
now we can do it with attributes from code it looks like
Oh okay
I have 0 idea about networking so i suppose i should look at other stuff first to get that
We'll just have to wait for the release anyway. We don't have access to their internal package registry, sadly.
well, at least we know Entities will get bump from 0.1 to 0.2 on next package
(no surprises there tho)
was here an update?
Just some examples that use new stuff that we cannot use yet
Wow..the tease is driving me crazy!! 😐 just showing us something that we cant use!
pretty eagle eyed to spot that repo package update 🙂
@dull copper the singleton for update thing was long needed
whats that about singleton for update?
RequireSingletonForUpdate<InitGameComponent>();
maybe its a bit more optimal than that
like not even scheduling the system if that component doesnt exist
I was so ready to dive in today already but...
but on the other hand
and yeah, I'll take the future memes to #497872469911404564 :p
My favorite game is programming
wait, RequireSingletonForUpdate<> was there for a while now
were all waiting, let the memes flow 🙂
...there are no mods around, right...?
Just an amateur question.. 6 months into Unity should I pursue DOTS or continue to work on the basic stuff?
I think once you get the basic workflow down in Unity - you can try jumping into dots - but the workflow might change with major releases
Probably better to continue working with basic stuff. You will have a better understanding on how to author components based on existing functionality that unity has.
I'm pretty proficient in creating the basic functionality of whatever game I want to make. Dirty code, but it works
If the entities package was ready for production, i would have given a different answer 😛
And i tried understanding ECS via videos but there is a complete lack of them save for some which just go over some part
Thats the thing. I think its better to learn it once it is actually production ready feature.
if you have just started working in unity that is..
The best learning environment is when there's plenty of examples, plugins and community discussions on the subject you are willing to learn on. You'll find much more help in non-DOTS world at the moment. If you are willing to learn DOTS I'd suggest starting with Code Monkeys video series on it. Pretty much the best tutorial out there.
@night cargo I tried the code monkey tutorials, but even after multiple attempts didn't really get the whole essence of what exactly is happening. I understand the architecture and what is supposed to happen but not how
@deft niche working on both at the moment. Will probably switch back to traditional methods in a while
Is Entities package documented yet?
We've been using Unity for 8 years now and adopting DOTS is still a challenge for our organization. I'd suggest you stick to the traditional approach as Unity DOTS won't be completely production-ready until end of 2021. Anything regarding Animations and UI are far from being integrated into the DOTS world.
All right. One last thing, apart from video tutorials any place you would suggest I could get studying material on dots?
@dusty scarab you can find docs linked in the pinned message here
also most video tutorials you'll find will be horribly outdated
look for the official manual + official DOTS sample repo, they are kept up-to-date
both are linked on the pinned msg
Got it! Thanks. Didn't see the pinned messages before, that should get me started i think 😅
@dusty scarab tbh, if you are just now diving into DOTS, I'd wait for a week or so
new entities package will release any day now and it's going to have API changes again
plus if they really did what they planned to do, then the new package usage is simpler due to less boilerplate code
so at this point, it's worth waiting a bit IMO
Okay, thanks for the heads up ;)
Honestly, if you're new to Unity and interested in ECS... just keep reading news and articles, watch videos (the unite ones are good), and pay attention in this channel to see what people get stuck on. That's what i did, for the longest time.
Sure, I played around a bit in a 'sandbox' project (basically just me making various things with no overarching plan, aside from learning), but the understanding came slowly, and then a few pieces 'click' here and there.
The Unite video on entity interaction is highly suggested, assuming you know the basic 'what's going on' of ECS. https://www.youtube.com/watch?v=KuGRkC6wzMY
Interaction is fundamental in games, both in how players interact with a game and receive responses, and in how parts of the game interact with one another. ...
I still suggest focusing on monobehavior for now.
That said: you should be aware of, and keep in mind, the parts of the DOTS stack that is deemed production ready (non-preview).
At the current moment, that'd be jobs, and burst (which you'd use with jobs).
One simple thing you can do to start is attach ConvertToEntity with Inject GameObject on everything, and then instead of writing Monobehaviour.Update() methods - write a system doing Entities.Foreach((MyMonobehaviour mb) => {});
Basically nothing has to change in the way you write code/think about things, keep using mb.transform etc. You will quickly start noticing that being able to do stuff before/after the Entities.ForEach() part, or query for something more than a single monobehaviour is really powerful.
I do however agree that if you are just starting you probably want to stay on the "classic" Unity until things mature a bit.
@dusty scarab i say spend a few days trying it out(make sure to check the samples repo in the pinned messages here) and see how you like it. if you arent super well entrenched in oop programming you might find it makes more sense to you than the old way of doing things.
I have a brick breaker game, and I want to know if my paddle is too far from the sides of the game board. I have a component for the game board, so I know the width. and I know the paddle component. Is there a way to query two different entities in order to check if the paddle's pos is beyond the board?
you'd query the width of the board first, grab the associative data for the board
pass the copy of the associative data to the job or function (im not sure what your set up is) to it and check if the paddle is within the bounds of the board
Ok, That was my understanding of it all. Thanks for the help
"population = entityQuery.CalculateEntityCount();"
with 0 entities why is this giving me a value of 1?
Are you destroying that entity immediately ?
excuse my ignorance but why would that matter? at >0 entities i get an accurate population count
its just when it hits 0 that things start getting werid
the system in the debugger also shows 0 entities?
i dont know what to make of this, but basically the query includes everyone that has an age (equivalent to saying everyone with a pulse) but excludes everyone with, well, no pulse
but theres no entities
and yet theres a ghost left
The code works perfectly if there's more than 0 entities, but not if there's 0 🤔
The UpdatePop function is just updating the GUI with the population variable
@onyx mist what about using this.RequireForUpdate(query); in OnCreate() ?? In that way the system will only runs when you have at least 1 entity that matches the query
sorry, this.RequireForUpdate(entityQuery), not query
And it's not necessary to do the same query again on update
you can just use entityQuery
Any news of the mythical dots sample yet?
Nope, yesterday we got some new git examples but we cannot use them yet
@hollow scroll thanks for the ideas! unfortunately that still doesnt solve the mystery of why at 0 entities the population is 1
@onyx mist basic q but just to ask, are you sure it's getting past if(GrossDaysCumulative == neededDay)? Perhaps UpdatePop just isn't updating the ui?
in fact, if there are no entities to process, the system won't run (and hence won't update the UI) - you could try temporarily adding the [AlwaysUpdateSystem] attribute
yes
that was the issue
thank you SO much
and thanks everyone for the other tips given 😊
ace 🙂
Anyone know how subscenes work, or got any vid of it? In my multiplayer game I'm trying to have three subscenes of Server, Mixed, Client. And want to load the level of Server, Mixed onto server world, Client Mixed onto client world(s). I do this by using the subscene script and prefabs, not sure if this is the right way to do it? But it doesn't like duplicated Mixed subscene asset in the hierarchy. Is there really a problem here, subscenes doesn't save any data back to asset right?, or is this just a unity non thought of use case I'm hitting?
You bruteforcing through on the Netcode alpha?
My guess is they've got around to test more of these use-cases with the next version (or, my hopes are as such)
You might look at this @mystic mountain , which is a preview of what will come in the next version, maybe there is something here to learn from wrt your issues:
https://github.com/Unity-Technologies/DOTS-training-samples/tree/larus-labrat-netcode/Ported/larus/LabRat
I thought subscenes wrote to blobs/entity cache?
Uncover the process of converting GameObjects to Entities and how this can be extended and customized. Find the code samples on GitHub: https://github.com/Un...
Might be something in here, but not sure
And if you find anything, I'd love to know too 😄
Hmm ok! Yeah, only real problem I had with netcode was that it assumes a match on port, and an immediate server frame after it's connection call. (as it sends commands right away for some reason). Will check em out. Yeah, I'm not sure at all if it writes or not. I would imagine this is something you can specficy/opt out of?
@mystic mountain in this video they talk a little about scenes https://youtu.be/TdlhTrq1oYk
Uncover the process of converting GameObjects to Entities and how this can be extended and customized. Find the code samples on GitHub: https://github.com/Un...
Skimmed through some of these, will check again 😛
You managed to get Netcode alpha to run on latest Entities version? Or stuck back in the version Netcode alpha was released on?
I tried but gave up, thinking the next version would be released soon. Now three months later, still waiting 😄
Soon though, soon!
@remote coyote I'm using https://github.com/Unity-Technologies/multiplayer with 2019.2.12f1
yeah, so just on the entities package version set up in its manifest yeh?
I have the com.unity.transport (ucg.matchmaking, ucg.uspq - though not using em right now) in Packages folder. Then NetCode & Utilities in Asset folder
How do people usually deal with triggers? I.e. tag to change UI for example. I'm currently creating an entity with a tag that I destroy on PostUpdateBuffer. But I feel like as the project grows it gets hard to keep track of what Tags are meant to destroy entity, and which should only remove the tag itself. I'm considering either having a naming convention for components that does either, or having a second tag that marks that it should destroy at end of frame - so it's all sorted on creation of entity.
last option sounds nice
adding a clear summary for the tag could also help
I also find that separating code into isolated feature modules also helps a lot
e.g. tags should only really be used within that feature module
but I'm unsure how easy it is to achieve that kind of code separation with how Netcode generate code, and specially that ProjectName generated group, that you might want some of your systems to be grouped with.
@remote coyote Can you elaborate what you mean with "isolated feature modules"?
@mystic mountain The idea comes from SpatialOS actually: https://improbable.io/blog/feature-modules-in-spatialos-and-designing-project-nobody
Independent Norwegian developer, Trond Fasteraune, talks about the feature modules he’s been creating for his prototype small-scale MMO on SpatialOS.
Though rather than adapt his Frontend.cs approach with static APIs for interfacing the functionality, I'd rather opt to have non-static equivalents on the systems you're interacting with, to avoid use of statics.
I also find that extending World with a Get*System() can take away a lot of bloat
World.Active.GetHealth().Damage(target, 100); for instance
Whether they're then used as pure Packages or just put into separate asmdefs in the Assets folder, doesn't really matter that much
Apoc/Packages/Apoc.Modules/Apoc.Health/
I do this
Apoc/Packages/Apoc.Modules/Apoc.Health/Apoc.Health.Server/
Hmm yeah ok. I already have asmdefs for base, editor, client, server, mixed. But would be interesting to divide and conquer it down to feature sets as well.
yeah, whether its worth it depends on the size of the project of course
and I'm not sure whether its a real best-practice yet 😄
I'm curious to see how Unity approach their TPS Netcode sample
Hmm yeah, only annoying is to create and update the references on every assembly. And the deeper you dive into gameplay I would imagine there are more and more inter references, but it makes you think and care more of cohesion : )
Yes, ideally feature modules shouldn't talk to each other directly, but rather expose interfaces that your main game code implements to create a bridge between them.
But this quickly edges toward over engineering
The cool thing about writing interfaces like that though, is that now you can easily mock those, and can test each feature module in isolation
@remote coyote How does this work with authoring components etc? First things that comes to mind is that you have to write all authoring in the main code anyway to not break prefabs etc when loading/unloading feature sets, and then call some interfaced method that adds the actual component to the entity in the conversion workflow? It feels like a lot of extra work x)
I dont suppose anyone can check my code and thinking as whether its correct
if (math.distance(prevpos, curmovpos.Value) > math.distance(prevpos, tempwaypointscurr[curryway.value].Position))
{
var tempdistance = math.distance(curmovpos.Value, tempwaypointscurr[curryway.value].Position);
curmovpos.Value = tempwaypointscurr[curryway.value].Position;
curryway.value += 1;
movedir = math.normalize((tempwaypointscurr[curryway.value].Position - curmovpos.Value));
curmovpos.Value += movedir * tempdistance;
}```
I'm moving around waypoints in a job and using that to check when the entity's are going too fast they jump beyond the waypoint
so it gets the excess distance, then sets the position to waypoint and moves it round to the next waypoint with the excess distance
I'm trying to move entity's through a bunch of waypoints at high speeds while keeping them equidistant to one another
At fast glance, the logic seems ok. Might not be the best way to solve the problem, but it should work of what I can tell.
dont have two waypoints at same place though
yeah thanks I'm sure their is better ways but thats the one I came up with
I'm thinking my problem may be something else then, maybe the spawn rate, I have to get them to spawn at exactly the right rate
What is the behaviour you have and want?
like I said I want to move a bunch of entity's through some waypoints while keep them at specific distances from one another
they tend to bunch up and clip into one another the way I have it now
maybe I should just have a system that detects the distances between them and moves them apart, that would probably be easier in general
Packages can hold prefabs, or maybe it's nice to decouple implementation from presentation... it's all just ideas anyway ;-)
@remote coyote Yeah, but then you have a player entity that wants movement, aim, inventory etc : ) But yeah, it's interesting.
@pliant pike I guess depends of what it is you're doing 😛 If they are "dynamic" as in to adjust if anything pops into between two, then I would go for that yes.
I'm not even sure its something you would want to do for all things
And DOTS allow you to have these things live in largely separate modules without having to know about each other. Its largely an approach targeting feature isolation naturally
still refreshing https://bintray.com/unity/unity/com.unity.entities here
guys, anyone came up with an efficient and safe way of appending to a nativearray in a ParralelFor job?
ive just been refreshing the main repository 😄
Why ? Did anyone mention its coming out today ?
basically im adding an array of from 3 elements to 10 elements from each parralel execute function and i want all of these combined in a grand array
i do it every day, multiple times a day 😦
i have a problem..
it was supposed to come out some days ago already
weeks ago!!
Entities update?
so... anyone have any good way of appending to an array from within a IJobParralelFor job?
nativearray that is.
what do you mean by appending exactly ? Do you mean modifying existing contents ?
(no idea on the actual question)
cuz i would append to it by finding its last set index and contininuing from there. But once you allocate its memory, its .length is always the same
and while that topic is about dots netcode, it's all tied together
Don't think you can append to an array in a job
they need to release entities, netcode and dots anim all at once if they want to ship that fps thing
You got the answer to your question already 😛 Once the memory is allocated, it won't change
so. I have 2 fields in the job. sourceArrayToBeWorkedOn and destinationArrayToAppendTo in a parralelFor job
so every job take from sourceArray and does stuff, and results in 3-10 Elements that need to go in the destinationArray
you need to allocate the memory for destinationArray beforehand
i know the memory wont change. i have allocated a memory of max 10 elements per job to the destinationArray. But if i save to the destinationArray with index*10 i will have gaps in my destinationArray right?
cuz in some jobs only 3 elements will return
Can't you loop over the output?
and eleminate any gaps? hmmmm only if the uninitialized values are set to null.... lemme check, cuz if the init values are 0 in an int array... then i cant know if the element is a gap or not
nope... looping over wont work... it sets the init value to 0... so i have no way of knowing if my jobs actually set it up with a 0 or they never got initialized
What I mean is it possible in your case to iterate over the output array, and gather the data from the input array to fill each element? I didn't really get what determines the output number.
Init, manually set all to some arbitrary value you're pretty sure won't be otherwise used(int.MinValue?), then do what you're doing, then check for the value?
More work, but setting all the values in an int array shouldn't be too bad, I think. And if it becomes a problem you could find a better way later
ok, I have nativearrayAAA, whichs length is 1000. so i am running it in IJobParralelFor (1000,100) and nativearrayBBB is where i want the output in
so each parralelFor Ijob will process nativearrayAAA[index] and result in 3-10 elements of int type which need to go in nativearrayBBB
what determines 3-10 elements
the actual execute part in the job.
i can safely assume if everytime it gives 10 elements for every 1000 elements of A, then BBB's size need to be 10,000. which i have already allocated
When you deal with multithreaded things you usually go over output and gather input, especially if you need to read from same place twice. So I'm asking if it's possible by index of output element, determine where input should come from?
Actually, shouldn't there be some overload to set which value it inits to? Seems like an oversight if not
@mystic mountain considering every job can return with max 10 elements, in can store the result in BBB[index10] . but then if index=1 gave 3 results, then index=2 will store results in BBB[210] and all elemtns from BBB[110+3] till BBB[210-1] will be gaps which i wont be able to identify... as they all initialize to 0 😦
@tawdry tree i doubt it. the results are actually float3 and they can be pretty much any value... unless i can set them to null.... lemme check!
You're not reading what I'm asking x)
hmm, i read that, didnt understand what you actually meant. my outputs are all zeros. input arrays determine what goes in the output array
So you can't rewrite your code to know that e.g. index 0 of output array requires inputarray index 1-3 ?
oh... err. index 0 -9 of output array requires info from index0 of A. but A could fill either from index 0-4 or 0-7 depending on what is at the index0 of A
wait, your image gave me an idea @mystic mountain to show you what i need!
to the batcave! to use the mspaint :p
@mystic mountain and for everyone who can help 🙂
So if you can't directly map output from input, which means there is some dependency between inputs. Depending on problem you can either run singleThread and save index to write to next( I think?). Or make a middle-calculation which first runs to calculate the amount indicies for each job, and then create offsets to use in the calculation (so one part create indicies, then iterate and summize the offsets). Or similarly when you write 3-7 indicies, also write this to a seperate array, which you later use to copy memory to a continous buffer.
hmmmm.... writing to a separate array how many elements were added in this particular job.... and then i know which ones are GAPS later... @mystic mountain thats a good start i think, i shall work on that
@digital scarab memory is not really a concern. But the GAPS are the useless items that the next function can not identify as useless...
either i eleminate the useless array elements from the jobs, or i find a way to tell the next function which output array elements to ignore
as nativearray by default, when initializes sets value of the element to 0. which is one possible useful value. and It doesnt let me set any elements to null... as int or float3 is not a nullable item
You can likely assume a default value that can be implausible as a "null" entry
e.g if you needed a float3 to be 'null' you can likely assume that generating a float3 with a magnitude of infinity would be a 'null' entry
Currently I have resorted to using a nativearray<bool> isElementSet lol to show if an element is actually set by me or not lol. It’s working. But it’s still irking me @mystic mountain @digital scarab thanks for the helpful discussion and concern!
@tawdry tree Thanks! Started playing around myself in a sandbox project! All the Unite videos are in my to-do list
@safe lintel Yes, OOP doesn't exactly go well with me so I'm trying to understand this! reading up on everything pinned in the channel.
Thanks!
Does ECS supports 2D graphics, SpriteRenderer?
I think there are solutions out there, but they're all custom, no Unity-built stuff right now
@digital scarab Any news on the update ? 😛
Cool.. sorry to bother you on vacation. Enjoy 🙂
they are probably waiting for Topher to get back from vacation to fix some last part of their setup
🤔
that really made it sound like it's happened before
If you work in IT... you will eventually come to know it. Assuming you have some level of responsibility, anyway. I expect it's not so different in many other fields.
Oh the joys of not having other people touch code you're responsible for
now theyre just teasing us by having entities 0.2 as one of the options in the survey 🙂
Soooooon
Looking at the AngryDOTS example code, a few entities are created by conversion from GameObjects and then used to instantiate entity copies, but these blueprint entities themselves are never rendered or accessed in any system, it seems. For example, an entity is converted from a 'Bullet' prefab, but that entity itself never acts like a bullet, and nothing in the example code explicitly marks it as inactive. Anyone understand what's happening here? Are entities from conversion somehow inactive by default?
Yes. Anything with the Prefab tag component is skipped unless explicitly queried for. Same for the Disabled tag.
@untold night Ah thx, I vaguely now recall hearing that. Do you know the doc or video source I have in mind?
btw, is the inspector display of tag entities bugged right now? Components following a tag component are improperly indented.
@old pulsar check this https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.IDeclareReferencedPrefabs.html
All GameObjects added to the referencedPrefabs list get converted to entities and the Prefab tag is added automatically, when instancing these prefabs the Prefab tag is automatically removed
dont think theres a fix for the debugger
@fair flame thx, and this is what I had in mind: https://www.youtube.com/watch?v=TdlhTrq1oYk
Uncover the process of converting GameObjects to Entities and how this can be extended and customized. Find the code samples on GitHub: https://github.com/Un...
@old pulsar - Here you go:
Prefab: https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.Prefab.html?q=Prefab
Disabled: https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.Disabled.html
I've looked over the package source before and can confirm it skips those two unless explicitly included in a query.
iirc the commandbuffer systems are going to be able to be burst compiled in 0.2, what does this mean exactly? i thought burst compile only made jobs faster not general code, and arent commandbuffers by definition done on the main thread?
you cant burst compile a job that uses add or remove component for now
So that means burst can implement the call but doesn't really make it incredibly fast?
awe
i was excited to see a big improvement in the speed
oh well should still help a little!
ok, another question for IJobParralelFor job. I have to use either A or B in this example. Which would be faster or recommended in the execute function. https://pastebin.com/GcUHyby8
a huge algorithm is determing the X and the source Array. so i have no control over the value of X or the contents of sourceArray of that length
I am leaning towards the switch, but need more feedback, tests are coming inconclusive
@onyx mist Playback of a command buffer can only be done on the main thread, but you can record structural entity changes in a job. Such jobs can't be burst compiled in 0.1, but changes to EntityCommandBuffer (or the compiler?) will fix that.
Gotcha thanks
@languid stirrup imo A) is more legible and you can make it faster (if that’s important) by caching .Length... that said, the other values are uninitialised so I don’t know how you’d know which ones actually had results set but I guess that’s just because it’s example code. Easy to test which is faster but my guess is the difference would be negligible and possibly practically un-profilable
hmm, yea from my tests the difference was neglible, hence wanted a second opinion, thnx for the feedback @amber flicker
What's the ECS way of dealing with singleton-like entities, like an inventory or smth? Should I get them with archetypes, too? How do I ensure their uniqueness? Am I mistakenly trying to use an OOP paradigm here, and there's a conceptually different way of doing this?
Check SetSingleton method that every query/system has
This blog explains really well how it works
https://gametorrahod.com/ecs-singleton-data/
Although it has a little bit of time so some stuff may be different
woah!
prefab component
I've never noticed that before
holy shit that can fix something I had to work around
@untold night thank you so much for that tip. I had totally glossed over it
hmm maybe visual scripting is almost ready for a package release(i guess technically it is but this doesnt appear to have any official announcement)? https://bintray.com/unity/unity/com.unity.visualscripting.entities