#archived-dots

1 messages ยท Page 126 of 1

junior fjord
#

I have a few systems that only get 1 entity every few frames (basically event based/user input systems). Are there any good reasons to do them either as Run, Schedule or ScheduleParallel?

safe lintel
#

run probably faster especially if you can run it with burst

junior fjord
#

oh really?

safe lintel
#

some very small overhead in scheduling it for other threads

junior fjord
#

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

safe lintel
#

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

junior fjord
#

ah and also they add a component to the event of the form ConsumedBySystemX (s.t. I won't get the same entity again)

zenith wyvern
#

Yes if you're just settings variables then you should definitely just use Run

junior fjord
#

dunno if that is a good idea

#

ok I'll go with run then

zenith wyvern
#

You can use a command buffer to avoid making structural changes during processing

junior fjord
#

at which point would you guys change from run to Schedule?

#

yeah I am using an ecb for that

#

for the component adding

zenith wyvern
#

Anything more complicated than just setting variables I will usually run as a scheduled job

junior fjord
#

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?

zenith wyvern
#

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

junior fjord
#

@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

zenith wyvern
#

Well yeah in my case I guess I'm basically using tag components as the events

opaque ledge
#

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

junior fjord
#

yes it would be nicer to be deleted after one frame, but I had no simple nice idea how to do it

zenith wyvern
#

@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

junior fjord
#

@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?

zenith wyvern
#

But then it becomes awful to maintain

fallow mason
#

a system that deletes event components that runs at the very end of the frame?

opaque ledge
#

have 1 system that creates it, have 1 system that destroys it, and your event entity at end or begin frame commandbuffer

fallow mason
#

or at the very beginning, cleanup up last frame's events?

junior fjord
#

@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

opaque ledge
#

@zenith wyvern what do you mean by consume tho, does the system actually destroys the event entity/tag ?

zenith wyvern
#

@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.

warped trail
#

system that creates Event just deletes it via ECB

junior fjord
#

@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

zenith wyvern
#

@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

opaque ledge
#

just reads it then ? thats easy to do

junior fjord
#

@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

opaque ledge
#

tbh, that sounds like a design flow, producer shouldnt care if there is a reader or not right ?

junior fjord
#

nobody cares if a system has read the event except the system itself @opaque ledge

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

junior fjord
#

I just add a ConsumedByX component in system X, s.t. X won't read the same event entity next frame again

opaque ledge
#

so there you go, 1 frame only event system

junior fjord
#

but only systems that run after the event is created and before the command buffer runs can read your entity

zenith wyvern
#

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.

fallow mason
#

trying to think of a situation that would require the event to survive longer a frame ๐Ÿค”

zenith wyvern
#

Not because it's like "a rule" but because it makes things easier on the coder

junior fjord
#

@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

opaque ledge
#

@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

warped trail
#

delete event at BeginInitializationECB, create events at EndInitializationECB ?๐Ÿค”

zenith wyvern
#

If you only want it to exist for one frame then in your producing system you do: Destroy all existing events, then produce events

junior fjord
#

@opaque ledge ah wait, you instantly create and delete the same entity in the same ecb?

#

can I do that?

opaque ledge
#

i dont instantly create it, i create it using ECB

junior fjord
#

yeah the instantly is completly wrong there ๐Ÿ˜„

zenith wyvern
#

@warped trail You don't need to create/destroy at different times. Just destroy first, then create immediately after

junior fjord
#

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?

zenith wyvern
#

That's what querying is for

warped trail
#

can you control when you destroy/delete entities via same ECB?

junior fjord
#

yeah if you could just give the command to destroy first and then create in the same ecb, that would be perfect

zenith wyvern
#

That's what I'm doing with my tags

opaque ledge
#

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

warped trail
#

@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?๐Ÿค”

junior fjord
#

yeah maybe I should just create in BeginInitializationEntityCommandBufferSystem ecb and delete in EndPresentationEntityCommandBufferSystem

opaque ledge
#

yep basically

junior fjord
#

one automatically introduced a one-frame lag this way

#

but I have no other good idea

warped trail
#

@junior fjord vice versa ๐Ÿ˜…

junior fjord
#

why vice versa?

fallow mason
#

because your event producer runs in between

zenith wyvern
#

@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

junior fjord
#

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?)

warped trail
#

delete every old event before EndPresentationEntityCommandBufferSystem in system, and new events will be created at EndPresentationEntityCommandBufferSystem

junior fjord
#

yeah or you delete in EndPresentationEntityCommandBufferSystem and create new ones in BeginInitializationEntityCommandBufferSystem right afterwards

#

thats the same thing or not?

warped trail
#

Begin is before End ๐Ÿ˜…

junior fjord
#

begin of next frame

#

can't I get the begin of the next frame?

#

Never tried until now

zenith wyvern
#

Yes if you use the begin buffer inside SimulationGroup it will be played back next frame

junior fjord
#

yeah exactly

#

ok perfect

warped trail
#

oh, didn't see Presentation part, this names are so long๐Ÿ˜…

junior fjord
#

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

zenith wyvern
#

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

