#archived-dots
1 messages ยท Page 126 of 1
run probably faster especially if you can run it with burst
oh really?
some very small overhead in scheduling it for other threads
because the overhead from the job system is larger than the work?
what the systems do is normally get a "command" entity, set 1 or 2 global variables with 1 or 2 if statements
that kind of thing
i noticed in my uses some jobs for a single entity were like 0.03-5ms with it being threaded, and then 0.01-2ms when just run
ah and also they add a component to the event of the form ConsumedBySystemX (s.t. I won't get the same entity again)
Yes if you're just settings variables then you should definitely just use Run
You can use a command buffer to avoid making structural changes during processing
at which point would you guys change from run to Schedule?
yeah I am using an ecb for that
for the component adding
Anything more complicated than just setting variables I will usually run as a scheduled job
So my event system is basically:
An Event always has a component
struct Event {
float aliveSince;
float destroyAt;
}
And a system that increases aliveSince and destroys the entity when aliveSince > destroyAt
Also the entity ofc has some component that has information (e.g. tileHeightChange) and all systems that need it can bind to it.
Every system that works on the event adds an ConsumedBySystemX in an ecb (for every system different X), and queries only for events that dont have ConsumedBySystemX.
So every system that wants the event, will see it once and the timing system makes the entity dissapear quickly (DestroyAfter is very short, it basically just needs to be longer than a frame)
is there anything I could easily do better?
I'm not sure to be honest, I'm kind of hitting this problem myself right now where I'm trying to figure out the best way to handle system dependencies for tags that might need to exist for more than a single frame.
It sounds like what you're doing is a solution for it, but having the tag just hang around for "some amount of time" seems weird
But if it works it works
There's also the performance cost to consider of having your consuming systems changing chunks every time they consume an event
@zenith wyvern not the tag hangs around for a random time, but the event entity itself
but yeah it would be nicer to just have it be consumed once by everyone and deleted
Well yeah in my case I guess I'm basically using tag components as the events
i dont think an event should hang around more than 1 frame tho ๐ค
but i guess it depends on what you are trying to do
yes it would be nicer to be deleted after one frame, but I had no simple nice idea how to do it
@opaque ledge The problem is the event might need to be consumed by more than one system, and it might cause another system to react which would also rely on the event. The obvious solution is to just create more events that you chain off one another
@zenith wyvern can you tell me an example on what you mean by event tag? Do you have one big event entity that you just add and remove tags from?
But then it becomes awful to maintain
a system that deletes event components that runs at the very end of the frame?
have 1 system that creates it, have 1 system that destroys it, and your event entity at end or begin frame commandbuffer
or at the very beginning, cleanup up last frame's events?
@zenith wyvern you mean every system deletes the event and creates a new one except one last chosen system? that sound like a lot of boilerplate and also which system is the last
@zenith wyvern what do you mean by consume tho, does the system actually destroys the event entity/tag ?
@zenith wyvern can you tell me an example on what you mean by event tag? Do you have one big event entity that you just add and remove tags from?
@junior fjord
It's not any kind of generic event system. I literally just have empty components that I use only for the purpose of being consumed by another system.
system that creates Event just deletes it via ECB
@opaque ledge no by consuming I just mean that the system looks inside the event, gets the information and does something
ah yeah maybe consuming is a bad word, it sounds terminal
@opaque ledge That's what I'm still figuring out. If I have the consumers destroy the event then I need to shift around where it gets destroy any time I add a new system to the chain. If I have the producer also destroy the event then obviously it can't know if other systems still need to consume it so it can only exist for one frame
just reads it then ? thats easy to do
@fallow mason that could work, but maybe one needs to wait one frame more (so the deletion system has to see the event twice), because elseways I don't know at which point I create the event entities
tbh, that sounds like a design flow, producer shouldnt care if there is a reader or not right ?
nobody cares if a system has read the event except the system itself @opaque ledge
what i do is, i have a system that simply destroys the event via ECB and thats it, imagine i created the entity at begin or end commanbuffer, and that destroyer system will destroy the entity at end command buffer, since entity will not be destroyed instantly, other systems will be able to read it as well
I just add a ConsumedByX component in system X, s.t. X won't read the same event entity next frame again
so there you go, 1 frame only event system
but only systems that run after the event is created and before the command buffer runs can read your entity
I think it's like Curly was saying, if an event needs to exist for more than one frame that's probably a flaw in design
By definition the event should just exist for a single frame so systems can react to it then be destroyed.
trying to think of a situation that would require the event to survive longer a frame ๐ค
Not because it's like "a rule" but because it makes things easier on the coder
@warped trail but what if the system that should read your event runs before you? Or you created the event entity from a MB?
I don't want the event to survive longer than one frame
@junior fjord thats where you are wrong, entity is instantiated only at ECB not instantly, so when you create the event it wont exist until frame is finished, therefore destroyer system wont be able to destroy it because it doesnt exist yet
delete event at BeginInitializationECB, create events at EndInitializationECB ?๐ค
If you only want it to exist for one frame then in your producing system you do: Destroy all existing events, then produce events
@opaque ledge ah wait, you instantly create and delete the same entity in the same ecb?
can I do that?
i dont instantly create it, i create it using ECB
yeah the instantly is completly wrong there ๐
@warped trail You don't need to create/destroy at different times. Just destroy first, then create immediately after
but how can I destroy it before it exists?
I don't know the entity id yet
and I can't change in which order the ecb does stuff?
That's what querying is for
can you control when you destroy/delete entities via same ECB?
yeah if you could just give the command to destroy first and then create in the same ecb, that would be perfect
That's what I'm doing with my tags
So something like:
EventProducerIssuedCreation->BunchOfSystems->EventReader(Couldnt read because event entity is not yet exist)->EventDestroyer(Didnt destroy because event entity is not created yet)->ECB(Event entity is created)->FrameFinished->BunchOfSystems->EventDestroyer(Issued destruction at ECV)->EventReader(Read successful because event entity is not yet destroyed)->ECB(Event entity is destroyed)->FrameFinished
@zenith wyvern if i ecb.Create(entity) in one job and ecb.destroy(query) in another job(but parallel to the first one) what will be executed first?๐ค
yeah maybe I should just create in BeginInitializationEntityCommandBufferSystem ecb and delete in EndPresentationEntityCommandBufferSystem
yep basically
one automatically introduced a one-frame lag this way
but I have no other good idea
@junior fjord vice versa ๐
why vice versa?
because your event producer runs in between
@warped trail Well in your scenario you are running them in parallel so it's impossible to know. I'm saying you would do something like this:
var ecb = _endSimBarrier.CreateCommandBuffer();
ecb.RemoveComponent<EventTag>(_eventQuery);
// Produce events here via same ECB
Ensure you destroy first then immediately produce
does the normal unity stuff run outside the ecs loop?
@fallow mason
if my event producer runs in dots, and creates in EndPresentationEntityCommandBufferSystem, then immeadiatly deletes in next frame start BeginInitializationEntityCommandBufferSystem , how would that work?
or are you talking about user events (when does MB.Update happen in the loop actually?)
delete every old event before EndPresentationEntityCommandBufferSystem in system, and new events will be created at EndPresentationEntityCommandBufferSystem
yeah or you delete in EndPresentationEntityCommandBufferSystem and create new ones in BeginInitializationEntityCommandBufferSystem right afterwards
thats the same thing or not?
Begin is before End ๐
begin of next frame
can't I get the begin of the next frame?
Never tried until now
Yes if you use the begin buffer inside SimulationGroup it will be played back next frame
oh, didn't see Presentation part, this names are so long๐
only thing to optimize is the one frame lag in this method
but for a strategy game that is probably irrelevant
as long as I won't become the next starcraft which is of course possible
๐
thanks for all the help
The discussion clarified that for me too, you should always produce events in a BeginSim buffer and destroy them in EndSim buffer. Pretty obvious now that I think about it but I was mindflooding myself hard trying to work out these damn system dependencies
yeah stuff is often so obvious afterwards
but why beginSim/endSim not beginFrame/endFrame?
I have some systems running in initialization and presentation because I wanted the free sync points
without creating some myself ๐
I guess you could use BeginInit buffer and EndPresentation buffer
Depends where you need the event to be processed I guess
i update simgroup at fixed rate, and I'm basically leaving some work to frame where simgroup won't be updated๐
err shouldn't always produce events in beginsim though right? if you want something to happen the same frame that you broadcast the event but require systems to run before knowing whether to broadcast or not
just case-dependent
yeah I will also need to update some systems on a fixed rate, how do you do it @warped trail ? just my manually creating and ticking them?
I feel like trying to force the event to happen during the same frame is setting yourself up for too much of a headache
That's true for me at least
it doesn't need 1 frame of lag - you can e.g. still destroy event at end of sim
@junior fjord loot at fixedrateutils
for my stuff that's how I need it to work
System dependencies are already annoying enough without trying to line up asynchronous events to happen within the same frame
yeah, won't work if you have a subscriber system already run before your producer
but what if systems that ran before the event happened need to know about it @amber flicker ?
then your destroy event job should run just before it creates new ones
yeah this is exactly the solution with beginframe and endframeecb
forgot the real names
Also in my case my events are components, so if I needed it to happen the same frame i would need to force a structural change during simulation, which immediately forces all jobs to complete
Not ideal
as an example.. with my tween stuff.. say a tween has a delay of 1s before it starts.. the time system runs and updates the time of the tween, then if t = 0 let's say a 'start' tag gets added - I need to make sure e.g. an 'OnStart' event is then fired that exact frame.. same with tween completion etc - not everything requires same-frame accuracy obviously
pretend that there is no 1 frame lag, but you know what will happen 1 frame in the future๐
did
EndPresentationEntityCommandBufferSystemget renamed? rider tells me it can't find it
@junior fjord they deleted it
oh ๐
haha ok then my systems in the presentation group can't get events
but I guess they shouldn't need them anyways
or hmm, where do you guys run the systems that rebuild meshes etc?
Mine just runs in SimulationGroup
pretend that there is no 1 frame lag, but you know what will happen 1 frame in the future๐
@warped trail good way to put it on your resume ๐
I already know what this small program will output in 2 minutes
@zenith wyvern ok I had them in presentationgroup up to know since it does not fit my feeling of what should go in simulation
but I could put them there too ofc
i interpolate things, so what you see is what happened some time ago๐
๐
after i saw true smooth motion, i see jitter everywhere๐
is there a reason it is called SetComponentData in entityManager and SetComponent in the ecb?
do they do different stuff?
ah wait about the idea with deleting it in EndFrameBuffer and creating it in StartFrameBuffer, did anyone actually implement that?
BC the Entity ref you get when creating it in StartFrameBuffer is just a temporal one, and I don't think EndFrameBuffer can work with the temporatl Entity refs that StartFrameBuffer created?
just delete whole query๐
ah ok but then I need a an own deletion system right
yeah ok but that is less work than always also giving the deletion command
๐
No. _endSimBarrier.CreateCommandBuffer().RemoveComponent(_eventComponentQuery);
That can be in the same system
is there a reason it is called SetComponentData in entityManager and SetComponent in the ecb this drives me crazy :S i know it shouldn't but it does.
when you change your ecb to entitymanager and have to rename all those methods ๐
ok so basically I just need to call endSimECB.DestroyEntities(allEntitiesWithEventTag) somewhere each frame?
I hope they fix things like that while they still have a chance. There's lots of weird API stuff right now like the Job structs Schedule being different from SystemBase Schedule. Or all the ComponentSystems we have now. They should have just replaced the old ComponentSystem with what SystemBase is now
Now we're stuck with all these deprecated and confusing names for systems
@junior fjord maybe create some system which will run at the end of frame , if you have event entities ๐ค
yeah that does sound like the easiest way out
how do I make it run as late as possible?
run it in PresentationSystemGroup?
yeah ok sure
Why create a separate system? What's wrong with endSimECB.DestroyEntities(allEntitiesWithEventTag)?
where do you run that command @zenith wyvern
Yeah I agree @zenith wyvern if there's any time to have breaking changes it's now when no one should be using this for production. Just kill ComponentSystem and require it to be SystemBase.
basically it doesnt make a difference I guess
why create ecb if you don't have to?๐
Less code to write
Also confusing to have both when everyone is trying to learn
where do you run that command @zenith wyvern
@junior fjord
Wherever, I would put it in whatever system produces your events
there are multiple systems
but yeah I can just put it somewhere ๐
are command buffers so expensive? If the sync point already exists anyways?
I mean the update loop of the deletion system would also have to be run
No, the expensive part is the actual structural changes. Creating the command buffers and playing them back is almost nothing
And what's this SystemBase nonsense. Should just be called System imo ๐
@fallow mason Yeaeaahh... the actual base class is ComponentSystemBase, but ComponentSystem is now deprecated, and SystemBase isn't actually a base class at all.
Quite a mess
How do you solve the problem with Player Input? I have an InputSystem collecting Input. And I have a VelocitySystem calculating velocity. But I want that system to calculate the velocity of every Entity with a velocity component, including the player.
But the velocity of the player is dependend on the Player Input and the velocity of every other entity is dependend on a "target".
I could use ```cs
if(playerInput.Exists(entity))
But that seems very inefficient to me when iterating over a large number of entities.
I am considering splitting up the VelocitySystem into two, one for the player and one for every other entity. What do you think?
Splitting the velocity calculation into two systems is how I do it. Players calculate velocity differently from ai, it's that simple I think
Thanks ๐ might be the best idea
where do you guys dispose your nativearrays? is there an easy way to just wait until all jobs are done and then dispose all?
.Dispose(JobHandle)๐
@formal scaffold I don't know if this is possible with your game, but you could convert the player input into a target. Both my player and npcs use targets and share one movement system.
@warped trail but what do you input as jobhandle? Do you actually check for each nativearray which job is the last one using it?
my input is just a mouse click which creates a target where I click, but WASD keys could create a target at the player position + float.forward, right, etc
I have quite a few global nativearrays that store data about the tiles since that seemed way easier than putting the data in chunks and with a good indexing scheme it should even be more performant than having it in chunks
Hmm thanks for the Idea, I haven't considered that. Sounds just as good I'll think about it
where possible i use a persistent NativeList and resize it to whatever size array i need and copy, since they can be implicitly converted to NativeArray.
I have quite a few global nativearrays that store data about the tiles since that seemed way easier than putting the data in chunks and with a good indexing scheme it should even be more performant than having it in chunks
@junior fjord
For a global array you can use EntityManager.CompleteAllJobs() before you dispose
Hey all, I'm at the start of working on an AI framework for my project and am planning to go with a Utility Based AI framework. Having some trouble figuring out how to structure things for ECS. I'm trying to keep the option for modding open, and ideally even runtime editing if possible.
To get into more specifics, with Utility Based AI, agents have a list of actions they're allowed to complete. Actions have a list of considerations that get evaluated to determine how good that specific action is compared to all the others. So, agents have a list of actions, actions have a list of considerations.
Adding the list of actions to agents is easy enough using a DynamicBuffer. What I'm struggling to figure out is the best way to handle the case of nested lists like in my situation. My first thought is to make actions into entities with their own dynamic buffer that stores the list of considerations, but I'm not sure if this is an appropriate use of entities? Actions will be more-or-less persistent, with some created/destroyed occasionally. Won't be an every frame kind of thing.
@zenith wyvern thanks!
@verbal pewter Are the "considerations" things that you author once or are they created on the fly? You could just make your actions into BlobAssets, which can have nested lists
Or you could store a FixedList of considerations in your Actions
I also think that if the actions are persistent and are shared between agents, then having action entities could be the right way
or build your own data structure to house that kind of data if you cant flatten it into a 1d array or a collection of 1d arrays
If you've figured out how you want the modding side to work, IE how you're actually going to author your actions in the editor, that should better inform the best way to represent it in ECS
I have no idea on how to approach modding in general. What should I think about to make my game moddable?
I worked with a modding system that was pretty flexible; they used roslyn compiler to pickup .cs files in a sub-directory that implement an interface.
@zenith wyvern Considerations are hard coded, but I need to store and pass settings info for each consideration instance. So, the logic of them is shared between all considerations of the same type, but the result depends on the settings that are passed which get assigned once when the Action is created.
I'll need to look into BlobAssets a bit more then. Not super familiar with them.
As for FixedList, from my understanding the type used needs to implement ICompareable. There's no obvious way to compare to compare considerations (unless I've misunderstood ICompareable completely).
And, yeah, it's too early to say about the modding framework. I'm still in early days on this and am just trying to prevent myself from coding myself into a corner down the line.
The type used in FixedList doesn't have any constraints aside from being unmanaged
how can unity warn me that a nativearray has not been disposed, allthough I have set it in one of my static global classes?
it has not been disposed since I am still using it
but there also still is the reference, since Globals.Array points to it
@junior fjord Hmmmm, that's a good point. I think ideally the actions would be shared within each agent type, since they'd have the same settings. I'm not 100% certain right this moment, but I don't think I need to store any entity specific data in an action. Need to get a little further along on this to be sure though.
@junior fjord From my understanding the editor should throw an error in play mode, right?
yes it throws an error but I don't understand why
the nativearray still has references pointed to it, so why should I deallocate it
Ah sorry, I misread your question.
@verbal pewter
I have very primitive AI, but maybe the idea can help
I have bunch of 'request' systems and 'action' systems,
request makes a request to brain that their action should be done, my request struct is basically an enum and an int for priorty
action has WithAll paramater according to what enum they represent, so my idle request is State1, so my idle action has WithAll<State1>
My trade space ship has 2 states for example:
Idle request giving request Request{enum=State1, priority=1} at every frame
Avoid enemy request giving Request{enum=State2, priority=2} when there is an enemy in vicinity
So i am giving these requests to a dynamic array
So in my brain system basically inspect that dynamic array and chooses the action that has most priority, It checks if previous action is the same action, if so then it does nothing, if different than it removes previous action's tag and adds the new action's tag and thats it.
Also enum indicates state's tag, So enum.State1 represets State1Tag, enum.State2 represents State2Tag etc..
@verbal pewter if your actions don't change through the game and are read-only you could also just do an array with the action information and have the entities store indexes into the array
its however kinda hardcoded, but not the action/requests themselves, they just represent a tag component so your ai can be driven by WithAll, WithNone parameters
@junior fjord Yeah that's a good point. I've done that for some other "settings" data structures. Gotta work a bit further to see if that's possible. Definitely better than creating entities if I don't have to.
@opaque ledge Thanks for the idea. I'm pretty set on going with a utility based AI approach atm.
idk what utility based exactly, but yeah hope it helps
Hmm, sorry so many Questions toaday but im still learning ๐
I want my MovementSystem to be dependend on my RotationSystem in a way that. When rotation is > 150ยฐ, don't update Movement for that Entity.
I did read about Write Groups and I was wondering how you do it? Meaning one System being dependend on another?
I would add a component to that Entity and my MovementSystem wont update because the Entity is now in a WriteGroup
i think WriteGroup is more for based on existence of certain components, not based on the values of certain components
The RotationSystem would add an empty "WaitForRotation" component. Haven't thought further because i'm unsure if this is a good approach
You probably could have a component just for this issue, your rotation system could set a flag(bool) in that component, and your movement system could read that flag and update or not
@formal scaffold i think it will be faster to just cs if(rotation > 150ยฐ) return; ///Your Update movement code
I'm worried about the overhead that adding / removing of components on entities causes. I would certainly use the EntityCommandBuffer for that but still. I somehow need to wait and it has to be two systems not one
@warped trail That would cause the problem next frame tho since I update the angle every frame. Once I am below 150ยฐ I would move again.
I want to rotate fully, then move, once at desired rotation
once you get your rotation > 150ยฐ you don't want to move until you get your rotation to 0ยฐ ?
Yeah I want to restrain movement basicly on 180ยฐ turns. So far I manage it like this
if (angle > 150) {
waitForRotation = true;
velocity.Linear = float3.zero;
}
if(!waitForRotation) {
rotation.Value = math.slerp(rotation.Value, targetRotation, 0.1f);
velocity.Linear = math.lerp(velocity.Linear, direction * magnitude * movementSpeed, 0.1f);
} else {
var currentRotation = rotation.Value;
rotation.Value = Quaternion.RotateTowards(rotation.Value, targetRotation, 40);
if (rotation.Value.value.y == targetRotation.value.y) {
waitForRotation = false;
}
}
Still ugly code but basicly,
angle > 150 -> wait for rotation -> rotate to target position -> move again
Works quite well so far but I have to split this code into two systems
you can create waitForRotation component and make movement foreach .WithNone<waitForRotation >๐ค
but is it worth it?๐ค
@zenith wyvern Hmm, I'm away from my computer so I'll have to dig into it later, but I tried playing around with them a while back and came to that conclusion about the ICompareable requirement. Can't remember the context that led me to that though, sorry. Before shutting down for the day I had a "there's no boxing conversion" error on the struct I tried using as the type of the FixedList. I was done for the day so I didn't get into it any further.
can't you just in Rotation rotation in your movement system and just do the same checks in both systems?
I guess you'll need the target angle too
Not sure, I would do that with every NPC, Enemy and player in the game. I wouldn't have to Iterate over those Entities, meaning I gain perfomance. But I create overhead by adding/removing those components within the EntityCommandBuffer.
As of right now I have an If() check every frame for every Entity that moves. Some time ago I read here that If() checks slow down Jobs and or Systems, So I'm worried about that too
premature optimization is evil๐
I know ๐ but I can't help it. If I learn about the Pros and Cons now, in my mind, I will be faster in the future.
It's hard tho, feels like 99% thinking and 1% coding๐
Just focus on writing code that works and is easy for you to understand. Worry about performance when you have solid knowledge of the tools - and more importantly when there is an actual tangible performance problem
ALWAYS make your code run properly first, worry about performance later
i think you are trying to solve nonexistent problem๐
Maybe you are right I will try to focus more on writing understandable code.
so is the visual scripting for DOTS supposed to use GO/MB terminology and do DOTS things behind the scenes?
its for DOTS
Right. But there are no nodes that use any dots terminology. Instead it's things like gameobjects parents, getcomponent, etc.
oh, i wouldnt know of that, havent tried
there is like 0 thing from ecs๐
this new thing is like visual scripting for monobehaviour๐ค
๐ค
I thought I'd be able to visually design systems. Maybe it's going to be a way for people to get DOTS benefits without learning new paradigm? No idea how they're going to convert data that hasn't been prepared for it though.
yeaah, i just read awesomedata's posts, it kinda made me sad a little
Which posts do you mean @opaque ledge?
about drop 8 in forums
no idea if it's really bad tho, would need to test it oneself to make that call
if there's anything I've learned in past years is that people always resist change
so if they've gotten used to something, new approach will always put them off
I knew it! I could have sworn there was a shader graph style output or input bar in a previous version.
you can't do any ecs stuff with this new drop๐
In order to iterate at a better pace we came to the conclusion that we needed to put aside codegen at least temporarily. We are not sure yet if we will bring it back as originally implemented since we have other very performant options that we would like to evaluate first.
Yeah from my tests, I have no idea how I would design equivalent functionality of my current systems in the visual editor. There just simply aren't the necessary nodes.
Also, this is very "anti-DOTS": Also temporarily ignoring performance optimization and focusing on the feature set.
We want to converge back to that kind of feature eventually, but we've been focusing on actual usecases from real world clients/users, hence the current feature set. ```
I totally hate this mindset for the design
UE4's blueprints strength is that it's like actual programming language, things you do there translate to text based coding almost 1:1, just with less boilerplate
So they weren't forgetting to mention the visual editor was DOTS only in the roadmap video lol
if you need to "dummify" and create higher level thing, you could just have helper functions
that being said, UE4 does do some things on their bluprints like this, basically implement some feats on single node that would take 10 lines of c++ normally
meet new Object Oriented Technology Stack ๐
I'm just happy I never really cared much of the visual scripting in the first place ๐
OOTS has a nice ring to it
only reason to want it in past would have been to get less boilerplate
but current DOTS is getting that aspect quite covered now
is just dropping ecs stuff for gameobjects just to test the actual flow of the visual scripting?
Definitely possible. DOTS is a moving target. MBs are mature and the API is unlikely to change much. Better candidate for something like this in early development.
any npm experts here? my google fu is failing me on how to list all package on the registry
I can poll individual packages if I know their names
also totally not a topic for DOTS specifically (but I'm mainly using this to poll DOTS packages)
can you parse that JSON that Topher posted to gather the names and poll for each?
I can but I can also use npm to get the info easier
- actually download the packages so I can automatically extract changelogs etc
Disclaimer: not at all an NPM expert, but decent at google: replicate? https://stackoverflow.com/questions/48251633/list-all-public-packages-in-the-npm-registry
For research purposes, I'd like to list all the packages that are available on npm. How can I do this?
Some old docs at https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-all men...
that was like first google hit when I tried to search it ๐
and nope. it doesn't work
for tiny it would be simple as they got https://packages.unity.com/com.unity.tiny.all
hmm i see
anyway, there is a command to actually list all these on commandline
I've done it in past but I can't remember the command :/
can blob assets hold ScriptableObject/Object references?
you'd probably have to pin them
not the end of the world, they're actual asset files
yeah.. you're right come to think of it, if they're treated anything like GameObjects and components.. which are they're native side allocated and don't seem to move. I once mapped out the struct for Transform in x64dbg and i didn't see it move at all.
Hmm anyone seen this error before?
Something went wrong while Post Processing the assembly (Arena.Server.dll) :
Object reference not set to an instance of an object
at Mono.Cecil.ImportGenericContext.TypeParameter (System.String type, System.Int32 position) [0x00000] in <58b86858c52b4b5fbb6efedd16c9c16a>:0
...
at Unity.Entities.CodeGen.PropertyBagPostProcessor+GeneratedPropertyBag.GenerateStaticFields () [0x003cc] in D:\Documents\Projects\Unity\ProjectArenaServer\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities.CodeGen\PropertyBags\PropertyBagsPostProcessor.cs:501
Happens to only be an issue during a build process :/
@dull copper Maybe you can use this and use this and search for everything? https://docs.npmjs.com/cli-commands/search.html
https://www.udemy.com/course/unitydots/ this just dropped today
The first few videos are free still https://www.youtube.com/playlist?list=PLi-ukGVOag_129NcrH5nHtgvkHBlSAwNk
this new visual scripting stuff is terribly disappointing. After years of development and the scramble to switch to a conversion workflow, I had an inkling that things might go this way, but was hoping that it wouldn't be the case...
this casts a big shadow of doubt to the future of dots for me, it feels like compromises will not simply end with visual scripting
even if it was alpha and clunky, I had high hopes for dots. I still do, but I've seen this picture too many times in unity (UI, networking, input, etc)
things are getting scaled back repeatedly? First it was full dots, then it was conversion workflow, now no dots terminology in visual scripting. I think it isn't a stretch to worry about other things getting scaled back at this point.
I remember there were talks of doing full dots editor with dots specific authoring tools, piggy backing on the project tiny, conversion workflow was brought in later, then it became the primary focus
gameobjects themselves aren't inherently scalable, they are just one way of authoring
if you want to ignore my point entirely and completely disregard the unity's trackrecord of scaling things back, well, more power to you
but this new visual scripting is looking just like dropping a new entity in the editor and pressing play๐
| even if we had 0 game objects, it would still be authoring data -> entities
there is a big difference between relying on clunky gameobject workflow and authoring data
all DOTS talks is like Don't think about objects, think about data, all mentions about visual scripting is It is built specifically for DOTS. And what i see in current release of VS Don't think about data, think about objects ๐ค
the conversion workflow is inferior both in authoring and in gameplay coding since it requires extra steps that require specific knowledge to get through the edge cases. And edge cases happen a lot in game development
the first design that tried to make things entity oriented wouldn't have had those problems baked in
you would still have great authoring and great programming experience without the additional gameobject layer that is thrown in
yes, thats right, it was a dots editor
and that was, guess what, gasp scaled back
not necessarily, if unity went all in like they said they would, there would've been bigger changes
instead, unity developed it along side new ui, new asset management, new input, but made those things completely non-dots
development has been going on for nearly 3 years now
just when everyone thought things were ramoing up, bam, conversion workflow
I have issues when it comes to conversion workflow, it is too clunky and too detached from the dots code. One of the primary strengths of Unity and C# was the near 1:1 relationship between authoring and coding
now I have to guess what is happening on the background and go in and decipher
sure that'll get better with time, but honestly I really don't like the idea of managing edge cases all the way to the heaven
well, you keep ignoring my points and keep going on with your what aboutism
one problem with the authoring workflow is having to dynamically convert prefabs
or use the subscenes
would be nice to have a ecs native prefab
the main issue i see with it is the general jank of it
you go from old unity, of plopping a game object and giving it a comp
vs making sure to have the subscenes and live link and conversion properly set
conversion is still very useful for a lot of things like static objects, but needing to do it for everything is not best workflow
or well, just look at Entitas and compare usability
pretty much. Or at least close-ish
thats one of the main reasons people like unity after all
of course, but i wonder whats the decision against having something like entitas does, which seems not so hard to do (i mean entitas code is not that hard), and yet solves hybrid fairly well
it would act as a stepping stone for teams
for reference
from the 2015 presentation on entitas
it makes hybrid massively easier
the only 'problem' i have right now is i cant create entity prefab, my workflow is like this, i create a MB and in it's start method i convert game object to an entity thru conversation utility and put it into shared static to be able to use it inside a bursted job, but i heard run time conversation will be dropped later on so my workflow wont work when that happens
what i personally think would be a great way to do it, is to start with this sort of "hybrid" component, where you can add ecs components into a normal gameobject, to simplify hybrid. After it, if possible, have entities as a "separated" object in the normal editor. So you can either create a gameobject, or an entity, and the editing is almost the same. Polish conversion workflow alongside it
@digital scarab eagerly awaiting for the prefab thing ๐
Same
I keep seeing unity people saying the 1:1 entity creation workflow would be less performant, but I simply don't understand the reasoning. Sure there would be processing overhead in the editor but the data representation would still be the same and we're already told to profile in the player ๐
@fallow mason there is a lot of fun stuff you do in the conversion
conversion being natively supported is actually great
unreal doesnt have this and its harmed by it
Like creating multiple icds with one authoring comp, you mean?
obvious example is imagine you have a survival game, where you have a massive forest in the editor. This forest uses individual game objects per tree, just so the trees can be cut and are dynamic
on conversion workflow
fuck that
you convert the entire forest into an octree
and pool the actual renderables
so instead of having to load a lot of game objects, you save the "presets" of the trees in a table, and the locations in some sort of flattened octree
then at runtime, you load this flattened binary octree + the preset table, and "stream" the trees around the player, by actually instantiating stuff only in a radius
and using inpostors for far away
you cant do this on unreal at the moment, not natively without custom editor tools. Makes you wonder why Ark and Conan perform as bad as they do
That is cool. I'm not advocating the removal of conversion. It's worked well for me. Just that there are some cases where it would be better to just construct the entity directly in the editor.
constructing directly is basically how its going to be for a big mayority of things
another of the things you can do on conversion workflow, is that when you add an "enemy" to the map, it doesnt save the enemy. It just saves the point. The enemy gets spawned and activated when the player gets close
lots of fun things like that can be done
@bright sentinel that was the second google hit ๐
I think that's the right command, but Unity's npm registry doesn't seem to support it
or alternatively the tool I have misses something
all in all, it can't search anything from unity's registry
also re: conversion workflow, I totally dislike it. If it would actually work nicely with DOTS packages, like even with Unity physics, I'd be ok with it as intermediate step to some future DOTS editor in few upcoming years (it's very clear we are not getting it any time soon)
it's just, this thing breaks in all directions on my use and I keep constantly fighting the conversion stuff
it's like the single biggest time consuming thing on DOTS atm
I can totally see why most advanced users try to avoid it and write authoring tools that bypass the whole conversion, it's just not a great workflow at all
I wouldn't be surprised if stuff like this will keep majority of Unity users away from DOTS, either people try it and find it cumbersome or other users who use it warn them about this stuff and they don't even try it. Something has to change
thus why i think something like what entitas has (easy way to add a sibling entity with comps to a gameobject) is a great stepping point
Are you guys converting subscenes or prefabs?
allows people to add some components for small stuff incrementally
dots subscenes break in all directions with current physics stuff so I'm not touching them until they can stabilize it more
which totally sucks and DOTS editor packages live entity conversion preview (not to be confused with the full ecs editor concept) only works in DOTS subscenes
does DOTS subscenes now support those experimental hybrid gameobjects?
because in past, having no GO's on subscene was a huge PITA if you needed to still use gameobjects
also remember that you can't even do cross scene references so you can't ref GO's on GO scene from DOTS subscene (this isn't DOTS related limitation, it's just limitation in general in unity between subscenes)
that sort of thing is perfectly normal
subscenes only hold references to inside stuff
without that it becomes a huge mess
IMO this current setup already is ๐ค
anyway, it's kinda hard to judge current state of DOTS as it's clearly still really wip and raw
would realistically need to wait for 2-3 more years and then see where they end up
it just feels that they have to do something to keep people still interested on this
there were some DOTS talks by mike acton on gdc that got cancelled ๐ฆ
my main concern is a lack of tools to quickly create components, which i can just drag and drop to objects in scene
was specially hyped for the "how to make an ECS" one
as that could explain some of the design decisions unity has
i have to block Unity's compilation to create some scripts without waiting ๐
The main annoyance for me is having to either write a conversion script (that often just straight copies the MB value to the ICD) or write a script that creates an entity from archtype on start, just to have an entity with some component data in there when I press play.
And yes, the other option is GenerateAuthoring, but the drawback with that is you can't have all these little components in one file.
All to say it's not a deal breaker, but it sure is annoying that I can't just add icds to an entity like I can add MBs to a GO.
My frustration is the lack of wider integration. How do you handle integration with UI? sound? cameras? animation? asset streaming/bundles/updates? there are very few viable connecting pieces right now. Maniuplating shaders in URP is finally coming for us which im excited about. But its the holes everywhere that you start to fall into once you get beyond spawning a million cubes.
Is there a release date for 0.9.0? Its really frustrating that Android is failing to compile in 0.8.0.
When using an ECB in a job, can I still delete the entityQuery as soon as OnUpdate starts (ie does the int entityInQueryIndex require the entityQuery to still be around?)
why not try it and find out?
Only because I'm mid refactor and have quite a long way to go before I get back to a testable point, just wondered if anyone knew off the top of their head
entityQuery will be destroyed when you playback ECB๐ค
In my old systems, I was using eg:
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
EntityManager.DestroyEntity(entityQuery)
//Then do stuff so it only happens once
}
just confused now I'm switching things over to SystemBase with this enforced name int entityInQueryIndex - if I've already used the EntityManager to delete the query above the job, does that affect this index that the ECB uses for playback?
I guess it boils down to: can I be guaranteed that the ECB playback will happen all within one frame, ie before the next OnUpdate is called if I switch over to destroy the entity within the ECB instead of the above method?
no it doesn't, but I could switch to SingletonEntity for these specific message/event entities or at worst case for loop over the NativeArray after dumping the entity queries to array async
well yes, basically ECB is same with any structral changes, except that it happens to in at a later time
a later time still guaranteed to be in the same frame?
if you use EndCommandBuffer, yes
thanks that's champion
it depends on which sync point you choose
EndSimulationEntityCommandBufferSystem most likely for this one
yep
if your system will run before EndSimulationEntityCommandBufferSystem, then yes it will happen in same frame
yup, that's grand thanks guys
not concurent version of ecb accepts entityquery
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var ecb = ecbSystem.CreateCommandBuffer();
ecb .DestroyEntity(entityQuery)
//Then do stuff so it only happens once
}```
has now become:
protected override void OnUpdate()
{
var commandBuffer = ecbBufferSystem.CreateCommandBuffer();
...
Entities
.ForEach((...)=>
{
//stuff
commandBuffer.DestroyEntity(playerChemUpdateQuery);
Entity a = commandBuffer.CreateEntity();
commandBuffer.AddComponent(a, new PlayerResizingEvent());
})
.Schedule();
ecbBufferSystem.AddJobHandleForProducer(Dependency);
i think this should be outside of ForEachcs commandBuffer.DestroyEntity(playerChemUpdateQuery);
not sure I follow how that would go, gimme a sec I'm close to setting the first pass of all systems converted to SystemBase done, then I'll know whether it'll build or not ๐
protected override void OnUpdate()
{
var commandBuffer = ecbBufferSystem.CreateCommandBuffer();
commandBuffer.DestroyEntity(playerChemUpdateQuery);
var commandBufferA = ecbBufferSystem.CreateCommandBuffer().ToConcurent();
...
Entities
.ForEach((...)=>
{
//stuff
Entity a = commandBufferA.CreateEntity();
commandBufferA.AddComponent(a, new PlayerResizingEvent());
})
.Schedule();
ecbBufferSystem.AddJobHandleForProducer(Dependency);
}```
ahh okay, so it should pick up the dependency info it needs automatically?
Hello! Having fun in not understanding how to use SharedStatic<T>. Any lead?
im wondering wouldn't using native stream be a better idea for events?๐ค
So its basically a 'field' that you can set/read both from managed code and from bursted jobs @scarlet inlet
construction is kinda weird looking, but its basically a copy paste operation
yes I am not sure how to use it, it crashes on me all the time
C:\Prgdir\Svelto\Svelto.MiniExamples\Example1-DoofusesMustEat\Iteration3-Jobs\Assets\Svelto\Svelto.ECS\EntityBuilder.cs(171,13): Burst error BC0102: Unexpected internal compiler error while processing function IL_0001: ldflda Svelto.ECS.SharedStatic1<System.UInt32> Svelto.ECS.EntityComponentIDMap::ID`: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
@warped trail not sure what you are talking about because I didn't follow, but I use a publish/consumer model for events. It's still polling, in the sense that the system interested in "listening" must poll its queue of published events
however I must say that I don't publish random data, I publish a copy of the entity component
so it becomes also an historic streaming of the entity component values
entityInQueryIndex is just like the older job index, basically just the index from the for loop going over the entities. the thing about it being played back is it isn't a ref int or a int*. your making a copy of that int and writing it to the ecb's buffer when you call that function on it requiring the index. @wary anchor
thanks for the explanation @low tangle!
@scarlet inlet ive used it a few times, https://gist.github.com/jeffvella/8ac73ba00552998b66140a886646a234 its an older script, they since have made the normal typeManager native accessible by using SharedStatic, and introduced Unsafe version of the map so i wouldn't have to rip out the safety
thank you! was waiting for your reply ๐ I just need a static uint
what I am doing it's not hard and actually burst would read from a readonly static variable, but this static variable value is set from another not readonly static variable and Burst doesn't like it
I understand that it's because c# and burst static values won't coincide, which makes sense
///used in burst
static class EntityComponentID<T>
{
///used in burst
public static readonly uint ID;
///not used in burst
static EntityComponentID()
{
ID = EntityComponentIDMap.NextID();
}
}
///NOT used from burst
static class EntityComponentIDMap
{
//the only bit potentially used by burst
internal static uint NextID()
{
return ID.value.Data++;
}
static readonly SharedStatic<uint> ID = new SharedStatic<uint>();
}
class SharedStatic<T> where T : struct
{
public Unity.Burst.SharedStatic<T> value =
Unity.Burst.SharedStatic<T>.GetOrCreate<Key>();
public SharedStatic()
{
value.Data = default;
}
class Key { }
}
the second bit is random code, still didn't figure it out @mint iron ๐
this is how Unity uses it for TypeManager
private sealed class TypeManagerKeyContext { }
private sealed class SharedTypeInfo
{
public static readonly SharedStatic<System.IntPtr> Ref = SharedStatic<System.IntPtr>.GetOrCreate<TypeManagerKeyContext, SharedTypeInfo>();
}
internal unsafe static TypeInfo* GetTypeInfoPointer()
{
return (TypeInfo*)(void*)SharedTypeInfo.Ref.Data;
}
public unsafe static TypeInfo GetTypeInfo<T>()
{
return GetTypeInfoPointer()[GetTypeIndex<T>() & 0xFFFFFF];
}
lemme see if i can adapt this to your situation
talking to me?
yeah
yeah basically I need to map a type to an ID like it's done in the unity code
but these types are not built really at run time, they could be theoretically at compilation time, but since such a thing doesn't exists in c#, they are created in static constructor. Once for each applicaiton run.
this means that the ID must be static too, but burst doesn't like ID whose value can change
what is a 'type' in your context?
Are there any learning resources for netcode other than the docs and sample project? They're pretty sparsely documented :/
just wondering why structs would need IDs like that ๐
trying to do some weird generic code with burst or something?
hehe yes it's weird if you want to put in that way. However the point is that I need to store some types from burst code, but since burst can't use Type, I need to map them to IDs
but what I am doing is definitively not common
@mint iron I finally understood the reason of the context btw
@bright sentinel https://www.reddit.com/r/GlobalOffensive/comments/6yij1l/the_grand_post_of_csgo_network_code/ I did come across pinning this post a while back - it doesn't exactly teach you - but it explains some of the concepts ๐ค
how do u edit component system parameters in editor?
whats the reason, im still not sure i get whats going on here.
@coarse turtle Hahaha see who made the post ๐
my understanding is to have an unique static object. if it was just <uint> it would be the same static object for all the <uint> SharedStatic. Anyway I am still getting errors: C:\Prgdir\Svelto\Svelto.MiniExamples\Example1-DoofusesMustEat\Iteration3-Jobs\Assets\Svelto\Svelto.ECS\EntityBuilder.cs(171,13): Burst error BC1042: The managed class type Unity.Burst.SharedStatic1<System.UInt32>*is not supported. Loading from a non-readonly static fieldSvelto.ECS.SharedStatic2<uint,Svelto.ECS.EntityComponentIDMap.Context>.value is not supported
Just wanted to say a big THANK YOU! to the many of you gurus who helped me update my old 0.5 code to 0.8.0 and get rid of some bad practices along the way. I'm back to a working build in a little under 2 half days with your help. You guys are awesome! Have a video update of where I am now ๐
that error is unexpected ๐
looks nice ๐
nice @wary anchor
My problem isn't so much the high-level stuff, more about how to get it done with ECS NetCode
thanks!
@wary anchor thats stunning, very nice job
working on the UI now, it's half updated, but boy there';s so much work to do
It's the same for me @bright sentinel - going to revisit how my side is done ๐ค
but im just using the low level transport layer - not necessarily the netcode package on top of it
Ah okay
lmk if u find good samples @bright sentinel
im thinking about peer to peer multiplayer
Well I know that netcode doesn't really support that yet
where one player acts as a host
Because they're focusing on server authoritative stuff
Oh
Maybe that's possible
Ya that should be possible with NetCode
But actual p2p isn't
well technically you can make the host player boot up a server ๐ค
i guess host is technically a server
Yeah exactly. But they do plan on having actual P2P with lockstep etc in the future
That was on the roadmap last time
But maybe there's something new in 45 minutes ๐
Join us on Wednesday, April 1 at 9 am PDT for the second installment of our 2020 roadmap, Unity 2020: Live Games.
We know you'll have a lot of questions about this roadmap, so we're hosting a Q&A on the Unity forum following the session. Product experts from across Unity wil...
Make sure to tune in
Seems like it's relevant for us ๐
in the future ๐
are you australian @wary anchor ?
Bummer, I thought this would at least partly be about their networking package, it seems it's only about their analytical tools and microtransaction game tools
๐
did roadmap vid just end?
Yea lmao
yeah
i just started watching ๐
any highlights for the lazy of us?
well, it is April Fools day, so it could all be a joke
any highlights for the lazy of us?
@amber flicker
There was nothing dots related
Pretty disappointed with what they chose to come up with after GDC got cancelled. As far as the dots stuff it seems like a fraction of a fraction of the information we would have gotten from the actual gdc talks.
I don't think this was supposed to be the GDC replacement though
I was just thinking that @zenith wyvern. No way they would have gotten up on stage and only showed this.
anyone tried out new platforms package btw ? last time i tried it was giving full of errors, or should i just stay at 0.2.1
If these roadmaps were not intended to be the replacement for what we would have seen at GDC then I will be happy to be wrong
seems like they are holding out on us ๐ฆ
anyone else disappointed ๐
unreal is even more of a dissapointm,ent
but holding out hope that there's more talks coming
they cancelled everything
and there were some seriously hype talks and announcements
what we really need is a roadmap for the planned talks lol
for example, very likely to show their new ecs stuff
is it possible to do chunk iteration on managed objects?
it was possible with the old componentsystem a while ago(then they changed it so you couldnt)
managed objects doesnt live in chunk, but you can do ForEach using component/buffer classes
old component system run on main thread
theres a nasty bug currently with foreach https://issuetracker.unity3d.com/issues/ecs-internal-native-array-is-deallocated-when-componentdatafromentity-is-captured-into-2-lambda-jobs
was wondering if i could just remake it with chunk like the old days to work around it
How to reproduce: 1. Open the attached project ("case_1207875-NativeArray.zip") 2. Open Test Runner 3. Run the 'CdfeCaptureSharing' ...
@safe lintel Is this also happening in 0.8.0?
it is for me
and it seems to be just one job(unless it means two jobs from two unrelated systems?)
wonder if this still happens using the SystemBase GetComponent, which seems to be the replacement for passing in a CDFE
hm will try that
anyway for the record, the dealloc error doesnt happen in a build, only in editor, sometimes..(so, annoying for testing)
ok nice i think that fixed it!
thanks @mint iron
I wanted just to share with you the pain that I wasn't able to crack SharedStatic<T> yet it seems to me that hasn't been designed to be used inside burst which confuses me a lot
@mint iron Don't you think it just fetches CDFE behind the scenes?
@opaque ledge I know right, but it literally says: Burst error BC1042: The managed class type Unity.Burst.SharedStatic1<System.UInt32>*` is not supported
waaaat
๐ค
I can't also imagine what alternative solution I could use, beside, maybe, a global native dictionary
should be something like
public abstract class Shared_UInt{
private class UINTKey{}
public static readonly SharedStatic<uint> uint = SharedStatic<uint>.GetOrCreate<Shared_UInt, UINTKEY>();
}
yes
I use this: not dissimilar:
class SharedStatic<T, W> where T : unmanaged
{
public static Unity.Burst.SharedStatic<T> value =
Unity.Burst.SharedStatic<T>.GetOrCreate<SharedStatic<T, W>>();
static SharedStatic()
{
value.Data = default;
}
}
wait radonly?
yeah
just copy from the burst manual really, thats what i do, its also recommended that you should give it's first value from managed side otherwise behaviour is undefined
thanks for the tip, it's not clear what calls it first. It should definitively be the managed code, but still it doesn't work with burst like if the values are screwed
perhaps its because you are doing it in a generic way ?
just do non-generic version and see how it goes
hmm that's the only thing I didn't test so yeah I'll test it
i dunno if this helps you but, what i tried **didnt **work https://gist.githubusercontent.com/jeffvella/5142541e61af0cffe4b841f2360956bd/raw/249177b763ae21b4e95c0e26752936661135dd2d/gistfile1.txt
thank 1M to test it!
that code didnt work thats why i never pasted it ๐
the numbers show up in the test all weird like 6789, 15,16,17
its like its creating multiple instances or something i dont get it
do you need control of the ID or could you just use like the runtime hash?
ahhh
well hash would be OK actually, but only if with no collision
well actually I could also not having issue with that ๐
ok what's your idea?
BurstRuntime.GetHashCode32(typeInfo.Type) / BurstRuntime.GetHashCode32<T>()
btw @opaque ledge whats the prefab issue that you had(from the discussion earlier)? to be able to create a prefab without actually referencing it in scene from another entity or something?
right didn't know those testing now
i couldnt make a entity prefab without runtime conversation basically @safe lintel i had to create a MB and in it's Start function i converted gameobjects to entities thru conversation utility and stashed them in shared static
yes @mint iron it worked! bill me now ๐
๐
hehe you also made me notice another error with this idea. Thanks for the GetHashCode I didn't know it existed
OK I bugger off now ciao!
@opaque ledge what about IDeclareReferencedPrefabs?
in the end you would get the entities you need so you can grab that and instantiate it ๐ค
Ah ๐ค
hey, can someone explain me when to use SystemBase over ComponentSystem? and is JobComponentSystem still a thing?
always use systembase, both jobcomponentsystem and componentsystem will be made obsolete some time in the future
ok cool, i was looking at using PostUpdateCommands, but that doesn't seem to still be there in systembase
what's the good way to do it? (im trying to instanciate a prefab from a system)
postupdatecommands is just a builtin helper which uses a command buffer internally afaik, you just need to create the command buffer yourself now, pretty sure its shown somewhere in the entities docs
ok , wasn't sure about that. No helper equivalent function you know about?
not as far as I know
you can use something like thatcs var postUpdateCommands = new EntityCommandBuffer(Allocator.TempJob); //Do your work postUpdateCommands.Playback(EntityManager); postUpdateCommands.Dispose()
basically the same thing
shall i create it once in the create method of the system?
i don't know๐ค
trying that right now, thanks ๐
but you have to use concurrent one, if you doing your work in jobs๐ค
oh, b4 is out๐
Entities Version: 0.0.12-preview21 ๐ง
[Inject]๐
lol
I didn't realize it was that ancient ๐
repo was just updated 18days ago for something
is there a way to instantiate a prefab from a system, and keep the gameobject counterpart, like in Convert To Entity: Convert and Inject Game Object ?
and second question: how can i change the name of an entity instantiated using a commandBuffer?
Hmm idk about the first one - but the second there is no way currently
Has anyone encountered a problem with loading a scene ? it seems like.. convert to entity scripts doesnt work on new loaded scene or doesnt register to default world properly
you need the entitymanager to be able to set the name, otherwise you can add a component which has the name of the entity ๐ค
@opaque ledge I had that problem in entities 0.7 ๐
but I upgraded to 0.8 and it worked again :/
:/
just store every prefab in subscene๐
man i havent even touched scene loading/changes ๐
thanks guys
i have a camera in 2nd scene, i need to be able to activate it once i am in that scene, but that camera isnt properly registered to defaul world
it all works fine if i add the scene to editor, but not if from code, which i need to do
this seems a little odd, its throwing exception because its invalidating the array on SetComponent, even though its a temp allocation used only here, inside structural changes block.
Entities.ForEach((ref SpawnActorEvent e) =>
{
if (_prefabs.TryGetFirstValue((int)e.Type, out var first, out var it))
{
var entities = EntityManager.Instantiate(first.Entity, e.Amount, Allocator.Temp);
for (int i = 0; i < entities.Length; i++)
{
SetComponent(entities[i], new Translation
{
Value = RandomCirclePosition(center, radius)
});
}
}
}).WithStructuralChanges().Run();
This is the first time i am maknig a build, and... there are differences between editor and actual build ๐
it only has problem with inject mode i think, other entities arent also showing in debugger but at least their system works properly
oof...I think I should take a look at mine since I'm using convert and inject ๐ฌ
i had to get UI related stuff out of my project because it wasnt building because of TMP references in managed components, now this.. ๐
just store every prefab in subscene:sweat_smile: yeah it works but im curious about the overheads because for every entity i instantiate its making 3 entities, with all sorts of scene related Ids and trackers and mumbo-jumbo.
An ECS Hybrid question. I can see that its possible to Spawn a GameObject which then gets a linked ECS entity created and synced. But can is there a way to provide an already existing entity to link it too?
that being said, this is just first one
I'm sure they'll cover DOTS on some upcoming ones
"a physical Unite event is not in the cards this year."
Meet the Devs: Input System
excited for that one. hope they go in depth.
I'd post about it in the Input System channel if there were one ๐ข
Hi, is there any way to raycast into a DOTS plane? The old Plane had a Raycast() method for that but I can't find anything analogous that can be used from a Job
I don't see anything plane-related
Just regular physics raycasts, which aren't helpful in my case
Needs to be specifically into a plane
plane-related? You cast against a collider. It doesn't matter what shape it is.
Plane doesn't have a collider
it should if you're wanting to get a hit when you raycast it
if Im understanding that page correctly, no theres no builtin equivalent that ive seen. you will just have to setup your own plane and raycast against it yourself which wouldnt be too hard
I see
They do a sphere cast using a sphere collider that's stored in a blobassetreference
just do a similar thing with a plane instead
not sure there's a 1:1 equivalent of plane.raycast in DOTS yet
Might have to do something like that
Feels like 60% of working with ECS is just workarounds, hacks and reimplementing missing features
On that note, I don't suppose there is any other built-in way of obtaining the distance between a point and a plane?
I've seen some methods in Plane but there's no documentation and the output is not what I'd expect
Is anyone running Unity 2020.1.0b3 with hybrid renderer?
https://blogs.unity3d.com/2020/04/01/were-bringing-unity-to-you-unite-now-starts-april-14/ Here's your Unity GDC ๐
just give me the slides for what was supposed to be presented at gdc
and id be happy
Anyone know how i can make a subscene GameObject into a prefab in my main world, without using IDeclareReferencedPrefabs? I thought it was working by just adding the Prefab component but there's something else going on becuase they get filtered out by the Camera.
this is how prefab component works๐ค
the prefab instantiates fine, but the new objects are not rendered
new objects?
adding prefab component to entity makes it invisible to any system, unless they explicitly query it
and this instantiated entities have all components?๐ค
yep they have components
too many components, looks like its all the sub-scene live link stuff thats probably breaking it, wondered if anyone has already jumped through these hoops, and i might be able to save myself some pain
mmm okay nothing in any subscene is rendering, so this all might be moot.
are you using things like this [ConverterVersion("joe", 1)] ๐
no, but i think i just figured it out, ... didnt have hybid renderer package.. yep that was it
facepalm
๐
not sure if anyone is interested but if you are just starting DOTS like me, maybe you will be interested for this new tutorial on Udemy by Penny de Byl who is known in Unity community, a great teacher i am sure it will be a great ressource for new learner in DOTS.
https://www.udemy.com/course/unitydots/
Is an error thrown when you try to remove a component that doesn't exist on an entity, or does it just ignore the call? Wondering if I need to use HasComponent before removing components.
I guess I'm wondering about the reverse too. If I'm adding a tag component that doesn't have any data in it, do I need to call HasComponent first or can I just add it?
having a look at that udemy tutorial
its actually damn good
unlike all ecs tutorials, the "move 20.000 objects" is only the intro to the concepts, it then continues to more complicated stuff
to show the ecs stuff on the "move 20k objects", it does a progression
spawn script + 20k monobehavior with position delta on update -> spawn script also has update loop that moves all objects -> spawn script uses IJobParallelForTransform to parallel transform the objects -> ECS
@verbal pewter afaik, no it doesnt give you an error if component doesnt exist
at least for ECB, not sure for entity manager directly
This comments for Visual scripting are pretty rough, i hope Unity will listen those issues and i hope they wont be discouraged or smth
@opaque ledge Okay thanks!
@fallow zealot issue with course like that is that it will be - if is not already - totally outdated in months
DOTS just moves so fast you can't maintain a bigger video tutorial course without the practises getting outdated almost immediately
@opaque ledge i don't think they really care about this type of feedback๐
also course like that should totally tell people which DOTS packages it's using so people would have even some idea on what to expect
it being published 3/2020 doesn't mean it even uses SystemBase for entities
well criticism is also a feedback ๐
if they had cared about such things on forum, we would got dark theme for free looong time ago๐
I think the criticism buried in a manifesto of ad hominem and condescension has to be the most annoying
@dull copper im watching it and it seems to be very good for now
this is what it uses
for now, at early-ish stages
this is already outdated ๐
yes, that's "outdated" already
SystemBase is what we should use now
that being said, a lot of things on that course are probably still very relevant
whats the point of WithName?
to have the for-each be named
to then in the debugger be able to find it easily
for benching and similar
damn people are pissed with the new visual script @dull copper
the change from vertical layout to blueprint-clone is such a huge downgrade
where on the forums?
if only layout was a problem ๐
it definitely is a massive fail to go back into oop-ish blueprintclone vs
the fun part of visual script for ecs systems is that most ECS systems tend to be very small, so it stays super readable before going into spaguetty
vertical layout also gives a lot of structure, with "execution" being vertical, while math is horizontal
for example, look at the systems of TinyRacer
most of them are some basic math and thats it. That sort of thing maps real nicely to visual script ecs, as it acts as "rules"
@vagrant surge I prefer the horizontal myself
but I can understand some of the reasons for what people are upset
i kinda liked how the vertical one was going, as it separates the "math" from the "execution" very cleanly
but yeah like mentioned earlier here, it's pretty hard to judge without trying it oneself
people tend to hate everything that's different than the previous thing
unless the new thing is all around amazing that is (which never happens)
just try it yourself, you will see why people complaining ๐
IMO none of the earlier versions I tried were even remotely usable even
new thing is basically BP
prettier nodes tho
Gotta say, I'm looking forward to the Unite Now Visual Scripting talk:
O.O.P.S: We Did It Again
You ever data driven so hard you end up object-oriented?
seems like they're not clear on who they're designing it for, is it for developers or artists/designers/ less codering people? because if its not for developers, you can't think about it like a developer.
visual script is always a selling point for artists/designers/noobs
programmers dont give a single fk about VS in general
this is for actual usecases from real world clients/users๐
design changes aside, these two are biggest red flags for me:
* In order to iterate at a better pace we came to the conclusion that we needed to put aside codegen at least temporarily. We are not sure yet if we will bring it back as originally implemented since we have other very performant options that we would like to evaluate first.
* Also temporarily ignoring performance optimization and focusing on the feature set.
if history has taught us anything, temporary solutions like these can turn into permanent ones
getting clean c# codegen was one of the biggest things that set this apart from competition IMO
(unless, they mean some other codegen here)
indeed
the codegen was a MASSIVE selling point
because now you can put it on source control
and diff it
even if the codegen is not really that stable, having a semi-readable codegen means you can diff it on your repo
this is the reason 1 why blueprints suck for big projects on unreal, that they are undiffable binary files
well, I dunno if it's that usable in that way unless it can reverse that to graph form again
how I understood that it only let you generate c# alternative for the thing(?)
doesnt need to be reversible
if the codegen is "stable", you can use it for the diffs
kinda like if it was a text representation of the graph
I don't really see how the original graph programmer could maintain it if c# feels alien ๐
the ones who are merging stuff are the programmers, not the designers/artists
and for those, being able to diff the graphs on the source editor would be huge
just to know what changed
you and your actual use cases
no, now hold on a moment. how do we know he's real world ๐ค
just commenting from working on an AAA ue4 project, where the binary-ness of the BPs is such a massive headache....
we would definitely use VS a lot more if it was diffable
for me when i see those massive graphs with 90% of it nodes just doing math on numbers and 200 lines connecting i just glaze over, it seems absolutely terrible for that sort of thing. The nodes need to actually group and simplify things or it just makes it much worse than writing code.
it allways is much worse than code, with an exception
timer based stuff and event based stuff is much better on VS
well, can't you use those placemat things? or is that not what they're for?
because on VS you can have OnEvent -> PlayAnimation -> Wait(1second)-> Explosion
are you talking about merging into a function node?
thats what i was thinking, like in blueprints, the stuff around pawns and spawning actors, events and the UI side are quite nice.
on ue4, i almost allways put events on the BP level
and then they just call cpp functions
specially if its level based stuff
at that point it becomes a useful visual by itself to document the flow of behavior.
looking at the feedback for the VS it does seem like they have some good well articulated points
hopefully they take some of it on board, I like ECS for its focus on pure data
btw, a VS that can do both well (maybe 2 modes? ) would be huge
being able to express ECS systems (simulation rules), and event based stuff
which is where the ECS fails hard
I don't feel like it fails with event based stuff how so ๐ค
due to the focus on systems instead of objects, ECS generally struggles with events
you need to do actual events, like putting them in a queue, instead of just calling a virtual function or a delegate
I still have to mess around with event's but just figured you create entity's for them, that's what I've been doing for my simple stuff so far
thats one way of doing it, for complicated events
sadly it forces sync points on the multithreading
its a really nice pattern for complex stuff, as you can process that event on multiple systems. You can do really fun things there
I'm not sure how you would entirely avoid sync points but surely that is still faster than monobehaviour
pretty sure a simple virtual call is faster than having to create entity and process it
yeah I guess that would be true ๐ค
its more about the general "flow" of the event
yes code monkey did a video on events and showed two ways, nativequeue and entity. NativeQueue was going to be much more complicated, but I bet it would be way more performant since you're not having to chunk an entity
on just a function call, you can inmediately go to reference and the likes
and then immediately delete it
on queue or entities, you can do super fancy stuff (multithreading/system processing), but its slightly harder to follow the flow
oh yeah queue is much faster
no sync point to begin with
im a really big fan of event entities, ive used them in actual commercial projects (but not with unity ecs XD)
being able to have systems process the event and do stuff is amazing
I'll have to watch that vid then, thanks
obvious example is for damage in a RPG. Your player hits an enemy, and has a flaming sword
so you create a entity with "DamageEvent(source=player, target =goblin), ElementalDamage(Fire)"
then you have a system that checks DamageEvent + ElementalDamage, and if target has elemental resistance, you lower damage
power pattern ^
then you have another system that applies target armor
also good fit for animation
then you have another system that spawns blood particles
and then you have another system that actually applies the damage and deletes the event
or you need to get the length along a spline, so you create the length component and then system finds it and calculates it for you, that's what I've used it for, it works great
if you decide to have an enemy that can reflect damage, then you create a system that checks if target has reflect damage component, and spawn another damage event
not the fastest pattern... (lots of checks around or adding/remove components), but its power is insane
this sort of logic tends to become a huge mess very quickly in a more normal oop architecture
yeah I'll probably continue to use it until I come up with performance problems
if its done for punctual events, there is no issue
I'm wondering how I would delay or queue events with it that's probably more difficult, ๐ค
by copying that event entity into a shadow world (to remove it from simulations)
and then restoring it at some point
alternatively, adding a "disabled" component to that event
yeah, I think I've seen that pattern on an episode of yugioh or something
sending stuff to the shadow realm is a power pattern in ECS
What I did is put a DelayedEvent(activationTime) on it, and than a system checks that and replaces with Event() where appropriate
that's cool
all the event handlers query for Event()
alternatively, adding a "disabled" component to that event thats what i ended up doing in my event system, because destroying entities is a very slow operation. If you can change the archetype or transfer a batch between archetypes its much faster.
writegroups can help with this type of things๐ค
there's also the structural components I guess, I mean the Isystemstatecomponents
What I had problems with is avoiding one frame delays with the normal auto-created systems (damage event spawned -> all the preprocessing, apply armor, elemental dmg modifiers etc -> damage handler sees the target has reflect on it, spawns another damage event -> no good way to apply armor to the newly spawned event without running the whole chain again
ended up actually running the systems manually until there are no more damage events left
@pliant pike here is the video I mentioned: https://www.youtube.com/watch?v=fkJ-7pqnRGo&feature=emb_title
โ
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=fkJ-7pqnRGo
Let's learn 2 ways we can handle Events in Unity DOTS! The final class is included in the Project Files.
Unity DOTS / ECS Tutorials
https://www.youtube.com/playlist?list=PLzDRvYVwl53s...
something to consider with Unity is the use of query-based entity destruction
@worldly pulsar thats common
ive seen project have a "chain" of event-systems
and they loop until there are no more events
i guess you can chain systemgroups with UpdateCallback๐ค
query based destroy is still not that fast, in fact from my testing for small numbers of entities its faster to just do them one by one.
curious to know more there, but always did the punctual event approach so had larger numbers of things
one big issue right now is that only some of the EntityManager methods go through burst routes and this might be the cause here. For example, CreateChunk() is considerably slower than it should be because it is not wired to a burst function like CreateEntity is in StructuralChanges.
just a note that query based archetype change still v fast (e.g. adding disabled tag to an event) - but that a batch method is slower than doing them individually at small numbers for some things obviously sucks
luckily its pretty easy to test, create a bunch of entities and put a stopwatch around these various delete options. for me it seemed that around 1000 entities the query took over as faster. But having said that its probably linked to how many different archetypes are used with the query components.
did you compare against ecb out of curiosity?
is that 1k entities in a single archetype, or over a lot of different archetypes?
could add all your events as buffercomponents on one entity and never destroy
yeah thats the right question, i dont remember offhand.
Question: Is it possible to use EntityManager inside the lambda function of a Entities.ForEach? I cannot seem to be able...
@mint iron were you the one who suggested to use IDeclaredReferencedPrefabs to convert stuff and stash them to shared statics ? I told that entity wasnt valid but it was, so that was a total lie lol but i think what i remembered was.. if you instantiate convert and inject entity that authoring always run for each entity you want to instantiate, so since thats the case i couldnt use your suggestion.
i also i simply solved my problem by... getting that gameobject camera that i wanted to convert and inject to my initial scene, so it works properly lol
i don't think that was me ๐ฆ but im writing a new project as an example scenario for my package and yesterday i was trying to figure out how to get an Entity Prefab from a SubScene and avoid runtime conversion, figured it out in the end!
ah, sorry to bother you with it then
@eager oracle cs Entities .WithStructuralChanges() .ForEach(()=> { }).Run();
@warped trail Is there a reason for needing that?
I mean, is creating new entities really an structural change?
What are the consequences of using ".WithStructuralChanges"?
I mean, so I understand what is really going on under the hood
@zenith wyvern i have seen your post about exclusive entity transaction, have you able to work on it ? i was wondering how it works and what kind of situation i should use it in and should i use it over ECB
it basically creates a Sync point @eager oracle Sync points is where every job has to finish and no job will be scheduled until that specific job is over, after that chunks are calculated and flow continues
so basically pauses the main thread?
something like that, think of it as a bottleneck, or a 4-lane road reduced to 1 lane ๐
so the less Sync point there is the better
But then it is not a really good solution, no...?
if your system suppose to do structral changes then go for it, and if you can use ECB that would be much better
ECB?
it also runs normal C# code; you get the benefit of the Entities.ForEach query filtering and iterating the componets you want, but there's no performance gain really.
ah, entity command buffer
Not all gameplay needs to happen immediately. In fact, there are many cases in which deferring commands may offer a better outcome โ improved user experience, performance, etc. This session explores thinking about where deferred commands are needed and provides examples on how...
Re: Visual Scripting Yes it's for DOTS only. That being said, we want to keep DOTS editing very similar to current GO editing. So even though you work in the editor with a familiar GO workflow, all is being converted to DOTS at runtime. What? How?
Well, I guess I will use it, and then see if it is performant
imo ? dont think ECB as a way to optimize your game, think of it as a foundemantal knowledge and try to use it whenever you can. Avoiding 1 sync probably wont make too much difference, but avoiding 5 or 10 can determine if your game is playable or not
By design ECS already has 6 sync points
But most of them are pretty light
Except for the simulation group, and maybe the rendering group as well
@zenith wyvern i have seen your post about exclusive entity transaction, have you able to work on it ? i was wondering how it works and what kind of situation i should use it in and should i use it over ECB
@opaque ledge
I haven't tried it yet, but I think you should use it in any case where you find structural changes on the main thread are becoming a bottleneck for you. Eizenhorn posted how to actually use it in another thread https://forum.unity.com/threads/how-to-use-exclusiveentitytransaction-entities-0-8.856711/#post-5647573
well what i was wondering is why would i use this over ECB, or rather what are the advantages/disadvantages over ECB
At least in my case structural changes are not a bottleneck for me, there are plenty of other avenues for optimization so I haven't used it yet
i mean does exclusiveentitytransaction simply makes structral changes faster ? how about sync point ? does it create one, if so its probably better to use ECB
The advantage over ECB is that exclusiveentitytransaction works inside a job. As in the actual structural changes occur off the main thread
With ECB the structural changes still occur on the main thread, they just occur at different sync points, IE when the ECB gets played back
I think i will stick to ECB for now
@mint iron were you the one who suggested to use IDeclaredReferencedPrefabs to convert stuff and stash them to shared statics ? I told that entity wasnt valid but it was, so that was a total lie lol but i think what i remembered was.. if you instantiate convert and inject entity that authoring always run for each entity you want to instantiate, so since thats the case i couldnt use your suggestion.
@opaque ledge
When you convert into a prefab it creates a canonical prefab entity with an actual Prefab component on it. Entities with prefab components are ignored in queries unless explicitly included, so to get your prefab entity you can query for it in some system's OnStartRunning and include the Prefab component in your query.
That's how I'm using it at least
i could have tried that but i think i will skip for now, i tried to do this for my world UIs but couldnt work it out, maybe i will check it later on
does anyone have any idea how the DOTS Sample character works? looking to use the sample as a base for animation/net code but would like to implement 1st person perspective client side
What is the component "PerInstanceCullingTag"? When I create a render mesh programatically doesnt seem to come, but when I use "Convert to Entity" is there..
why this happens exactly, i have like 4k entities with 6-7 children, is this really normal ?
Hello!
Quick question... someone knows how to create a custom job type using UnsafeHashMapData?
Where it is defined?
Oh... its internal.
Nvm , thx
Another thing.
Trying to avoid the X/Y problem...
What I really need is a job for a NativeMultiHashmap that executes in the form of
Execute(TKey key, TValue[] values).
Is there a way to create a custom job to do something like that?
can't you use a NativeArray (values) for the context of the job?
entity create/destroy methods comparison https://gist.github.com/jeffvella/b4c3dc2b6748d62dab6dca6e6bcad780
For those of us too lazy to run this - any important take aways?
mmm yeah i was going to post screenshots but i did a bunch of work and then noticed some bugs, and cant be bothered again ๐ ill summarize it in a sec.
๐คฃ cool
Maybe someone can answer me this...
If this is not allowed
Entities.ForEach(( ref RenderMesh renderMesh) =>
because I have to remove the ref then how can I do to modify the mesh in my System?
with SetSharedComponentData? ๐ค
@warped trail but I need the entity for that, no?
use .WithAll for the rendermesh
Entities.ForEach(( Entity entity, RenderMesh renderMesh) =>```
or that
Aha... let me see
If the first element is Entity, none of the components can be a reference, no?
@
can't you use a NativeArray (values) for the context of the job?
@gaunt creek
I want skip the step of allocating new arrays in the mainthread as far as I can.
i guess you have to use WithStructuralChange and Run๐ค @eager oracle
@warped trail Altering a mesh in a RenderMesh is a considered a StructuralChange?
RenderMesh is a shared component so yes, if you change any value in it it's a structural change
Or I should say if you set any value in it
Interesting that, even though I am using Entities.WithStructuralChanges().ForEach , I still get this error: InvalidOperationException: Structural changes are not allowed during Entities.ForEach. Please use EntityCommandBuffer instead.
I thought the .WithStructuralChanges would take care of that ๐
@chilly halo isn't that why they added.SheduleParallel()?
You need to use .Run as well
@zenith wyvern I am using it already
Entities.WithStructuralChanges().ForEach((Entity entity, MeshDataComponent meshDataComponent, RenderMesh renderMesh) =>
{
if (meshDataComponent.isRendered) return;
Mesh mesh = new Mesh();
MeshData meshData = MeshData.LoadDataAt(Vector3.zero, meshDataComponent.chunkSize, worldConfig);
mesh.SetVertices(meshData.vertices);
mesh.SetTriangles(meshData.triangles, 0);
mesh.SetUVs(0, meshData.uvs);
mesh.RecalculateNormals();
EntityManager.SetSharedComponentData(entity, new RenderMesh { mesh = mesh, material = material });
EntityManager.SetComponentData(entity, new RenderBounds { Value = mesh.bounds.ToAABB() });
meshDataComponent.isRendered = true;
}).Run();
Even though... now my Intellisense is telling me that "ForEach" is returning "void"
๐
This isn't in a ComponentSystem is it?
this thing works fine๐ค cs Entities .WithStructuralChanges() .ForEach((Entity entity, RenderMesh renderMesh)=> { renderMesh.mesh = new Mesh(); //renderMesh.material = //DoSomething with material EntityManager.SetSharedComponentData(entity, renderMesh); }).Run();
Yeah, just making sure
Yeah I can only assume the error you're getting is not from the code you posted, unless I'm missing something
It "MeshComponentData" a shared component? You should use in or ref if not
And put RenderMesh before it
You mean "MeshDataComponent", no?
Yeah
without in or ref you are getting just copy
If I use this...
Entities.WithStructuralChanges().ForEach((Entity entity, ref MeshDataComponent meshDataComponent, RenderMesh renderMesh) =>
I get this error
Delegate 'Invalid_ForEach_Signature_See_ForEach_Documentation_For_Rules_And_Restrictions' does not take 3 arguments
Order of arguments is value then ref then in
Ok, learned something new
lets see if compiles now
I keep getting this error:
InvalidOperationException: Structural changes are not allowed during Entities.ForEach. Please use EntityCommandBuffer instead.
This is the whole file
using UnityEngine;
using Unity.Entities;
using Unity.Rendering;
using Unity.Mathematics;
using Extinction.Renderer;
public class ChunkRenderSystem : SystemBase
{
Material material;
Extinction.Config.World worldConfig;
protected override void OnCreate()
{
material = Resources.Load("WorldMaterial", typeof(Material)) as Material;
worldConfig = Resources.Load("WorldConfig", typeof(Extinction.Config.World)) as Extinction.Config.World;
worldConfig.Setup();
}
protected override void OnUpdate()
{
Entities.WithStructuralChanges().ForEach((Entity entity, RenderMesh renderMesh, ref MeshDataComponent meshDataComponent) =>
{
if (meshDataComponent.isRendered) return;
Mesh mesh = new Mesh();
MeshData meshData = MeshData.LoadDataAt(Vector3.zero, meshDataComponent.chunkSize, worldConfig);
mesh.SetVertices(meshData.vertices);
mesh.SetTriangles(meshData.triangles, 0);
mesh.SetUVs(0, meshData.uvs);
mesh.RecalculateNormals();
EntityManager.SetSharedComponentData(entity, new RenderMesh { mesh = mesh, material = material });
EntityManager.SetComponentData(entity, new RenderBounds { Value = mesh.bounds.ToAABB() });
meshDataComponent.isRendered = true;
}).Run();
}
}
Despite using WithStructuralChanges ...
oops misread sorry
?
deleted an earlier comment where I misread something - now I've confused things more ๐
Btw, my intellisense is still complaining at the .Run() , saying that ForEach returns void
(even though Unity does not complain)
ah that's usually an indication that the signature of the foreach is wrong or something's wrong in the body
does it go away if you ref the RenderMesh?
I cant ref RenderMesh
in fact you don't need the RenderMesh right? how about WithAll RenderMesh instead?
Indeed I dont. This suffices
honestly not tried to use the lambda with ISCDs like that but I can see how it would make sense for RenderMeshes
Entities.WithStructuralChanges().ForEach((Entity entity, ref MeshDataComponent meshDataComponent) =>
But it doesnt fix my problem
ok, will copy/paste, brb
Thanks
Weird... this alone also gives me the error
using UnityEngine;
using Unity.Entities;
public class ChunkRenderSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.WithStructuralChanges().ForEach((Entity entity, ref MeshDataComponent meshDataComponent) =>
{
}).Run();
}
}```
what is MeshDataComponent?๐ค
yea - I don't get errors - I'm guessing MeshDataComponent is a shared component?
A component of mine
using Unity.Entities;
public struct MeshDataComponent : IComponentData
{
public bool isRendered;
public int chunkSize;
}```
It is really dumb
You're saying if you remove the ForEach from this code
using UnityEngine;
using Unity.Entities;
public class ChunkRenderSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.WithStructuralChanges().ForEach((Entity entity, ref MeshDataComponent meshDataComponent) =>
{
}).Run();
}
}
Then the error goes away?
Like you're 100% this code is what's causing the error?
Like I said earlier it seems like you're misattributing your error to this code
It does compile, the error appears when I press play
maybe error from another job?
What error appears
Urrr.... let me see again
If it is coming from another system, im gonna kill myself
It can't be the no structural changes error because that's a compile time error
problem solved๐ฅณ
Maybe you need to change your name ๐
(Just kidding btw9
๐ข
@amber flicker with 1 archetype, 2 components, '<' denotes left-side is faster than
Destroy for 25 entities
* EM NativeArray < EM individually < ECB < Query
Destroy for 100 entities
* EM NativeArray < ECB < EM Query < EM Individually
Destroy for 250 entities
* EM NativeArray < ECB(Burst) < EM Query < ECB(C#) < EM Individually
Destroy for 1000 entities
* EM Query < EM NativeArray < ECB < EM Individually
Create for 25 entities
* EM NativeArray < EM Individually < ECB < Create+Add
Create for 100+ entities
* EM NativeArray < ECB < EM Individually < Create+Add
ecb then ๐
I think you'd need a few tens of thousands if not more to get any reliable results
its even faster not destroy if you don't have to, which is one of the benefits of an event system, it knows if it needs the exact same number of entities this frame, and can just neither create nor destroy, and skip to setting component data.
yup, don't take that as gospel, those weren't from a build (just editor with safetys/leak-detect/debugger off, burst on).
build & larger numbers would be interesting - anything above significantly (i.e. 2x+) slower than alternatives?
You could write some simple performance tests to figure things out as well
this is what i came up with https://gist.github.com/jeffvella/ad499fb3e1d6642f30f08dfd36a63dc8
probably needs to re-test with multiple archetypes, ECB and query would slow down having to switch around chunks more.
There's no way for BlobAssets to reference each other, is there?
In that, I need two of them to reference the other. I know I can have one reference the other one, but from my understanding there's no way to reserve a pointer, pass it as a value to a BlobAsset, then create another BlobAsset at that pointer.
Nice ๐