junior fjord
#

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 ๐Ÿ˜„

zenith wyvern
#

I guess you could use BeginInit buffer and EndPresentation buffer

#

Depends where you need the event to be processed I guess

warped trail
#

i update simgroup at fixed rate, and I'm basically leaving some work to frame where simgroup won't be updated๐Ÿ˜…

amber flicker
#

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

junior fjord
#

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?

zenith wyvern
#

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

junior fjord
#

@amber flicker that is what I meant with the 1-frame alg

#

lag

amber flicker
#

it doesn't need 1 frame of lag - you can e.g. still destroy event at end of sim

warped trail
#

@junior fjord loot at fixedrateutils

amber flicker
#

for my stuff that's how I need it to work

zenith wyvern
#

System dependencies are already annoying enough without trying to line up asynchronous events to happen within the same frame

fallow mason
#

yeah, won't work if you have a subscriber system already run before your producer

junior fjord
#

but what if systems that ran before the event happened need to know about it @amber flicker ?

amber flicker
#

then your destroy event job should run just before it creates new ones

junior fjord
#

yeah this is exactly the solution with beginframe and endframeecb

#

forgot the real names

zenith wyvern
#

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

amber flicker
#

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

warped trail
#

pretend that there is no 1 frame lag, but you know what will happen 1 frame in the future๐Ÿ˜

junior fjord
#

did EndPresentationEntityCommandBufferSystem get renamed? rider tells me it can't find it

warped trail
#

@junior fjord they deleted it

junior fjord
#

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?

zenith wyvern
#

Mine just runs in SimulationGroup

junior fjord
#

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

warped trail
#

i interpolate things, so what you see is what happened some time ago๐Ÿ˜…

junior fjord
#

๐Ÿ˜„

warped trail
#

after i saw true smooth motion, i see jitter everywhere๐Ÿ˜•

junior fjord
#

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?

warped trail
#

just delete whole query๐Ÿ˜…

junior fjord
#

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

#

๐Ÿ˜„

zenith wyvern
#

No. _endSimBarrier.CreateCommandBuffer().RemoveComponent(_eventComponentQuery);

#

That can be in the same system

mint iron
#

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.

warped trail
#

when you change your ecb to entitymanager and have to rename all those methods ๐Ÿ˜…

junior fjord
#

ok so basically I just need to call endSimECB.DestroyEntities(allEntitiesWithEventTag) somewhere each frame?

zenith wyvern
#

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

warped trail
#

@junior fjord maybe create some system which will run at the end of frame , if you have event entities ๐Ÿค”

junior fjord
#

yeah that does sound like the easiest way out

#

how do I make it run as late as possible?

warped trail
#

run it in PresentationSystemGroup?

junior fjord
#

yeah ok sure

zenith wyvern
#

Why create a separate system? What's wrong with endSimECB.DestroyEntities(allEntitiesWithEventTag)?

junior fjord
#

where do you run that command @zenith wyvern

fallow mason
#

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.

junior fjord
#

basically it doesnt make a difference I guess

warped trail
#

why create ecb if you don't have to?๐Ÿ˜…

zenith wyvern
#

Less code to write

fallow mason
#

Also confusing to have both when everyone is trying to learn

junior fjord
#

the endSIMECB exists for me anyway

#

ah no ok I get it

zenith wyvern
#

where do you run that command @zenith wyvern
@junior fjord

Wherever, I would put it in whatever system produces your events

junior fjord
#

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

zenith wyvern
#

No, the expensive part is the actual structural changes. Creating the command buffers and playing them back is almost nothing

fallow mason
#

And what's this SystemBase nonsense. Should just be called System imo ๐Ÿ˜‰

zenith wyvern
#

@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

formal scaffold
#

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?
zenith wyvern
#

Splitting the velocity calculation into two systems is how I do it. Players calculate velocity differently from ai, it's that simple I think

formal scaffold
#

Thanks ๐Ÿ‘ might be the best idea

junior fjord
#

where do you guys dispose your nativearrays? is there an easy way to just wait until all jobs are done and then dispose all?

warped trail
#

.Dispose(JobHandle)๐Ÿ˜…

fallow mason
#

@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.

junior fjord
#

@warped trail but what do you input as jobhandle? Do you actually check for each nativearray which job is the last one using it?

fallow mason
#

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

junior fjord
#

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

formal scaffold
#

Hmm thanks for the Idea, I haven't considered that. Sounds just as good I'll think about it

mint iron
#

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.

zenith wyvern
#

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

verbal pewter
#

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.

junior fjord
#

@zenith wyvern thanks!

zenith wyvern
#

@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

junior fjord
#

I also think that if the actions are persistent and are shared between agents, then having action entities could be the right way

coarse turtle
#

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

zenith wyvern
#

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

junior fjord
#

I have no idea on how to approach modding in general. What should I think about to make my game moddable?

mint iron
#

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.

verbal pewter
#

@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.

zenith wyvern
#

The type used in FixedList doesn't have any constraints aside from being unmanaged

junior fjord
#

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

verbal pewter
#

@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?

junior fjord
#

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

verbal pewter
#

Ah sorry, I misread your question.

opaque ledge
#

@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..

junior fjord
#

@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

opaque ledge
#

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

verbal pewter
#

@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.

opaque ledge
#

idk what utility based exactly, but yeah hope it helps

formal scaffold
#

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

opaque ledge
#

i think WriteGroup is more for based on existence of certain components, not based on the values of certain components

formal scaffold
#

The RotationSystem would add an empty "WaitForRotation" component. Haven't thought further because i'm unsure if this is a good approach

opaque ledge
#

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

warped trail
#

@formal scaffold i think it will be faster to just cs if(rotation > 150ยฐ) return; ///Your Update movement code

formal scaffold
#

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

warped trail
#

once you get your rotation > 150ยฐ you don't want to move until you get your rotation to 0ยฐ ?

formal scaffold
#

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

warped trail
#

you can create waitForRotation component and make movement foreach .WithNone<waitForRotation >๐Ÿค”

#

but is it worth it?๐Ÿค”

verbal pewter
#

@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.

fallow mason
#

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

formal scaffold
#

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

warped trail
#

premature optimization is evil๐Ÿ˜„

formal scaffold
#

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๐Ÿ˜’

zenith wyvern
#

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

opaque ledge
#

ALWAYS make your code run properly first, worry about performance later

warped trail
#

i think you are trying to solve nonexistent problem๐Ÿ˜…

formal scaffold
#

Maybe you are right I will try to focus more on writing understandable code.

fallow mason
#

so is the visual scripting for DOTS supposed to use GO/MB terminology and do DOTS things behind the scenes?

opaque ledge
#

its for DOTS

fallow mason
#

Right. But there are no nodes that use any dots terminology. Instead it's things like gameobjects parents, getcomponent, etc.

opaque ledge
#

oh, i wouldnt know of that, havent tried

warped trail
#

there is like 0 thing from ecs๐Ÿ˜•

#

this new thing is like visual scripting for monobehaviour๐Ÿค”

opaque ledge
#

๐Ÿค”

fallow mason
#

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.

opaque ledge
#

yeaah, i just read awesomedata's posts, it kinda made me sad a little

formal scaffold
#

Which posts do you mean @opaque ledge?

opaque ledge
#

about drop 8 in forums

dull copper
#

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

fallow mason
#

I knew it! I could have sworn there was a shader graph style output or input bar in a previous version.

warped trail
#

you can't do any ecs stuff with this new drop๐Ÿ˜•

dull copper
#

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.

fallow mason
#

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.

dull copper
#

Also, this is very "anti-DOTS": Also temporarily ignoring performance optimization and focusing on the feature set.

warped trail
#

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. ```
dull copper
#

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

fallow mason
#

So they weren't forgetting to mention the visual editor was DOTS only in the roadmap video lol

dull copper
#

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

warped trail
#

meet new Object Oriented Technology Stack ๐Ÿ˜

dull copper
#

I'm just happy I never really cared much of the visual scripting in the first place ๐Ÿ˜„

fallow mason
#

OOTS has a nice ring to it

dull copper
#

only reason to want it in past would have been to get less boilerplate

#

but current DOTS is getting that aspect quite covered now

safe lintel
#

is just dropping ecs stuff for gameobjects just to test the actual flow of the visual scripting?

fallow mason
#

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.

dull copper
#

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)

fallow mason
#

can you parse that JSON that Topher posted to gather the names and poll for each?

dull copper
#

I can but I can also use npm to get the info easier

#
  • actually download the packages so I can automatically extract changelogs etc
fallow mason
dull copper
#

that was like first google hit when I tried to search it ๐Ÿ™‚

fallow mason
#

lol

#

and I'm guessing that doesnt work

dull copper
#

and nope. it doesn't work

fallow mason
#

hmm i see

dull copper
#

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 :/

sour ravine
#

can blob assets hold ScriptableObject/Object references?

mint iron
#

you'd probably have to pin them

sour ravine
#

not the end of the world, they're actual asset files

mint iron
#

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.

coarse turtle
#

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 :/

bright sentinel
indigo delta
gusty comet
#

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

warped trail
#

but this new visual scripting is looking just like dropping a new entity in the editor and pressing play๐Ÿ˜…

gusty comet
#

| 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

warped trail
#

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 ๐Ÿค”

gusty comet
#

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

vagrant surge
#

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

#

from the 2015 presentation on entitas

#

it makes hybrid massively easier

opaque ledge
#

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

vagrant surge
#

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

opaque ledge
#

yay ๐Ÿ˜„

#

๐Ÿ‘

vagrant surge
#

@digital scarab eagerly awaiting for the prefab thing ๐Ÿ‘

north bay
#

Same

fallow mason
#

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 ๐Ÿ™„

vagrant surge
#

@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

fallow mason
#

Like creating multiple icds with one authoring comp, you mean?

vagrant surge
#

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

fallow mason
#

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.

vagrant surge
#

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

dull copper
#

@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

vagrant surge
#

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

gusty comet
#

Are you guys converting subscenes or prefabs?

vagrant surge
#

allows people to add some components for small stuff incrementally

dull copper
#

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)

vagrant surge
#

that sort of thing is perfectly normal

#

subscenes only hold references to inside stuff

#

without that it becomes a huge mess

dull copper
#

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

vagrant surge
#

there were some DOTS talks by mike acton on gdc that got cancelled ๐Ÿ˜ฆ

warped trail
#

my main concern is a lack of tools to quickly create components, which i can just drag and drop to objects in scene

vagrant surge
#

was specially hyped for the "how to make an ECS" one

#

as that could explain some of the design decisions unity has

warped trail
#

i have to block Unity's compilation to create some scripts without waiting ๐Ÿ˜•

fallow mason
#

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.

mint iron
#

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.

stiff skiff
#

Is there a release date for 0.9.0? Its really frustrating that Android is failing to compile in 0.8.0.

wary anchor
#

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?)

pliant pike
#

why not try it and find out?

wary anchor
#

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

warped trail
#

entityQuery will be destroyed when you playback ECB๐Ÿค”

wary anchor
#

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?

opaque ledge
#

i dont think ECB accepts entity query ๐Ÿค”

#

also Burst preview9 is up ๐Ÿ‘€

wary anchor
#

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

opaque ledge
#

well yes, basically ECB is same with any structral changes, except that it happens to in at a later time

wary anchor
#

a later time still guaranteed to be in the same frame?

opaque ledge
#

if you use EndCommandBuffer, yes

wary anchor
#

thanks that's champion

warped trail
#

it depends on which sync point you choose

wary anchor
#

EndSimulationEntityCommandBufferSystem most likely for this one

opaque ledge
#

yep

warped trail
#

if your system will run before EndSimulationEntityCommandBufferSystem, then yes it will happen in same frame

wary anchor
#

yup, that's grand thanks guys

warped trail
#

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
}```
wary anchor
#

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);
warped trail
#

i think this should be outside of ForEachcs commandBuffer.DestroyEntity(playerChemUpdateQuery);

wary anchor
#

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 ๐Ÿ˜„

warped trail
#
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);
}```
wary anchor
#

ahh okay, so it should pick up the dependency info it needs automatically?

scarlet inlet
#

Hello! Having fun in not understanding how to use SharedStatic<T>. Any lead?

warped trail
#

im wondering wouldn't using native stream be a better idea for events?๐Ÿค”

opaque ledge
#

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

scarlet inlet
#

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

low tangle
#

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

wary anchor
#

thanks for the explanation @low tangle!

mint iron
scarlet inlet
#

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 ๐Ÿ˜„

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

scarlet inlet
#

yes I am basically doing the same thing

#

let's see if I can follow that

wet epoch
#

what do you need this for?

#

seems like a lot of work for a static uint

scarlet inlet
#

talking to me?

wet epoch
#

yeah

scarlet inlet
#

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

wet epoch
#

what is a 'type' in your context?

scarlet inlet
#

something that I pass through a generic parameter

#

EntityComponentID<T> //T

bright sentinel
#

Are there any learning resources for netcode other than the docs and sample project? They're pretty sparsely documented :/

wet epoch
#

just wondering why structs would need IDs like that ๐Ÿ™‚

#

trying to do some weird generic code with burst or something?

scarlet inlet
#

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

coarse turtle
digital kestrel
#

how do u edit component system parameters in editor?

mint iron
#

whats the reason, im still not sure i get whats going on here.

bright sentinel
#

@coarse turtle Hahaha see who made the post ๐Ÿ˜‰

scarlet inlet
#

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

wary anchor
#

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 ๐Ÿ™‚

scarlet inlet
#

that error is unexpected ๐Ÿ˜„

opaque ledge
#

looks nice ๐Ÿ˜„

coarse turtle
#

nice @wary anchor

bright sentinel
#

My problem isn't so much the high-level stuff, more about how to get it done with ECS NetCode

wary anchor
#

thanks!

mint iron
#

@wary anchor thats stunning, very nice job

wary anchor
#

working on the UI now, it's half updated, but boy there';s so much work to do

coarse turtle
#

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

bright sentinel
#

Ah okay

digital kestrel
#

lmk if u find good samples @bright sentinel

#

im thinking about peer to peer multiplayer

bright sentinel
#

Well I know that netcode doesn't really support that yet

digital kestrel
#

where one player acts as a host

bright sentinel
#

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

digital kestrel
#

most games dont use p2p

#

that's why

coarse turtle
#

well technically you can make the host player boot up a server ๐Ÿค”

digital kestrel
#

i guess host is technically a server

bright sentinel
#

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 ๐Ÿ˜„

#

Make sure to tune in

#

Seems like it's relevant for us ๐Ÿ˜„

warped trail
#

in the future ๐Ÿ˜…

mint iron
#

are you australian @wary anchor ?

zenith wyvern
#

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

bright sentinel
#

@zenith wyvern Probably coming up

#

Live Games is a lot of stuff

warped trail
#

๐Ÿ˜…

fallow mason
#

did roadmap vid just end?

north bay
#

Yea lmao

warped trail
#

yeah

fallow mason
#

i just started watching ๐Ÿ˜†

bright sentinel
#

oh lmao

#

wtf

amber flicker
#

any highlights for the lazy of us?

fallow mason
#

well, it is April Fools day, so it could all be a joke

zenith wyvern
#

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.

bright sentinel
#

I don't think this was supposed to be the GDC replacement though

fallow mason
#

I was just thinking that @zenith wyvern. No way they would have gotten up on stage and only showed this.

opaque ledge
#

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

zenith wyvern
#

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

safe lintel
#

seems like they are holding out on us ๐Ÿ˜ฆ

digital kestrel
#

anyone else disappointed ๐Ÿ˜…

vagrant surge
#

unreal is even more of a dissapointm,ent

fallow mason
#

but holding out hope that there's more talks coming

vagrant surge
#

they cancelled everything

#

and there were some seriously hype talks and announcements

fallow mason
#

what we really need is a roadmap for the planned talks lol

vagrant surge
#

for example, very likely to show their new ecs stuff

safe lintel
#

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)

opaque ledge
#

managed objects doesnt live in chunk, but you can do ForEach using component/buffer classes

#

old component system run on main thread

safe lintel
bright sentinel
#

@safe lintel Is this also happening in 0.8.0?

safe lintel
#

it is for me

#

and it seems to be just one job(unless it means two jobs from two unrelated systems?)

mint iron
#

wonder if this still happens using the SystemBase GetComponent, which seems to be the replacement for passing in a CDFE

safe lintel
#

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

scarlet inlet
#

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

opaque ledge
#

its literally designed to be used inside burst

#

๐Ÿ˜„

bright sentinel
#

@mint iron Don't you think it just fetches CDFE behind the scenes?

scarlet inlet
#

@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

opaque ledge
#

๐Ÿค”

scarlet inlet
#

I can't also imagine what alternative solution I could use, beside, maybe, a global native dictionary

opaque ledge
#

should be something like

public abstract class Shared_UInt{
private class UINTKey{}
public static readonly SharedStatic<uint> uint = SharedStatic<uint>.GetOrCreate<Shared_UInt, UINTKEY>();
}
scarlet inlet
#

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;
        }
    }
opaque ledge
#

and use Shared_UInt.uint.Data

#

to access

scarlet inlet
#

wait radonly?

opaque ledge
#

yeah

scarlet inlet
#

let me check

#

hmm k

#

didn't crash but I have another bug

#

brb ๐Ÿ˜„

opaque ledge
#

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

scarlet inlet
#

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

opaque ledge
#

perhaps its because you are doing it in a generic way ?

#

just do non-generic version and see how it goes

scarlet inlet
#

hmm that's the only thing I didn't test so yeah I'll test it

mint iron
scarlet inlet
#

thank 1M to test it!

mint iron
#

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

scarlet inlet
#

yes I am experiencing something similar

#

the numbers are not right

mint iron
#

do you need control of the ID or could you just use like the runtime hash?

scarlet inlet
#

but only if burst is on, otherwise it works fine

#

I need to be consecutive numbers

mint iron
#

ahhh

scarlet inlet
#

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?

mint iron
#

BurstRuntime.GetHashCode32(typeInfo.Type) / BurstRuntime.GetHashCode32<T>()

safe lintel
#

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?

scarlet inlet
#

right didn't know those testing now

opaque ledge
#

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

scarlet inlet
#

yes @mint iron it worked! bill me now ๐Ÿ™‚

mint iron
#

๐Ÿ˜‰

scarlet inlet
#

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!

coarse turtle
#

@opaque ledge what about IDeclareReferencedPrefabs?

opaque ledge
#

Entity is not valid when i do that

#

iirc

coarse turtle
#

in the end you would get the entities you need so you can grab that and instantiate it ๐Ÿค”

#

Ah ๐Ÿค”

eager jungle
#

hey, can someone explain me when to use SystemBase over ComponentSystem? and is JobComponentSystem still a thing?

safe lintel
#

always use systembase, both jobcomponentsystem and componentsystem will be made obsolete some time in the future

eager jungle
#

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)

safe lintel
#

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

eager jungle
#

ok , wasn't sure about that. No helper equivalent function you know about?

safe lintel
#

not as far as I know

warped trail
#

you can use something like thatcs var postUpdateCommands = new EntityCommandBuffer(Allocator.TempJob); //Do your work postUpdateCommands.Playback(EntityManager); postUpdateCommands.Dispose()

#

basically the same thing

eager jungle
#

shall i create it once in the create method of the system?

warped trail
#

i don't know๐Ÿค”

eager jungle
#

trying that right now, thanks ๐Ÿ˜‰

warped trail
#

but you have to use concurrent one, if you doing your work in jobs๐Ÿค”

#

oh, b4 is out๐Ÿ˜…

dull copper
safe lintel
#

Entities Version: 0.0.12-preview21 ๐Ÿง“

dull copper
#

I was about to say that this is ancient

#

last commit from 2018 ๐Ÿ˜„

warped trail
#

[Inject]๐Ÿ˜

dull copper
#

lol

#

I didn't realize it was that ancient ๐Ÿ˜„

#

repo was just updated 18days ago for something

eager jungle
#

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?

coarse turtle
#

Hmm idk about the first one - but the second there is no way currently

opaque ledge
#

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

coarse turtle
#

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 :/

opaque ledge
#

:/

warped trail
#

just store every prefab in subscene๐Ÿ˜…

safe lintel
#

man i havent even touched scene loading/changes ๐Ÿ˜„

eager jungle
#

thanks guys

opaque ledge
#

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

mint iron
#

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();
opaque ledge
#

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

coarse turtle
#

oof...I think I should take a look at mine since I'm using convert and inject ๐Ÿ˜ฌ

opaque ledge
#

i had to get UI related stuff out of my project because it wasnt building because of TMP references in managed components, now this.. ๐Ÿ˜’

mint iron
#

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.

stiff skiff
#

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?

dull copper
#

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."

fallow mason
#

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 ๐Ÿ˜ข

mint iron
#

oh you mean here, derp!

raven grail
#

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

fallow mason
raven grail
#

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

fallow mason
#

plane-related? You cast against a collider. It doesn't matter what shape it is.

raven grail
#

Plane doesn't have a collider

fallow mason
#

it should if you're wanting to get a hit when you raycast it

raven grail
#

OOP didn't need it

#

I'm asking if there's something equivalent for Physics.Plane

safe lintel
#

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

fallow mason
#

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

raven grail
#

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

viral sonnet
#

Is anyone running Unity 2020.1.0b3 with hybrid renderer?

bright sentinel
safe lintel
#

just give me the slides for what was supposed to be presented at gdc

#

and id be happy

mint iron
#

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.

warped trail
#

this is how prefab component works๐Ÿค”

mint iron
#

the prefab instantiates fine, but the new objects are not rendered

warped trail
#

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?๐Ÿค”

mint iron
#

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.

warped trail
#

are you using things like this [ConverterVersion("joe", 1)] ๐Ÿ˜…

mint iron
#

no, but i think i just figured it out, ... didnt have hybid renderer package.. yep that was it

#

facepalm

warped trail
#

๐Ÿ˜‘

coarse turtle
#

there's a prefab component?

#

lol I didn't know that ๐Ÿ‘€

fallow zealot
verbal pewter
#

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?

vagrant surge
#

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

opaque ledge
#

@verbal pewter afaik, no it doesnt give you an error if component doesnt exist

#

at least for ECB, not sure for entity manager directly

opaque ledge
#

This comments for Visual scripting are pretty rough, i hope Unity will listen those issues and i hope they wont be discouraged or smth

verbal pewter
#

@opaque ledge Okay thanks!

dull copper
#

@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

warped trail
#

@opaque ledge i don't think they really care about this type of feedback๐Ÿ˜…

dull copper
#

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

opaque ledge
#

well criticism is also a feedback ๐Ÿ™‚

warped trail
#

if they had cared about such things on forum, we would got dark theme for free looong time ago๐Ÿ˜‚

fallow mason
#

I think the criticism buried in a manifesto of ad hominem and condescension has to be the most annoying

vagrant surge
#

@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

warped trail
#

this is already outdated ๐Ÿ˜…

dull copper
#

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

mint iron
#

whats the point of WithName?

vagrant surge
#

to have the for-each be named

#

to then in the debugger be able to find it easily

#

for benching and similar

mint iron
#

ahhh okay, thanks

#

they really should put more intellisense comments in

vagrant surge
#

damn people are pissed with the new visual script @dull copper

#

the change from vertical layout to blueprint-clone is such a huge downgrade

mint iron
#

where on the forums?

vagrant surge
warped trail
#

if only layout was a problem ๐Ÿ˜•

vagrant surge
#

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"

dull copper
#

@vagrant surge I prefer the horizontal myself

#

but I can understand some of the reasons for what people are upset

vagrant surge
#

i kinda liked how the vertical one was going, as it separates the "math" from the "execution" very cleanly

dull copper
#

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)

warped trail
#

just try it yourself, you will see why people complaining ๐Ÿ˜…

dull copper
#

IMO none of the earlier versions I tried were even remotely usable even

vagrant surge
#

new thing is basically BP

dull copper
#

so I don't think I'd like the new one either

#

yes

vagrant surge
#

prettier nodes tho

fallow mason
#

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?

mint iron
#

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.

vagrant surge
#

visual script is always a selling point for artists/designers/noobs

#

programmers dont give a single fk about VS in general

warped trail
#

this is for actual usecases from real world clients/users๐Ÿ˜

dull copper
#

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)

vagrant surge
#

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

dull copper
#

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(?)

vagrant surge
#

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

dull copper
#

I don't really see how the original graph programmer could maintain it if c# feels alien ๐Ÿ˜„

vagrant surge
#

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

mint iron
#

you and your actual use cases

fallow mason
#

no, now hold on a moment. how do we know he's real world ๐Ÿค”

vagrant surge
#

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

mint iron
#

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.

vagrant surge
#

it allways is much worse than code, with an exception

#

timer based stuff and event based stuff is much better on VS

fallow mason
#

well, can't you use those placemat things? or is that not what they're for?

vagrant surge
#

because on VS you can have OnEvent -> PlayAnimation -> Wait(1second)-> Explosion

fallow mason
#

are you talking about merging into a function node?

mint iron
#

thats what i was thinking, like in blueprints, the stuff around pawns and spawning actors, events and the UI side are quite nice.

vagrant surge
#

on ue4, i almost allways put events on the BP level

#

and then they just call cpp functions

#

specially if its level based stuff

mint iron
#

at that point it becomes a useful visual by itself to document the flow of behavior.

pliant pike
#

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

vagrant surge
#

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

pliant pike
#

I don't feel like it fails with event based stuff how so ๐Ÿค”

vagrant surge
#

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

pliant pike
#

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

vagrant surge
#

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

pliant pike
#

I'm not sure how you would entirely avoid sync points but surely that is still faster than monobehaviour

vagrant surge
#

pretty sure a simple virtual call is faster than having to create entity and process it

pliant pike
#

yeah I guess that would be true ๐Ÿค”

vagrant surge
#

its more about the general "flow" of the event

fallow mason
#

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

vagrant surge
#

on just a function call, you can inmediately go to reference and the likes

fallow mason
#

and then immediately delete it

vagrant surge
#

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

pliant pike
#

I'll have to watch that vid then, thanks

vagrant surge
#

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

sour ravine
#

power pattern ^

vagrant surge
#

then you have another system that applies target armor

sour ravine
#

also good fit for animation

vagrant surge
#

then you have another system that spawns blood particles

#

and then you have another system that actually applies the damage and deletes the event

pliant pike
#

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

vagrant surge
#

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

pliant pike
#

yeah I'll probably continue to use it until I come up with performance problems

vagrant surge
#

if its done for punctual events, there is no issue

pliant pike
#

I'm wondering how I would delay or queue events with it that's probably more difficult, ๐Ÿค”

vagrant surge
#

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

fallow mason
#

yeah, I think I've seen that pattern on an episode of yugioh or something

vagrant surge
#

sending stuff to the shadow realm is a power pattern in ECS

worldly pulsar
#

What I did is put a DelayedEvent(activationTime) on it, and than a system checks that and replaces with Event() where appropriate

pliant pike
#

that's cool

worldly pulsar
#

all the event handlers query for Event()

mint iron
#

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.

warped trail
#

writegroups can help with this type of things๐Ÿค”

pliant pike
#

there's also the structural components I guess, I mean the Isystemstatecomponents

worldly pulsar
#

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

fallow mason
sour ravine
#

something to consider with Unity is the use of query-based entity destruction

vagrant surge
#

@worldly pulsar thats common

#

ive seen project have a "chain" of event-systems

#

and they loop until there are no more events

warped trail
#

i guess you can chain systemgroups with UpdateCallback๐Ÿค”

mint iron
#

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.

sour ravine
#

curious to know more there, but always did the punctual event approach so had larger numbers of things

mint iron
#

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.

amber flicker
#

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

mint iron
#

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.

amber flicker
#

did you compare against ecb out of curiosity?

worldly pulsar
#

is that 1k entities in a single archetype, or over a lot of different archetypes?

fallow mason
#

could add all your events as buffercomponents on one entity and never destroy

mint iron
#

yeah thats the right question, i dont remember offhand.

eager oracle
#

Question: Is it possible to use EntityManager inside the lambda function of a Entities.ForEach? I cannot seem to be able...

opaque ledge
#

@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

mint iron
#

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!

opaque ledge
#

ah, sorry to bother you with it then

warped trail
#

@eager oracle cs Entities .WithStructuralChanges() .ForEach(()=> { }).Run();

eager oracle
#

@warped trail Is there a reason for needing that?

#

I mean, is creating new entities really an structural change?

warped trail
#

yes

#

you can use command buffers

eager oracle
#

What are the consequences of using ".WithStructuralChanges"?

#

I mean, so I understand what is really going on under the hood

opaque ledge
#

@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

eager oracle
#

so basically pauses the main thread?

opaque ledge
#

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

eager oracle
#

But then it is not a really good solution, no...?

opaque ledge
#

if your system suppose to do structral changes then go for it, and if you can use ECB that would be much better

eager oracle
#

ECB?

mint iron
#

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.

eager oracle
#

ah, entity command buffer

opaque ledge
fallow mason
#

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?

eager oracle
#

Well, I guess I will use it, and then see if it is performant

opaque ledge
#

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

bright sentinel
#

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
#

@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

opaque ledge
#

well what i was wondering is why would i use this over ECB, or rather what are the advantages/disadvantages over ECB

zenith wyvern
#

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

opaque ledge
#

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

zenith wyvern
#

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

opaque ledge
#

I think i will stick to ECB for now

zenith wyvern
#

@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

coarse turtle
#

๐Ÿ‘

#

Good to know about the Prefab component lol

opaque ledge
#

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

gaunt creek
#

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

eager oracle
#

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..

opaque ledge
#

why this happens exactly, i have like 4k entities with 6-7 children, is this really normal ?

chilly halo
#

Hello!

Quick question... someone knows how to create a custom job type using UnsafeHashMapData?

#

Where it is defined?

#

Oh... its internal.
Nvm , thx

chilly halo
#

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?

gaunt creek
#

can't you use a NativeArray (values) for the context of the job?

mint iron
amber flicker
#

For those of us too lazy to run this - any important take aways?

mint iron
#

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.

amber flicker
#

๐Ÿคฃ cool

eager oracle
#

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?

warped trail
#

with SetSharedComponentData? ๐Ÿค”

eager oracle
#

@warped trail but I need the entity for that, no?

safe lintel
#

use .WithAll for the rendermesh

warped trail
#
Entities.ForEach(( Entity entity, RenderMesh renderMesh) =>```
safe lintel
#

or that

eager oracle
#

Aha... let me see

#

If the first element is Entity, none of the components can be a reference, no?

chilly halo
#

@

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.

warped trail
#

i guess you have to use WithStructuralChange and Run๐Ÿค” @eager oracle

eager oracle
#

@warped trail Altering a mesh in a RenderMesh is a considered a StructuralChange?

zenith wyvern
#

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

eager oracle
#

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 ๐Ÿ˜›

gaunt creek
#

@chilly halo isn't that why they added.SheduleParallel()?

zenith wyvern
#

You need to use .Run as well

eager oracle
#

@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"

#

๐Ÿ˜•

zenith wyvern
#

This isn't in a ComponentSystem is it?

eager oracle
#

SystemBase

#

ComponentSystems are being phased out, no?

warped trail
#

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();

zenith wyvern
#

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

eager oracle
#

You mean "MeshDataComponent", no?

zenith wyvern
#

Yeah

warped trail
#

without in or ref you are getting just copy

eager oracle
#

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 
zenith wyvern
#

Put RenderMesh first

#

After entity

eager oracle
#

WOW

#

I would have never guessed that

zenith wyvern
#

Order of arguments is value then ref then in

eager oracle
#

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 ...

amber flicker
#

oops misread sorry

eager oracle
#

?

amber flicker
#

deleted an earlier comment where I misread something - now I've confused things more ๐Ÿ˜„

eager oracle
#

Btw, my intellisense is still complaining at the .Run() , saying that ForEach returns void

#

(even though Unity does not complain)

amber flicker
#

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?

eager oracle
#

I cant ref RenderMesh

amber flicker
#

in fact you don't need the RenderMesh right? how about WithAll RenderMesh instead?

eager oracle
#

Indeed I dont. This suffices

amber flicker
#

honestly not tried to use the lambda with ISCDs like that but I can see how it would make sense for RenderMeshes

eager oracle
#
Entities.WithStructuralChanges().ForEach((Entity entity, ref MeshDataComponent meshDataComponent) =>
#

But it doesnt fix my problem

amber flicker
#

ok, will copy/paste, brb

eager oracle
#

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();
    }
}```
warped trail
#

what is MeshDataComponent?๐Ÿค”

amber flicker
#

yea - I don't get errors - I'm guessing MeshDataComponent is a shared component?

eager oracle
#

A component of mine

using Unity.Entities;

public struct MeshDataComponent : IComponentData
{
    public bool isRendered;
    public int chunkSize;
}```
#

It is really dumb

zenith wyvern
#

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

eager oracle
#

It does compile, the error appears when I press play

warped trail
#

maybe error from another job?

zenith wyvern
#

What error appears

eager oracle
#

Urrr.... let me see again

#

If it is coming from another system, im gonna kill myself

zenith wyvern
#

It can't be the no structural changes error because that's a compile time error

warped trail
#

problem solved๐Ÿฅณ

eager oracle
#

Ok, yes... it was another system

#

๐Ÿคฆ

#

But whyyyyy? Before was working

bright sentinel
#

Maybe you need to change your name ๐Ÿ˜‚

eager oracle
#

Great...

#

Because I was using "WithoutBurst" instead of "WithStructuralChanges"

bright sentinel
#

(Just kidding btw9

eager oracle
#

๐Ÿ˜ข

mint iron
#

@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

warped trail
#

ecb then ๐Ÿ˜…

bright sentinel
#

I think you'd need a few tens of thousands if not more to get any reliable results

mint iron
#

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).

amber flicker
#

build & larger numbers would be interesting - anything above significantly (i.e. 2x+) slower than alternatives?

bright sentinel
#

You could write some simple performance tests to figure things out as well

mint iron
#

probably needs to re-test with multiple archetypes, ECB and query would slow down having to switch around chunks more.

verbal pewter
#

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.

eager oracle
#

Finally

verbal pewter
#

Nice ๐Ÿ˜

eager oracle
#

Now for the whole map

#

Is there an Util to transform float3 into Vector3?

#

Not that it is much work, but just in case

low tangle
#

Already casts just fine on most cases

#

If not just explicit cast it (vector3)myvar

eager oracle
#

Oh, nice

#

๐Ÿ™‚

#

Finally!

#

Now I have to learn how to build systems that connect 2 different entity types...

#

So that when the player is too far away from the center, it re-renders

#

Maybe using 2 different .ForEach in the same system??