#archived-dots

1 messages · Page 92 of 1

onyx mist
#

okay gotcha, thanks!

stuck hatch
stuck hatch
#

I am not sure, I am testing a lot right now, a very easy example would be nice

#

I am just missing the days, where I just wrote a collision Enter in Monobehaviours, good old days

stuck hatch
#

Easy should be readable, human friendly. I already trying to get this thing running.

#

Any ideas?

#

ähm, Nani? I am spawning an Entity with physics components on it. There is nothing special

#

Yeah I already tested this too, thats why I changed it, same result

#

what do you mean? I have to run it in a job, I just want to get the collisionEvents

#

BTW I am using latest unity beta and latest entities and physics stuff

#

2019.03.b9

stuck hatch
#

I know what causes the issue, but I dont know why

#

please wait a second, I just want to be 100% sure

#

I compared the unity example again and I need to take this line into the job. After that it runs without errors.

#

I think it changes something beneath

#

If you remove it, it makes error

#

well, the name of the method is only GetComponentDataFromEntity and not change Read-Mode or what ever

#

ok, I will keep an eye open on those

rare umbra
#

I have a component being used by a system and inside the system I’d like to edit data on the entity referenced in the component

I’ve done this before but lost the code I was referencing. If I recall there was an efficient way to do this and a really really inefficient way 😀

#

Basically I have a Wallet component on Entity A which contains currency balance and a PurchaseRequest component on an entity which has a reference to the wallet entity

#

I want a PurchaseTransaction system which edits the wallets balance and awards the references item in the purchase request

tawdry tree
#

EntityManager.GetComponentForEntitity<Component>(entityId)Or something? Check intellisense auto-completion

rare umbra
#

Looks great, thanks! I can use this directly in my ForEach?

#

That reminds me I need to figure out why my intellisense isn’t working 😦

tawdry tree
#

No autocompletion, or no documentation information?

#

I get the former, but not the latter with packages

rare umbra
#

It’s not so much knowing what I can do but more about knowing what the best way to do something is

tawdry tree
#

Accessing an entity like that breaks the normal linear accessing of memory that ECS benefits so much from, but keep in mind that while not optimal, it might not be worth optimizing.
How often does it happen, for one?

rare umbra
#

Only when the player chooses to make a purchase. So very rarely, once per few frames maximum

#

Talk looks great, thanks!

tawdry tree
#

Then it should be absolutely no problem

#

Also, you might be able to do it in foreach, I just don't know

rare umbra
#

So I had another idea about how to do this...

tawdry tree
#

Try! The perf impact should be neglectible if it's only initiated by a player. Could add a small comment along the lines of // Look into optimizing if triggered often/automatically

rare umbra
#

Each time the player makes a request, create an entity with a purchase request component which references the item for sale.

Also attach the wallet component which would be a shared component

And then access the data as part of the system

tawdry tree
#

I'm not sure I understand you here, but if you haven't watched the talk, i advise you to do so - you will probably find some new ideas

rare umbra
#

Will do, thanks! Was thinking of treating the wallet like a singleton so I can attach it to any entity and read from any system

#

Thanks guys!

plush dock
#

Should RaycastCommand be used with ECS physics?

fair condor
#

Could someone enlighten me? Why is this not working?

    public class SomeSystemGroup : ComponentSystemGroup
    {
    }

    public class SomeSystem : ComponentSystem
    {
        protected override void OnUpdate()
        {
            var commandBuffer = World.GetOrCreateSystem<SomeSystemGroup>().PostUpdateCommands;
            var e = commandBuffer.CreateEntity(); // Throws NullReferenceException: The EntityCommandBuffer has not been initialized!
        }
    }

I can access PostUpdateCommands from within Update from "SomeSystemGroup", that works just fine. But when I try and access it from elsewhere, it throws the exception above.

plush dock
#

You should use CreateCommandBuffer() from one of build in EntityCommandBufferSystem or create your own buffer system

fair condor
#

Cool, thanks for the pointer, I'll go investigate how to do that 😋

#

now CreateCommandBuffer is throwing null reference exceptions.

plush dock
#

I am using barier = World.Active.GetOrCreateSystem<BeginSimulationEntityCommandBufferSystem>();

#

in OnCreate() and barier.CreateCommandBuffer().ToConcurrent() in OnUpdate()

fair condor
#

Aah ToConcurrent() maybe that's what I'm missing?

plush dock
#

barrier is a field in a system.

#

ToConcurrent is used in Parrallel jobs

fair condor
#

Hmm, so CreateCommandBuffer is supposed to be called each frame?

#

I think my problem is that I'm trying to cache it.

#

Which to me, sounds like an appropriate thing to do with buffers -_-

plush dock
#

In all examples buffers are created each frame, they are just structs.

fair condor
#

Yeah, there's probably not any reason to cache it then. Thanks for the help!

fair condor
#

I'm trying to achieve the following:

Have an entity spawned, then updated once by all systems between the two command buffers, and destroyed immediately after. All in the same frame.

var beginCommandBuffer = World.GetOrCreateSystem<SomeCommandBufferSystemBegin>().CreateCommandBuffer();
var endCommandBuffer = World.GetOrCreateSystem<SomeCommandBufferSystemEnd>().CreateCommandBuffer();

var e = beginCommandBuffer.CreateEntity();

endCommandBuffer.DestroyEntity(e);

Right now DestroyEntity(e) is causing errors, I'm guessing that creation of entities doesn't happen immediately, and there's no entity do destroy?

Does anyone know if that's possibly to achieve it somehow, or something similar?

stable fog
#

How do you invoke a job asynchronously

#

Or where do I read about that

tawdry tree
#

You do not use asynd/await, if that's what you thought. You can start a job and just hold on to its jobhandle. The tricky part is making the engine not wait for it to finish the same frame, but I'm not entirely sure how to do that. Default behavior in systems is definitely not it.

plush dock
#

I guess your system is in a simulation group. and destroy is called on EndSimulationEntityCommandBufferSystem and create is called on BeginSimulationEntityCommandBufferSystem

#

so it is executed like this current frame OnUpdate, then EndSimulationSystem, next frame BeginSimulationSystem

prisma anchor
#

Is there a way to only let a job run if something has changed i.e Screen.width/height?

onyx mist
#

can i make one mathematics.random class instance with one seed and then be done with it for the rest of the game? or should i keep updating it every so often?

stable fog
#

When using RaycastCommand, will the order and number of the commands you send to the batch equal the order and number of results in your result set?

#

Or put another way, will the indices in the arrays match if maxhits == 1

#

its my current belief that is true, but I'm unsure

pliant pike
#

@prisma anchor you could create an event entity when the screen has changed and then use that to start the job

prisma anchor
#

Event Entity? Is there any docs on that?

coarse turtle
#

an event entity is something you produce so that a system can pick it up consume it and do some kind of action

rare umbra
#

hrmm, I'm having trouble accessing EntityManager from a system. Can anyone link an example? I'm finding it tough to find anything online

rare umbra
#

found it in the options for entity interaction talk 🙂

ashen gull
#

@rare umbra you get a reference from the JobComponentSystem which get it from ComponentSystemBase as a reference

   public EntityManager EntityManager { get; }
#

Is there a way to use RenderMesh in a job with burst, its not working because Material/Mesh inheritance from Object which is not bitable?

somber drift
#

can use 2D arrays or jagged arrays in jobs?

#

or do you have to do the flattening technique

somber drift
#

rip okay

prime cipher
#

Hi. I'm pretty new to ECS. Applying what I learn through tutorials, I get stuck in missing assembly references. InjectAttribute an GetEntities is not working for me, although I installed the Entities package in latest preview, running project in 2019.3b.

amber flicker
#

@prime cipher it's possible you're following some old tutorials - [Inject] was depreciated quite a while ago - would recommend checking out the pinned links and starting with some of the examples

prime cipher
#

@amber flicker Probably, this is what I found looking for Hybrid, as Entities.ForEach is not working with my MonoBehaviour, although I have GameObjectEntity on the GameObject. Maybe I'm on the wrong track here, as Entities.ForEach works for all my pure ECS Components. Thx

slow epoch
#

Well, the MonoBehaviour is going to be destroyed after conversion

prime cipher
#

@slow epoch thx, but shouldn't that result in a corresponding component I can query for? And the error is a compile time error.

slow epoch
#

If the Entities.ForEach is in other place and the Convert method converts correctly the monobehaviour to the intended IComponentData then it should work yes

#

Can you show us the Compile time error?

prime cipher
#

Sure: The type 'PlayerMovementComponent' must be a non-nullable value type in order to use it
as parameter 'T0' in the generic type or method 'EntityQueryBuilder.ForEach<T0>(EntityQueryBuilder.F_D<T0>)' (CS0453) [Assembly-CSharp]

Where PlayerMovementComponent is the MonoBehaviour I want to update through my ComponentSystem (which reads the Input from user)

slow epoch
#

PlayerMovementComponent must be a struct

#

Probably is a class right now

slow epoch
#

Well then yes, he should recheck the whole idea of ecs again

prime cipher
#

Just trying to get a hang on Hybrid ECS. From samples it was using GameObjectEntity and can partially work with MonoBehaviours. I'm not convinced, that Hybrid is a good idea, but it is featured though.

prime cipher
#

The solution was to create a struct and a MonoBehaviour, using ComponentDataProxy<the struct> on the Monobehaviour. With GameObjectEntity, the data is interchanged

vagrant bear
pliant pike
#

you can convert monobehaviours straight to entitys though, the node example does just that

stable fog
#

I'm not a fan of this conversion setup

#

it requires a bunch of boilerplate code

#

you write fields twice, and write a converter

pliant pike
#

yeah there is too many and they are confusing

prime cipher
#

I'd love to stick to pure ECS, but how do you currently handle animations then?

slow epoch
#

Animation api for ecs is comming "soon"

#

There is no actual date but should come with the networking demo

#

Which, as well, is comming "soon"

prime cipher
#

exactly ... not so reliable solution today 🙂

slow epoch
#

Also is here already the new version of entities with the auto conversion stuff?

#

It was supposed to be the next week to Copenhagen

amber flicker
#

Working on getting my monobehaviour to convert and destroy properly - what's the way to handle multiple of the same mb on a single gameobject? I don't mean the entity/dynamic buffer side but rather avoiding the GameObject .. has multiple xxx components and cannot be converted, skipping. error - is there a pre conversion method? A way to remove the component beforehand or something?

slow epoch
#

Using Subscenes

#

I don't know if it's what you need but it caches the entities and their components on edit mode

amber flicker
#

unfortunately I want to support non-subsene workflows

safe lintel
#

i think you might need to figure a way to reorganize whatever you have on multiple monobehaviours

slow epoch
#

Maybe using ConvertionSystems but that doesn't guarantee that runs before other systems

safe lintel
#

possibly, not sure if conversion systems follow the logic of the converttoentity class though

slow epoch
#

Maybe an editor tool that checks the active gameobject or a set of gameobjects to remove the duplicated components

amber flicker
#

hmm.. yikes..

#

so I guess at the moment you can't, for example, add two joints to a physics body?

slow epoch
#

Nope since an entity cannot have two of the same component

amber flicker
#

or rather, it will let you but then through a conversion error

slow epoch
#

(i think)

amber flicker
#

well.. you could easily solve the entity side by making a dynamic buffer or something.. in my case I don't even need to keep the data on the entity so I could just throw away the component

#

but thank you for the input - good to know I'm not missing something

safe lintel
#

well you need to setup the joints manually

deft niche
#

A new week has started... waiting for the entities package update..😎

safe lintel
#

<insert meme image of skeleton at keyboard>

stiff skiff
#

Maybe its linked to the release of 19.3?

deft niche
#

Its definitely linked to 19.3. People from unity have mentioned that 2019.3 is required for the next package.

dull copper
#

2019.3 being required doesn't automatically mean 2019.3 release version tho 🙂

#

but it's very likely that 2019.3 is going to get released this month

stable fog
#

w00t

dull copper
#

last two years .3 have been on december I doubt Unity wanted it to take that long for either 2018.3 or 2017.3

#

and 2019.3 is pretty good shape and doesn't have as huge late minute changes on the core engine side as 2018.3 had for example

#

main thing I could see stalling 2019.3 right now are some packages that are supposed to be released along with 2019.3

stable fog
#

The release schedule has basically been consistent since they migrated to the Year version model

dull copper
#

like, HDRP and UPR for example

stable fog
#

1 major version and 4 minor versions per year, approximately every 3 months

dull copper
#

sure, but the initial target for 2019.3 was end of October even

stable fog
#

I guess you could argue its kinda 3 minor versions

dull copper
#

and same was for 2018.3 afaik

#

but yeah, things get shifted all the time

stable fog
#

I just want to see the 2020 ball rolling, lots of really awesome features in 2020

#

SerializeReference FTW

dull copper
#

I really want HDRP's better DX12, DXR and virtual texturing

#

these are coming during 2020 cycle

#

and we'll probably get better dots hybrid rendering by then too :p

stable fog
#

I wont be upgrading to a ray tracing card until the next generation comes out atleast

dull copper
#

yeah, it's pretty good idea to wait at this point

stable fog
#

which would probably be in 2020 anyways I suppose

safe lintel
#

just want that dots animation package 😦

stable fog
#

I just want an entity focused workflow

#

I don't want this GameObject conversion stuff

magic frigate
#

I'm sitting around waiting for the new shooter project they showed at Unite. Maybe with .3?

stable fog
#

which new shooter project?

safe lintel
#

well i guess too bad as it seems like conversion is here to stay for a long time

stable fog
#

?

safe lintel
#

dots shooter isnt out

#

it might come along with the new entities release but maybe after

stable fog
#

they are relasing another one? lol

#

how many FPS packages are they going to release

safe lintel
#

its based on the fps sample project, not the one you linked but the other that uses hdrp

stable fog
#

the one that uses HDRP isn't entities at all though right?

safe lintel
#

im assuming its just a small slice of doing everything in pure dots

stable fog
#

its classical style?

safe lintel
#

well its a mix

magic frigate
#

This new one is more DOTS based. I believe it uses the new animation stuff as well?

safe lintel
#

yeah

stable fog
#

I really want to rework my parametric modeler for DOTS, but it seems DOTS isn't ready for that

magic frigate
safe lintel
#

it shows off the subscene workflows with live entity conversion which fpssample doesnt do any of as of yet

stable fog
#

I could probably do it all in jobs...

safe lintel
#

yeah think i was reading a thread this morning on the hybrid renderer not working so great with procedural meshes

stable fog
#

really? I wasn't even aware of that

#

:/

#

I suppose I shouldn't be surprised, Unity never likes when you do procedural stuff

rare mason
#

Anyone have any suggestions on how you would sum a value from a component attached to several entities and save it to another entity with a different component? An example being updating the health of a fleet of ships based on the individual ship health?

deft niche
#

@rare mason You can use IJobForEach to process those components in a job and return the resulting sum in a 1 capacity NativeArray, then use that result to set/add a component to that entity using a command buffer.

rare mason
#

@deft niche Thanks for the response. Just to make sure I am understanding correctly. You can store the fleets in a command buffer and then update the health of the fleet after processing the health sum of the ships?

deft niche
#

Oops.. not like that.. use EntityQuery to query the entities that you want.. so in this example, when you are scheduling the IJobForEach job, you can pass the EntityQuery that queries for health component and individual ships.

#

Once that job is completed, use another EntityQuery to get the fleet entity and add/set the healthcomponent on that entity using command buffer calls.

#

maybe a hash map might work good if you have a lot of ships assigned to different fleets

#

So, the key could be the id of the fleet and the value could be the resulting sum

rare mason
#

Thanks @deft niche I may need to read up more on the command buffer. I think that is where I am failing to understand. This was a great help and gives me a more focused direction to do some more reading. Thanks for the help!

rare mason
#

@deft niche It took a min but I got it working! Thanks again!

deft niche
#

Awesome!!

rare umbra
#

hey guys, really dumb question - I was asking about how to use EntityManager in a system last night. I'm still not having much luck, I think because it can't be statically referenced

#

all of the examples I've found seem to be old too so they're not helping

#

GaaammmlerYesterday at 10:53 PM
@rare umbra you get a reference from the JobComponentSystem which get it from ComponentSystemBase as a reference
public EntityManager EntityManager { get; }

#

not sure quite where to use this

#

haven't seen it in any of the examples

#

weird, compiler was throwing me errors

#

I'll try it again

safe lintel
#

if it still doesnt work, what does your code look like?

rare umbra
#

ok that works!

#

turns out I was putting it in the Execute function

#

turns out I need to do more reading about how jobs work 🙂

#

I was using it in Execute since that's where my entity reference is

#

yep, I'm totally confused. Hah! So OnUpdate runs once first and then OnExecute runs once for each set of matching entities?

#

sorry once for each entity that has the matching components?

#

doh

#

Execute, not OnExecute

#

nah, I need to find a component of a certain type that's not a component that's part of the system

#

ok so full explanation:
I'm creating an entity with the component "transactionrequest" as a "message" when the user purchases something. It contains fields: WalletEntityReference and ItemReference

My system needs to run on the wallet component (to deduct the currency), but it needs to read data from the item (the cost)

#

finding the item data is what I'm struggling with, since I don't know how to fetch it from OnUpdate without the entity reference, which I can get from the job

#

yes, entities that contain WalletComponent and ItemComponent respectively

#

yep, exactly

#

yup

#

ok, I'll try that

#

I've probably missed a fundamental concept somewhere

#

derp

#

ok, and does the walletData field have to be [ReadOnly]?

#

yeah, I deliberately left it out but I'm getting an InvalidOperationException "walletData is not declared [ReadOnly]"

#

yep 2 secs

#

normal job will be fine 🙂

#

I just used the editor "create" option under ECS-> System

#

so it's just the default

#

thanks! I really appreciate it

#

simpler is better!

safe lintel
#

assuming you have all safety checks and leak detection on, using the NativeDisableParallelForRestriction attribute and you do have a situation where multiple threads attempt to write to the same index, will it give you an error?

#

are you just overwriting data or will it cause other issues?

rare umbra
#

@digital scarab that works great! Thanks 🙂

rare umbra
#

@digital scarab like I said I really appreciate it! adding the functionality now and it's working great! Until that is I have multiple PurchaseRequestComponents. Looks like the data on the wallet is never being updated on the wallet component, just copied locally. Is that correct?

safe lintel
#

i actually dont know what happens? im trying to make a system that specifically causes one to see the result but it seems like nothing bad is happening?

#

oh ok, i can live with that (personally :D)

#

but one last followup if i am always using the entity supplied from IJobForEachWithEntity and setting ComponentDataFromEntity[entity] (with the disable parallelfor restriction attribute) that wont cause a race condition right?

#

oh if i also need to set the data of another entity not from the same query set in the ForEach

rare umbra
#

@digital scarab you lost me on the last step there, but I gotta turn in unfortunately

#

thanks again for the help

#

great, thanks!

safe lintel
#

dont suppose it can cause any issues with job scheduling stability? like largeish stalls?

#

ive been using it liberally, without much thought until just now

safe lintel
#

thanks @digital scarab 👍 was trying to think of more oddball questions before bed but coming up short

onyx mist
#

is i job chunk faster than i job foreach with entity?

#

even after watching a few unity talks, reading the docu, and searching this discord i cant seem to find the purpose of ijobchunk

#

sorry if i overlooked something obvious

onyx mist
#

"Skipping chunks with unchanged entities"

#

yes, and only this strikes me as a possible usage

#

i know thats wrong but

#

ohhh

#

ok im starting to get it thank you

amber flicker
#

I’m of the opinion that IJobChunk should be the first jobs you make. Then foreach, IJobxxx... all make sense and are much less magical. Too often it seems to be the last type of job people learn/are taught. I wonder if anyone else shares that opinion or if it’s just me?

slow epoch
#

I'm confused about how IJobChunk pass the chunks that you need?

#

Oh okay sorry i've seen it

#

It's in the last part of the link you have pasted

amber flicker
#

haha wow, that's an extreme analogy. It could be quicker to get up and running which has value - but I think it quickly makes more complicated things feel mystical ¯_(ツ)_/¯

slow epoch
#

Depending on the person it's better to start in a more "magical" but easier way and once he has a better knowledge jump to more controlled but complicated stuff

#

It's in a different magnitude, but both (IJobChunk and making an engine) are about low level and high level api

amber flicker
#

I think if the comparison was the ease of mb Update() and IJobChunk...sure.. but I really don't have the impression you can get that far with ECS & ForEach without having to understand a lot. Like how far can you get before you have to understand why you can't use CDFE as well as IComponentData of the same type. Or why the read/write rules for containers etc are as they are. It could be that you can get a lot further than I presume. My perspective is given I think you're going to learn mostly the same things in the end, I'm of the opinion that it'd be quicker and more straight forward to start with what's needed to understand IJobChunk but I appreciate others opinions on this.

prime cipher
#

I have created a System which inherits from JobComponentSystem, implementing a Job with IJobForEachEntity. No compiler nor Runtime errors shown. The OnCreate() method gets called, but OnUpdate() is never called, nor is the System in the EntityDebugger. I'm killing myself trying to find the reason, but probably lack some experience. What can be reasons for this behaviour?

amber flicker
#

A job will only run if it thinks it needs to - usually this is implied from an entity query - if your job schedules on a query then if there are entites it will run, if there aren't, it won't. I don't know but I suspect this could be why. Basically you either want to add either something like an [AlwaysExecute] attribute (I don't remember the exact name) or else make the job run on a query. Others might know if there's an alternate way or other potential issue.

prime cipher
#

@amber flicker That is what I also thought initially, but entity debugger shows during runtime, that I have an existing entity for the IJobForEach<entity>

amber flicker
#

@prime cipher maybe just try adding [AlwaysUpdateSystem] above your system and see if it runs

prime cipher
#

@amber flicker Indeed, it does. Weird

#

@digital scarab nope, just using '''struct BirdManagerJob : IJobForEachWithEntity<Birds>'''

#

I have an additional query, to get the count of other entities then <Birds>, but thought declaring the IJobForEachWithEntity would be enough for the system to fire up the job, as the query for the others is only used during job execution and not a dependency for the system

#

@digital scarab This seems to be the reason, if I remove the query, the system runs w/o AlwaysRun. Weird, intention was to check for a specific count of entities and if not reached, spawn new ones. This means, initially the query will yield an empty result.

#

@digital scarab @amber flicker THX

amber flicker
#

(sorry, took a call) - glad you got to the bottom of it 👍

prime cipher
#

It looks like the Conversion only auto converts MeshRenderer but not yet SkinnedMeshRenderer. Or did someone got the latter one used in a prefab or subscene yet?

amber flicker
#

Only meshrenderer is supported atm.

frosty siren
#

And ~70% of cpu calc in my project are in SkinnedMeshRenderer/Animator/NavMeshAgent

frosty siren
#

with skinned mesh renderers?

solar spire
#

Yes

dull copper
#

soon™

little tartan
#

Hi guys
I have a question:
In unity 2018 I was able to Inject a serverside system into a clientside system to share functionallity between the two like so:

[Inject] CellGridSystem m_CellGridSystem;

now since Injection has gone the way of the dodo is there a recommended way of sharing functionallity between server and clientside systems? (systems residing in different worlds)

mystic mountain
#

Has the dots sample been released yet?

little tartan
#

anyone?

little tartan
#

so I have two worlds and I'm trying to use a method from a system that runs in WorldA in a system that runs in WorldB

#

so World.GetExistingSystem() does not do the trick since the system im trying to get is in another world

little tartan
#

okay I'll try making the method static thanks

amber flicker
#

Anyone familiar with the conversion workflow? I need my children to have been converted before the root GO's conversion - how do you specify order? I'm also a bit surprised the children being created first isn't the default.

coarse turtle
#

I think you may have to create your own ConversionSystem to go through the children first and then reconstruct the hierarchy in its entities' format

pliant pike
#

I'm curious about that as well if you have several Conversionsystems how do you define the order

amber flicker
#

thinking about it.. my issue may be solved through creating data placeholders for all the initialization and then having a system run after the conversion that does the second step/instantiation - I wonder if more broadly this is the better way to think about it - order dependency in Conversion Systems sounds like a nightmare good to avoid

coarse turtle
#

afaik there were attributes so you can add ConversionSystems in

  • GameObjectBeforeConversionGroup
  • GameObjectConversion
  • GameObjectAfterConversionGroup

I havent tried adding multiple conversions in the same UpdateGroup yet

amber flicker
#

hmm I see from TransformConversion that there's e.g. [UpdateInGroup(typeof(GameObjectBeforeConversionGroup))]

coarse turtle
#

yep - those were the attributes - sorry I couldnt remember how those system groups were named exactly

amber flicker
#

huh, using GameObjectAfterConversionGroup was actually much more straight forward than I expected

night cargo
#

How do you guys store strings in IComponentData?

slow epoch
#

NativeString i think it's called

#

Yeah, NativeString64, 512 and 4096

deft niche
#

Damn it...still no update for entities package yet!! 😐

old pulsar
#

@night cargo Short answer is you can't have strings in IComponentData structs. I believe they just added IComponentData classes, which do allow strings and any reference types, but these class components are not stored directly in the chunks and so require relatively expensive lookups. There's also shared components which allow for reference types, but the docs say that may change in the future.

amber flicker
#

Awesome - looking forward to taking a look at the video - I was getting tempted to make something myself 😅

old pulsar
#

If anyone spots a mistake in the videos, please let me know.

icy quartz
#

@old pulsar I see you using World.Active.EntityManager, is there a reason you're not just using the accessor inherited from ComponentSystemBase?

old pulsar
#

@icy quartz no reason other than I probably copied the basis of that example from old code

icy quartz
#

Ah okay, was just wondering if there was some bug that I'd missed that ruined perf or something haha

craggy orbit
#

hey all. im getting back into DOTS and am having some trouble. the magenta object in the image has a mesh filter+renderer, a Physics Shape (which i think is pretty much a DOTS-based collider?), and a Convert to Entity script attached. the top screenshot is how it's supposed to look, and the bottom is what happens when i enter play mode. it seems that the mesh filter converts properly but not the material. i've tried removing the collider just in case it was that for some reason and i got the same result. also, before i messed with the mesh in Blender a bit, the entity's rotation was reset (i'm assuming it would have reset the translation and scale too if i used those). i'm using the latest Unity 2019.3 beta (b9) and all of my DOTS packages are up to date (afaik). i'm also using the URP and haven't checked if it works without the pipeline. the material for the magenta object has a shader made in Shader Graph. any ideas as to where i could be going wrong? please mention me so i don't miss it. thank you 🙂

#

forgot to mention that this is what appears in the entity debugger. an error also appears when i click on the entity in the debugger. here's the first line:
InvalidCastException: Specified cast is not valid.
and the entire error in the console:
https://hastebin.com/lesipuvadi.pl
though from what i can tell, it might have something to do with the debugger

craggy orbit
#

suddenly getting shader errors when entering play mode, even though it compiles fine for editing purposes 🤔

craggy orbit
#

another update on the situation. i tried just changing the master node in the shader from PBR to Unlit and it works. no error magenta. isn't the Hybrid Renderer supposed to support lighting and such?

craggy orbit
#

ah i wasn't aware of that when i started. thank you for confirming my suspicion 🙂

safe lintel
#

with the entity debugger error make sure your properties package is at least 0.6.4

plain cloak
#

how do i install properties 0.6.4? it is shown on dependencies but can't find it on package manager

#

is it built-in?

solar spire
#

just to be sure, if it's in your dependencies already you know it's in your project

stuck hatch
#

Open the manifest file (/Packages/manifest.json) and add "com.unity.properties": "0.6.4-preview",

plain cloak
#

@solar spire i meant 0.6.2 is on dependencies but can't upgrade. @stuck hatch thanks will try

stuck hatch
#

I had the same issue 😉

plain cloak
#

thanks a lot, no more errors

naive parrot
#

whats the ETA on dots animations?

solar spire
#

soon

amber flicker
#

@old pulsar best videos I've seen so far - good job👍 - tiny tiny thing (I guess you already know and choose your explanation for brevity) but I think entity (0,0) is reserved for null so the first entity you create will be entity(0,1)

mystic mountain
#

When doing "one time runs" through systems, like events. Do you usually duplicate data needed to run this, or use a combination of components?
My current thing that I have is , ClientData { long clientID}. But I do events like FindServerData() { float time, flong characterID) , - which is only used for triggering a sendSystem, but needs ClientData as well for the clientID. Would you duplicate the clientID for that event? (ClientID is used in other places as well, and is not changing during it's lifetime).

sharp nacelle
#

Hey guys!
Anyone knows where can I find an up-to-date code-snippet or documentation or tutorial or anything that explains how you are supposed to use EntityCommandBuffers from jobs? I find a lot of code using the outdated [Inject] stuff and would like to find something simple and up to date.
thanks in advance for the help 🙂

#

ah I see. so this BeginInitializationEntityCommandBufferSystem is something provided? Because I saw a lot of talk about barriers etc but no example of code for them.

thanks for the help btw

mystic mountain
#

DynamicBuffers vs creating new entities for events that are consumed? What are the arguments for using which?

sharp nacelle
#

@digital scarab I see. I will take a look into it to find which one suits my use case best. All I want to do is add a component to an entity from a job 😄

#

good to know 🙂 thank you!

prisma anchor
#

I want to make a random spawner. Is it possible to have component data containing an array of entities to be randomly created. or some other way of getting the data for the job?

amber flicker
#

an entity can have a buffer (which can be read by a job) and a buffer element can store an entity

tawdry tree
#

So you randomly pick among some presets? Or random pick components to piece together?

deft niche
#

sigh...no update today as well 😐

mystic mountain
#

I feel ya

hollow sorrel
dull copper
stable fog
#

hmm, is it possible to use the new unity physics in 2018.3?

#

I've been trying to mod Risk of Rain 2's baking system so that it uses jobs, but there is no OverlapCapsule or OverlapSphere commands like there is in the Physics class and Its caused me some trouble

#

On that same topic and in reference to the blog they state "You can switch between either solver without having to reauthor all of your content completely."
I can tell you the Gamecraft developers (FreeJam) recently have been making this transition, and the lead on that endeavor mentioned that he was pleasantly surprised by how easy the transition was.

mystic mountain
#

Anyone who got some time for some input on this? Sometimes I'm not sure if the job should be split up or not. I currently have a job that will run when a client is connecting to it (so some net-dots stuff), which checks if it's spot is reserved and then sends RCP to accept or deny (I also have a HashMap that I want to place the connection into).
https://pastebin.com/KCkrLE8F

old pulsar
#

@amber flicker thanks! was unaware about any null entity, makes sense

prisma anchor
#

@amber flicker & @tawdry tree I want to randomly spawn a list of enemies, and the buffer of entities sounds like the correct approach. Thanks.

rare umbra
#

What's the current best way to delete entities from within a system? It used to be using a barrier as far as I can remember (it was april since I last poked this)

#

still the best way? or other ways to do this from a job?

#

Oooh adding a dead tag is something I'd not thought of, doh!

#

and I'd need an ECB to add a component in the job?

coarse turtle
#

Yea

prime cipher
#

Due to the LocalToWorld TransformSystem, shouldnt an entity move into the forward direction automatically, if I change the Rotation.Value and the Translation.Value? Earlier I tend to use Transform.TransformDirection() to accomplish this.

amber flicker
#

You mean with physics or something? If you set the Translation, it should move to that position (local space) by the next frame but it would only move after that if it had a velocity (rigidbody)

prime cipher
#

@amber flicker I set Translation and Rotation. What I want to achieve is, that the object moves into the forward direction (in which it is facing with its Rotation) and I assumed due to what I read about the Conversion LocalToWorld, that it should move in World automatically always in forward direction. But it is not. Example
If I rotate by 30deg and add to the current translation (0,0,0) a vector (0,0,1) the object is moving along the z axis only in the world, not considering the rotation.

amber flicker
#

@prime cipher perhaps it's easiest just to think of it as setting the position and rotation in the Transform component of a normal gameobject. If you set the position and rotation of a gameobject, it would move to 0,0,1 and the object itself would be rotated to 30 deg (which I guess is what you're seeing). If you want to avoid calculating this yourself, you can do the same thing that you'd do with GameObjects and create a hierarchy - set the parent to 30 deg then move the child to 0,0,1 for instance.

prime cipher
#

@amber flicker What would be the ECS preferred way to calculate a vector that is rotated by a quaternion (which is what TransformDirection was doing). Then I can change the Translation to the rotated vector

amber flicker
#

@prime cipher just the way you'd do it normally but using Unity.Mathematics instead - quaternion.AxisAngle(axis, angle) * pos or whatever

#

@prime cipher sorry, my bad - you'll need to use math.mul( quaternion.AxisAngle(axis, angle), pos) - the implicit * won't work

prime cipher
#

@amber flicker or var forward = math.mul(rotation.Value, inputVector); as the rotation is calculated elsewhere. Thx

prime cipher
#

Some1 having a good tut or video to get a hang on the new Physics thingy?

dull copper
#

@prime cipher I'd recommend checking the official docs and DOTS sample repo first, it has separate physics samples

#

you can find links to both on the pinned message here

gusty comet
#

just figured out something about DOTS that was kind of an eye opener.
I've got a parent GameObject with child GameObjects that I convert to Entity, but I convert those children manually within a mono of the parent object (IConvertGameObjectToEntity:Convert...). The whole reason why: I need to build a dynamic buffer of the related child Entitys to use as look-up keys later (i.e. for ComponentDataFromEntity).
The problem came in because I was doing stuff in this order

-For loop
---Entity childEntity = Create child entity
---Setup child entity (add all necessary componentdatas)
---Add bufferelement to buffer, with value = childEntity```It gave me errors about a NativeArray being disposed, and I couldn't understand what was going wrong until I recalled reading about sync points
By creating & setup the child entitys, I was apparently invalidating the buffer accessor
So instead what needed to be done
```-Create a NativeArray of the buffer's bufferelement type, sized to fit the number of child entitys
-For loop
---Entity childEntity = Create child entity
---Setup child entity (add all necessary componentdatas)
---Assign to NativeArray
-Add the buffer to the parent entity
-Use AddRange(NativeArray) to add all of the buffer elements```After that I'd just destroy the child GameObjects
stable fog
#

I'm curious why not just add a SharedComponentData that groups these child entities for lookup?

gusty comet
#

I'm not trying to access all of those child entities of the same archetype necessarily (the children may have different icomponentdatas), I'm trying to access them when they have the same parent. If I do that to split it up on a per-parent basis, I'd end up with a very large amount of chunks

stable fog
#

yeah, that sounds like a good case for a ScD to me

#

ah I see, so you have many parents

gusty comet
#

yea, it's for a trigger system

#

just experimenting with this "pattern" I guess

safe lintel
#

i think i had issues where I couldnt do
var buffer = dstManager.AddBuffer<Child>(entity); buffer.Add(childEntity)
but instead I had to do
dstManager.AddBuffer<Child>(entity); var buffer = dstManager.GetBuffer<Child>(entity); buffer.Add(childEntity);

solemn ice
#

I have a quaternion rotation but I only want to keep the rotation around y (it shouldn't really rotate much in the other directions anyway). Normally I'd just get the Euler angles and get the y part, but the mathematics package doesn't seem to have a conversion from quaternion to euler angles.

slate breach
#

Is there any way to check if an entity has a dynamic buffer of a certain type?

safe lintel
#

@solemn ice there is the RotationEuler(XYZ/variations) & PostRotationEuler(XYZ/variations) components which might be what you're looking for, transform docs have more info

slate breach
#

Vector3 rotationEuler = ((Quaternion)rotation.Value).eulerAngles;

#

is what I've been doing

safe lintel
#

@slate breach i think you can query with EntityManager.HasComponent or you could use BufferFromEntity and query if(buffer.Exists(targetentity))

slate breach
#

You can cast the ecs lowercase Unity.mathematics.quaternion to the uppercase UnityEngine.Quaternion which has the euler angles @solemn ice

#

I'll see is hascomponent works

safe lintel
#

is this mainthread or job check?

slate breach
#

main thread

solemn ice
#

It seems to actually work in a job, even in burst. Probably suboptimal as hell, but I don't have to process it on many entities, so...

slate breach
#

Haha, yeah I have no idea if that's the best option but it was I apparently came up with a few months ago.

solemn ice
#

Yeah, there's a thread in the forums that says it doesn't exists since there's no use for it, but I would beg to differ.

plain cloak
#

you could query for RotationEulerXYZ instead of Rotation

slate breach
#

That does seem like it would be better.

solemn ice
#

It's not something I read/write on a converted transform, it's just something I need to calculate in a system

#

The cast to Quaternion seems to be the only way to do what I need, short of making my own method. Anyway, I'll use that for now, thanks!

gusty comet
#

@safe lintel yea that's another solution (getting the buffer), although when you do AddBuffer it already returns the buffer so there shouldn't be a need to do GetBuffer right after that. You probably only have to GetBuffer if you create/destroy an entity (and maybe even add componentdata) while you're trying to assign to that buffer, such as within a loop

safe lintel
#

it does return the buffer, but i get the nativearray deallocated errors when i try to use it that way, was just highlighting that in case that was what you were encountering(hmm maybe i should bug report that)

slate breach
#

I have the same problem, I'm not sure what causes it to get deallocated, some cases it does when I'm working with a buffer and sometimes it doesn't.

dusky wind
#

Does anyone know if you can substitute UDP for another transport level protocol in the networking package?

safe lintel
#

i guess its my turn, another day goes by without the fabled entities release 😦

frosty siren
#

I use CopyTransformFromGameObject on my Hybrid Entity, but it seems system copy position directly to LTW and LTW has no auto sync with Translation. So i have 2 approaches: 1) Sync LTW with Translation 2) Get LTW instead of Translation in every job that need to know entity position
What way is more performant?

slate breach
#

If you have an entity with a Parent component, is there a way to find it's absolute position? The translation gives me the position relative to it's parent.

frosty siren
#

@slate breach As i understand u can use LocalToWorld.Position

slate breach
#

That didn't seem to work. But I can try again, I might have been doing something else wrong.

frosty siren
#

is it pure entity?

slate breach
#

yes

#

yeah its still giving me the relative position

frosty siren
slate breach
#

I see the appropriate value in the local to world component in the entity inspector.

#

But when I log it or breakpoint it or try to actually use it its the wrong value.

frosty siren
#

can u post ur code?

coarse turtle
#

it could be that the system responsible to update the LocalToWorld position hasn't ran yet on the child entity

slate breach
#

That is entirely possible, this is operating on newly created entities. Let me see.

frosty siren
#

What the best practice to get entity position now? Using LWT.Position because it relative?

slate breach
#

Wow that was it @coarse turtle

#

I used an UpdateAfter the transform group and it worked

coarse turtle
#

@frosty siren I still use LWT.Position if I want to get the world position

#

relative positioning I use LTP

slate breach
#

@frosty siren that thread you posted was my brother asking about the same problem months ago, and it didn't work then for the same reason. I guess I'll go update that post.

frosty siren
#

do not forget to mention the genius of psuong

#

What the differences between RequireComponent and RequireComponentTag?

slate breach
#

RequireComponentTag is for components with no values

#

One's that you would never have to read or write from.

#

Just if you care that it exists on an entity or not.

frosty siren
#

thx

slate breach
#

I would like to know if Tag components put archetypes into different chunks or not.

#

I just have no idea if there's any actual performance increase to using them or not.

frosty siren
#

While it defined like IComponentData it will

coarse turtle
#

its still worth benchmarking it in your own game tho 🙂

frosty siren
#

Tagging is still being handicapped by not able to be Burst compiled. It will be in the future. (And I will return to benchmark it, let's hope the benchmark project is still here at that time)
Is this still true?

slate breach
#

I know that you can use them in ForEach loops now and you used to be unable to.

frosty siren
#

It works now

safe lintel
#

Might as well make another system to copy the data to the translation. Its what I did and its pretty easy to copypaste the built in copytransform system and mold it to translation instead of localtoworld @frosty siren

frosty siren
#

I decided to use LTW to get position

simple ether
#

I haven't had a chance to look into DOTS yet, can anyone point me at some good starting resources?

safe lintel
#

pinned message ^
samples repo is the best starting point imo

rare umbra
#

is it possible that I can get an Entity that the component is on within a IJobForEach?

#

discovers IJobForEachWithEntity

languid stirrup
#

whats the difference between IJobParralelFor and IJobParralelForBatch apart from the addition of a startindex in the ForBatch one. I mean, if i have an array of 64000 elements, Is it better to use IJobParralelFor(64000) or 4 of the IJobParralelForBatch(x,16000) where x will be 0,1,2 and 3 respectively. ?

#

wait, where x will be 0, 16000, 32000 and 48000 respectively?

prime cipher
untold night
#

They'll have ref-based interface structs at some point so you don't have to mess with pointers as much, but when that'll happen is still up in the air

silver dragon
#

24h left: Preparing to yell at @digital scarab and call him names!😜

twin raven
#

What is happening?

fair condor
#

How far should I go to avoid archetype changes?

Having lots of components like this, means that an entity never stays in an archetype for very long, and be moved around in memory frequently as state changes and components are added and removed. But it does make it very easy to work with in ECS, it's almost like Unity is asking us to do this for everything with a one to one relationship.

    public struct MoveTowards : IComponentData
    {
        public float3 targetPosition;
    }

But if we instead did this we would avoid making changes to the archetype:

    public struct MoveTowards : IComponentData
    {
        public Entity entityToMove;
        public float3 targetPosition;
    }

But then it becomes a pain to work with, as you would have to add additional systems if a third party system ever wanted to figure out if a player is currently moving towards a target or not.

I'm curious, what are you guys doing for cases like that and why?

worldly pulsar
#

changing archetypes every now and then is fine, what you should avoid for perf reasons is changing the archetype of a large amount of entities per frame

#

so if you want to add/remove struct MoveTowardsEntity {Entity target} on user input, or AI decision, that's fine

vagrant surge
#

changing archetypes on the amount of thousands a frame is good

#

tens of thousands or more.... think about it very seriously

#

also if you change archetypes too much, you are also creating too many archetypes, and might be fragmenting stuff

#

its a case of "bench it"

fair condor
#

Hmm I'ts hard for me to think about where to draw the line, though. Because there are so many systems like that,

Take for instance an "isGrounded" state, it would be really convenient to add that as a ComponentTag also, but if you keep going down that road, you just end up with constant memory copies. It doesn't feel right :p

vagrant surge
#

thats kind of the thing. One thing that can be done is to have less monolythic entities

#

like a "child" entity that holds movement components

#

that way instead of shuffling aroudn the "main" entity, you shuffle around the "movement logic" entity

languid stirrup
#

so a nativearray<uint> when allocated memory has 0 as initial value or nulls?

vagrant surge
#

but anyway, one of the experiments i did in my own unity style ECS that i implemented, i was using tag components for culling and it was fine

#

and i was swapping on the orders of 50.000 a frame

#

the cost scales depending on your complexity of the entity you are shuffling

#

it does num-components x 2 amoutn of memcopy

#

its still just a few memcopy aroudn, so its not really that expensive

worldly pulsar
#

btw, is the Burst-ification of EntityManager in the next Entities release?

vagrant surge
#

even with constant entity shuffling around stuff will still be much faster than old system

#

its mostly that atm people are using the ecs to run 50.000 of something

fair condor
#

Hah @digital scarab That's true. But it's more out of curiosity than concern, I'm still just trying to get a grip of ECS.

Thanks for insight guys, lots of stuff to think about.

frosty siren
#

you just end up with constant memory copies. It doesn't feel right
Can someone explain for me WHY? I'm not really understand what does it mean. I just know that when u add/remove components it changes entity archetype and cause entity data copy to matching chunk. What is "constant memory copies"?

safe lintel
#

Wait less than 24 hours? 😀

dull copper
#

for what?

safe lintel
#

Am I presuming too much to assume its the entities release? What Topher posted a few hours ago

dull copper
#

I'm just going to go and assume it's delayed

#

and if not, then be happily surprised

safe lintel
#

Ah responding to someone else, knew I shouldn't have gotten my hopes up

amber flicker
#

hmm it appears that [ExcludeComponent(typeof(CompA))] works but multiple (i.e. [ExcludeComponent(typeof(CompA), typeof(CompB))]) beyond the first argument are ignored.. applied to an IJobForEachWithEntity - anyone else see this?

coarse turtle
#

@amber flicker I've certainly ran into that before sometime ago, and I ended up using IJobChunk at that time 🤔

amber flicker
#

thanks @coarse turtle .. think I'll have to do the same (was trying hard to hold on to my last non IJobChunk haha!)

safe lintel
#

that is worrying

amber flicker
#

I vaguely remember seeing something about this on forums.. who knows.. the fix might land with a new entities package in the next couple of hours 😅

#

Half joking of course but I think if it's not ready by the end of the day a revised eta is in order? So many fixes and changes that it feels like a lot of people are hanging on for...

rare umbra
#

Any nice samples out there on UI and DOtS? E.g. building a menu / scrollable list from components?

deft niche
#

Still no updates 😦 i was really hoping for something to happen today 😦

rare umbra
#

There’s still time!

floral ravine
#

Hi all, any advices on how to approach new 2D project - should i go with data oriented or object oriented? I want that my project is modular, so my thought was on object oriented with DI etc. But all the recent fuss about dod made me think and i don't really know if i should start with dod approach (dots). I'll be doing an app that will receive data from database and display it in AR, there will be also some c++ plugins and lots of loading different UIs and scenes (i do not need any physics or some other fancy stuff). Any tutorials/pointers on good dod or ood architecture in unity would be great!

safe lintel
#

dots is super modular, but there arent any builtin 2d things for sprites so that may outweigh any pros

coarse turtle
#

yea - you'd likely do an interface w/ hybrid spriterenderers

#

or write your own one off soln

#

until there's official support - as for UI, @deft niche posted the DotsUI proejct which attempts to convert uGUI to its entities format

#

I dont think UIElements is coming to runtime till late 2020

#

which I've no idea if it'll support dots immediately

#

as for tutorials/pointers on good dods - i'd look at the Unite videos on youtube and the pinned messages/samples on this channel

safe lintel
#

i think uielements should be coming soonish

#

well soon like that entities release 😆 😩

floral ravine
#

well with dots i'm afraid that i will hit a wall and i'll be stuck. Maybe its just that i'm used to oop, dunno. So you guys are already transitioning your architectures to data-oriented design or sticking with object-oriented?

coarse turtle
#

I have a 2D game im working on using dots architecture

#

the transition wasnt bad for me

#

as a lot of the old monobehaviours just became separated systems

#

and ordered that worked the same way as previous for me

floral ravine
#

Do you have some core logic which is accessible through more systems, for example logging? Currently what have i done is to have a Core scene and then load additive scenes. Core scene binded interfaces that all other scenes will use (logger, user management, etc.) which was then injected into other scenes (these scenes have their own bindings etc. which are also unbinding after scene is destroyed). Now in dots that DI is thrown out of the window if i'm not mistaken and i cannot fully wrap my mind around it on how to do this in dots.

coarse turtle
#

I do have a core scene with gameobjects that get converted to its entities format - since the entities live in the same world - it's easy to access the entities from various systems

#

and I load additive scenes when levels change - which also get converted to entities

vagrant surge
#

read the DOD book

floral ravine
#

thanks for the link @vagrant surge, will take a look. Any other tips you can give me? I'll greatly appreciate it.

vagrant surge
#

just that, really

floral ravine
#

@coarse turtle, thank you also 🙂

vagrant surge
#

its not specifically ECS, but its the same mindset and has a big overlap

floral ravine
#

yeah, i'm guessing that i really lack that knowledge.

#

Maybe the real question is, is it too soon to shift to ecs in unity? Or should i wait till it gets fully released, dunno if people are using this in production yet

coarse turtle
#

thats the first blog I read which introduced me to dod years ago

floral ravine
#

i'm just reading this now 😄

vagrant surge
#

@floral ravine any day now the new update pops

#

and that one makes ECS les horrid to use, with a bunch of syntax sugar

#

at that point, it will start to be viable for some "parts" of games

#

you would still have your main game on monobehaviors, but some stuff you can migrate to ECS, like say, projectiles

deft niche
#

Its not any day..its gonna be Today!!! hopeful * fingers crossed *

tawdry tree
#

Get ready to shout at Topher, eh?
Or hopefully not need to.

dull copper
#

doesn't look like it

safe lintel
#

get the pitchforks ready!

deft niche
#

stiff skiff
onyx mist
#

the truth is the package was released 2 weeks ago and they didnt tell anyone

#

gotta go on a treasure hunt for it

deft niche
#

gonna give up on today it seems... its close to the end of the day already now 😐

untold night
#

It's probably sometime next week.

deft niche
#

Topher lied to us! 😦

untold night
#

and I said I would post an update to my entity utility package... last week.

It will probably be next week at this rate.

#

Life (and work stuff that took higher priority and needed to be kicked out faster) happens

deft niche
#

Damn...what's the utility package ?

untold night
deft niche
#

Oooh... this is pretty cool

#

Sriptableobject Conversion

#

Thanks for the link...gonna keep my eye out for updates. It looks promising

untold night
#

thanks

#

I add to it when I need math functions that aren't already in Unity.Mathematics and such

stuck hatch
#

Hello, how do you use Arrays in Components? I am trying to create a gridCell, but Unity is complaining with "which is neither primitive nor blittable."

#

I also tried making BuildGridCellData inherit from IComponentData

plain cloak
#

either make it a BufferElementData as a separate component

#

or create a blob

#

if you are not mutating it

stuck hatch
#

do you have an example?

plain cloak
#

for buffer or blob?

#

i think in your case, you could have BuildGridCellData as IBufferElemntData

#

and keep row and column count in component

stuck hatch
#

What about "InternalBufferCapacity"

plain cloak
#

i think you can omit that

#

if you are not sure at all about the size

#

it behaves like a list

stuck hatch
#

ok, I try

plain cloak
#

and before you use the dynamic buffer

#

you can .AsNativeArray()

stuck hatch
#

@plain cloak Thank you now it works 🙂

languid stirrup
#

so, if i allocate.persistant the nativearray i pass on to a job, and just keep using that in my other code, without CopyTo some other managed type Array, and i make sure nothing is happening to this nativearray simulataneously when this job is being, I can get away with using the same native array, or should i still copy the nativearray to a managed array and dispose of the native array?

#

for me, copying the nativearray to a managed array takes about 2500 ticks, while not copying and just using that nativearray takes about 2300 ticks. and this is across 740 instances. So im not really bothered about these 200 ticks i would save. But just wondering

plain cloak
#

why do you copy to managed array in the first place?

stuck hatch
#

Hello, do you also get this error very often? "Recursive type definition detected" I am working with unity beta and after this error comes up, I have to restart unity

languid stirrup
#

@plain cloak i dont have to, i can just keep using the nativearray with persistant allocation. But in all the examples i saw, i saw ppl copied the nativearrays to plain arrays and dispose() the nativearrays

#

also i keep getting the JobAlloc temp array is older than almost 4 frame, this is most likely a memory leak warning message in unity lol

plain cloak
#

if you intend to keep using it for long term, you should use persistent allocation.

#

I dont think there is anything wrong with using native arrays as is

#

outside of jobs

#

"In IL2CPP performance of builtin array and NativeArray is on par, in mono in a build, NativeArray is slower than builtin array" quote from Joachim

languid stirrup
#

hmmm. so if my app will be IL2CPPi can keep using nativearray. but if they are going to be regular unity crossplatform apps then builtin array is the way to go

plain cloak
#

i dont know if it is worth to copy you should benchmark it imo

#

it might still be better to use native arrays

#

i personally do use native arrays instead of copying

languid stirrup
#

i did benchmark it. using just native arrays, i save about 200 ticks

#

200 ticks, per 740 instances, mind you... so that much hehe

#

fine, i will go with nativearrays then, no need copying them over and over, thnx for the discussion magni 🙂

plain cloak
white agate
#

Is there a way to alter the ECS data from a monobehaviour? Specifically for Unity.Physics (with a convert to entity script)

tawdry tree
#

Any script(including MBs)) can access entities via World.Current.EntityManager (Not 100% if that's the exact call, but the general idea stands). You are somewhat limited in how you can do things, compared to an ECS system, but should be able to do most things, one way or another.

prisma anchor
#

Hey and happy Saturday. So I have a question about setting up NativeArray and Jobs. Is there a way I can delay the job from starting until the native array is created? Or just set the component data when I create the array?

stuck saffron
#

I think its World.Active

#

@ hodhandr

prisma anchor
#

@white agate There are the components PhysicsShape and PhysicsBody is there something more you want from there?

white agate
#

Yes, I'm not sure how to access its fields from a MonoBehaviour, is that at all possible? I'm considering refactoring the game to full ECS to get the most out of Unity.Physics. (We were using PhysX for our multiplayer, relatively competitive, physics game; which started showing its ugly indeterminism in our prototype).

#

Another thing I've considered is using Bullet, but I figure we might as well make the jump to ECS because the plan is multi year support for the game

prisma anchor
#

I haven't gotten too far into the UnityPhysics besides movement and collisions, I do everything in ECS and really only use MonoBehaviours for setting values i.e IConvertGameObjectToEntity.

#

But if you're trying to change the component data during runtime you can just use the entity manger to set that data. i.e manager.SetComponentData(entity, new PhysicsCollider() {...});

white agate
#

Makes sense, thanks. I was told it'd be possible to use Unity.Physics without any ECS, but it seems like at least hybrid is necessary to get it going

#

Is ECS a good choice, in your opinion, for a project looking to launch mid next year?

#

I really like it but am afraid of its stability for production

prisma anchor
#

I would say yea. I was going to start doing a 3d top down multiplayer shooter in ECS. Then I realized I want to finish a project in ECS. :/ lol. So right now I'm doing a brick breaker game.

#

I say its way more stable now, but I don't plan on shipping this game until ECS is fully released.

white agate
#

Is there any window for an ECS release?

prisma anchor
#

not sure honestly ¯_(ツ)_/¯

white agate
#

Okay, thank you!

tawdry tree
#

I would argue that you should at least keep ECS in mind for parts of a game where ECS is the most useful, ie. when dealing with lots of stuff of things.
If you're looking for a 1.0 launch (as opposed to alpha/beta/early access) by summer 2020, I'd say probably you should not use ECS unless you're already semi-familiar with it, because of the learning factor; at least if you're familiar with monobehavior development.
It's much easier to find help for MonoBehavior issues, its better documented, and if you're also used to it...
One exception would be for a small and mechanically simple game, something that been done before, and a lot. Think tower defense. But to which degree that'd benefit from ECS... Only for learning, really.

white agate
#

Interesting; so if I understand it correctly, I could use both MonoBehaviour and ECS (hybrid) + use Unity.Physics? Or would that introduce me to a whole other world of pain? My primary goals are to switch to a deterministic physics engine and be able to support the game for a while.

#

The current prototype I have (PhysX, no ECS) has a bit too many server corrections to my liking

#

I'm sure I could improve that a bit on my end, but having a deterministic physics engine should help us along a fair bit

tawdry tree
#

Okay so, the current design-time model always uses MonoBehaviors. And from the sounds of it, it's going to stay that way. Then you have a conversion script that, on converts them to entities during build, and that's what they are on runtime.
You can make stuff that interacts between mono and ECS, and I believe the official packages, where applicable (physics...), do so.
It's generally easier (on the whole) to either go all in on DOTS (with some exceptions, such as GUI, which is much easier if you 'do work' in monoland and then communicate with ECS land), or only use DOTS, (jobs, primarily) for specific things ('lots of stuff' kinda things)

#

Note also the difference between DOTS and ECS
The Data Oriented Tech Stack(DOTS) includes ECS, jobs, and the burst compiler, so it's a superset of ECS.

white agate
#

Your input makes me think that if I want to have a public release in summer 2020, it may be best to use MonoBehaviours and Bullet right now

#

At least to achieve my aforementioned goals

tawdry tree
#

If you have lots of communication between the two of them, you will give yourself headaches, but communication between the two is hardly impossible, and some things are better(easier, faster to dev, more perf, and so forth) to do one way or the other - for a simple game the primary consideration will be learning - It is nice if you want to, but will take time

white agate
#

It's a sequel to another game that was built in another engine, there's a community waiting for it and the improvements it'll bring to the physics and networking

#

So not a small game per se

tawdry tree
#

So the question becomes: What are your primary goals (short dev time?), and what kinda game are you making

white agate
#

It's a sequel to https://store.steampowered.com/app/707680/Slapshot/
I'm okay with a longer dev time, but if the 'longer' comes from waiting for DOTS to be ready then that's not the best trade-off for the project.
My goals are to really get the most out of networking and physics before anything else, because the game really relies on those two to be viable.

#

I really like the idea behind DOTS, I'm more comfortable with that concept because I've always used non-visual game engines and that leans more towards that workflow

#

Seeing how it's still missing a lot of things makes it tough to decide if it's the right move at this time for what I'm making

tawdry tree
#

Well, you can do any logical thing in ECS that you can in mono.
You don't have as many built-in APIs and features (yet), though. GUI for one can't directly communicate with ECS, but since it's mostly just one-way bindings (button was pressed, health is X) it's pretty trivial to make work.

#

And both networking and physics are among the features of ECS that does have built-in (well, packages, but ECS is also a package).

#

I would recommend trying to make a simple multiplayer prototype using DOTS - Nothing fancy, just give each player one physics-driven character, and a couple boxes they can push around.
See how long that takes to make you, compared to the time it'd take to do the same in mono. Extrapolate for making the game you want to make.

#

I'm guessing you should be able to make it in a day or at least weekend, and if you can't, then ECS is probably not ideal for your project, because learning curve and tricky features. In that case, still keep its features (again, primarily jobs) in mind, while working in mono-land.

white agate
#

Makes sense, thank you

#

Looks like I've got my work cut out for the weekend 😉

tawdry tree
#

From watching most of the first video on the steam page, your project looks exceedingly simple, mechanically speaking, meaning if you could do that basic work, you're like 90% there, but of course the last 10% is polish and tweaks that takes 90% of the time 😛

white agate
#

Yep, very true

tawdry tree
#

But the bright side is that means it wouldn't take long to know that it wouldn't work out, hence the mini-project

stable fog
#

Is it possible to create raycastcommands in a job if you need to schedule a large number of them?

stuck hatch
#

Hello, I am asking myself is this a good way to go or not? World.Active.GetOrCreateSystem<WalkableAreaSystem>().Data
I just want to allow all entites access to a specific set of data

safe lintel
#

might be better to create an entity with that data, to reduce hard coupling with systems

#

also yes you can create raycast commands in a job, but when it comes to scheduling RaycastCommands.Schedule that can only be done on the mainthread

candid bough
#

cant wait for dots netcode sample mentioned in copenhagen

prisma anchor
#

Now that I've added [DisableAutoCreation] on my system and create it using World.Active, it has stopped updating. Any ideas? The data for the job is there

tawdry tree
#

Have you verified that the system is, indeed created?

prisma anchor
#

yea, i set a breakpoint on OnCreate.. that works

#

It doesn't show in the Entity Debugger under the active world, or any*

tawdry tree
#

I meant in the entity debugger, that's the important one

prisma anchor
#

Oh in that case, no I don't see it

tawdry tree
#

How are you creating the system?

prisma anchor
#

world.CreateSystem<BrickLayoutSystem>(brickEntities);

tawdry tree
#

brickEntities being of type?

prisma anchor
#

no, create system says: param object[] constructor args

#

public T CreateSystem<T>(params object[] constructorArguments) where T : ComponentSystemBase;

tawdry tree
#

No, I meant what type is brickEntities? What would typeof(brickEntities) return?

prisma anchor
#

oh, sorry. NativeArray<Entities>

tawdry tree
#

I must admit I'm not familiar with creating systems with that constructor overload. Have you tried moving whatever code requires the argument to a separate method, and call an empty constructor, then the initialization method?

prisma anchor
#

Yea, I tried that already. I was setting the entity array via the system's property

tawdry tree
#

And that also doesn't make it appear in the entity debugger?

prisma anchor
#

Yea, that way doesn't work. I saw in the FPS Demo that they were using Disable Auto create attribute to create there systems. Maybe look at that codebase to see what I'm doing wrong

tawdry tree
#

Non-default system creation seems to be a tricky thing

prisma anchor
#

lol I'll let you know if I figure it out!

prisma anchor
#

@tawdry tree , and everyone else. you need to call update on the system. That was the problem.

stiff skiff
#

You need to add the created system to a SystemGroup, otherwise it wont automatically update

#

the Initialize, Simulate, and Presentation groups are the only ones who's Update function is added to the PlayerLoop (and will thus be called each frame)

#

These groups will call the update of each system in those group.

rare umbra
#

So I have a system which adds a ‘Dead’ component to an entity and another system which deletes entities with the ‘Dead’ component. Only trouble is that they seem to run out of sequence. The deletion system seems to run twice for each entity that gets tagged with the Dead component

#

Any ideas for how I debug?

#

I can do some checks for null to prevent the exceptions but I’d much rather figure out why it’s firing twice. It’s as if it starts running again before the barrier delete is fired

rare umbra
#

actually that's not the problem, it's the opposite way around...

#

The entities are being flagged for delete twice, and then I'm getting an error that the component "Dead" has already been added

#

which is weird since it should be destroyed first

coarse turtle
#

Hmm I guess you could ensure that you only add "Dead" to entities that don't have the "Dead" component tag already

#

I think another way is to reorder the jobs so that - you clean all entities with dead component first - and you add dead component tags to new entities that need to be marked for deletion

#

so the former would have the [ExcludeComponent(typeof(Dead))] on its job

prisma anchor
#

Ah, I see @stiff skiff. Thanks.

rare umbra
#

@coarse turtle I tried the second option, as to me it's an order of execution problem... problem is that I'm trying to flag them for delete twice before I do the delete.

Here are my logs:
Flagging for delete: Entity(3:1)
Flagging for delete: Entity(4:1)
Flagging for delete: Entity(3:1)
Delete Entity: Entity(3:1)
Flagging for delete: Entity(4:1)
Delete Entity: Entity(4:1)
EXCEPTION: The entity does not exist <-Seems to be the flagging for delete that caused this

#

m_Barrier = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();

That's the part in the flow where it's updating the entity

coarse turtle
#

hmm and both jobs are using the EndSimulationEntityCommandBufferSystem?

rare umbra
#

yup

coarse turtle
#

the jobs are chained too?

rare umbra
#

Dead Entity Cleanup has: [UpdateBefore(typeof(VendorTransaction))]

#

and the other one has [UpdateAfter(typeof(DeadEntityCleanup))]

#

I can put these on pastebin if it helps?

coarse turtle
#

sure

coarse turtle
#
        var transactionComponents = PurchaseQuery.ToComponentDataArray<PurchaseRequestComponent>(Allocator.TempJob);
        var walletComponents = GetComponentDataFromEntity<WalletComponent>();
        var vendorOfferComponents = GetComponentDataFromEntity<VendorOfferComponent>();

So I think these lines might be the issue - so the CleanUp job is only scheduled and then you move onto your transaction job, so deletion hasn't happened yet. You're then grabbing the all the component data and associative entities immediately which may have the entities that need to be deleted to be copied over to its transaction job which is then scheduled to run

#

I do know that if you wanted to do a ToComponentDataArray or ToEntityArray you can pass an out var jobHandle to schedule the retrieval later instead of grabbing the componentdata/entity array immediately

#

since ToComponentDataArray(Allocator) calls JobHandle.Complete() internally

rare umbra
#

OKk 2 secs, need to get my head around this

#

lol

#

so VendorTransaction OnUpdate is happening before the cleanup job is finished?

coarse turtle
#

So I think it's more like the data including the entities that need to be deleted are being copied over

#

for the VendorTransactionJob since you're only scheduling the DeadEntityCleanUpJob - so the deletion hasn't happened yet

rare umbra
#

so I thought that scheduling it in EndSimulationEntityCommandBufferSystem meant that it'll happen before all of the Update calls?

coarse turtle
#

so when the VendorTransactionJob is being set up and scheduled, you have already copied over potential entities which may need to be deleted

#

Im not sure if it's played back immediately 🤔

#

What happens if you did a JobHandle.Complete() as the first call in your VendorTransaction system? I'm thinking that would perform the playback for the cmd buffers too and would "solve" the issue - ofc its not ideal as you're completing the previously scheduled jobs immediately

rare umbra
#

first call inside Execute()?

coarse turtle
#
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        inputDeps.Complete(); // Immediately complete previously scheduled jobs.
        var transactionComponents = PurchaseQuery.ToComponentDataArray<PurchaseRequestComponent>(Allocator.TempJob);
        var walletComponents = GetComponentDataFromEntity<WalletComponent>();
        var vendorOfferComponents = GetComponentDataFromEntity<VendorOfferComponent>();
        var commandBuffer = m_Barrier.CreateCommandBuffer().ToConcurrent();
        var myJob = new VendorTransactionJob();
        myJob.PurchaseRequests = transactionComponents;
        myJob.WalletComponents = walletComponents;
        myJob.VendorOfferComponents = vendorOfferComponents;
        myJob.CommandBuffer = commandBuffer;
       
        var myJobHandle = myJob.Schedule(inputDeps);        
        m_Barrier.AddJobHandleForProducer(myJobHandle);
 
        return myJobHandle;
       
    }
#

so the first effective call in the OnUpdate(JobHandle inputDeps) function

rare umbra
#

Flagging for delete: Entity(3:1)
Flagging for delete: Entity(4:1)
Flagging for delete: Entity(3:1)
Flagging for delete: Entity(4:1)
Delete Entity: Entity(3:1)
Delete Entity: Entity(4:1)
Exception

coarse turtle
#

hmm

rare umbra
#

it's as if the vendor system is running twice before the deletion happens

coarse turtle
#

Would it make sense to reverse the order?

  • DoTransaction
    • Only add Dead component to entities that do not exclusively have "dead" component?
  • Cleanup all dead entities after transaction
rare umbra
#

yeah, I'm being a little lazy by not checking if they already have the component - 1 because I don't have access to the entity and 2) because I don't want it to mask this issue

#

the first 2 lines of my logs are contradicting my UpdateBefore / After

coarse turtle
#

Yea - that makes sense

rare umbra
#
Dead Entity Cleanup - On Update
Vendor - On Update

Vendor Transaction: [UpdateBefore(typeof(DeadEntityCleanup))]
Dead Entity Cleanup: [UpdateAfter(typeof(VendorTransaction))] ```
#

seems out of order, right?

coarse turtle
#

yea

rare umbra
#

maybe I'm using those tags wrong, or in the wrong place or something :/

coarse turtle
#

Certainly looks right

#

hmm what if you made your own CommandBufferSystem that's used for the 2 jobs 🤔

#

I'm wondering how much the CommandBuffer is recording

rare umbra
#

never done that

coarse turtle
#
public class SomeCommandBufferSystem : EntityCommandBufferSystem { }

World.Active.GetOrCreateSystem<SomeCommandBufferSystem>(); // You'd use this instead of EndSimulationCommandBufferSystem
rare umbra
coarse turtle
#

Hmm 🤔 okay

rare umbra
#

sorry, don't mean to be a pita

coarse turtle
#

it's cool - Im curious about this too

rare umbra
#

seem to be in the right order here

#

command buffers seem to be before the systems are run

#

bah, I'm going to let this beat me for tonight

#

thanks for the help, going to head to bed o/

coarse turtle
#

np - I'll sleep on it too haha

onyx mist
#

is including the writeonly attribute necessary

#

i know that readonly helps jobs go faster cause it disables some safety thingies

#

also is randjob.nextx(min, max) inclusive or exclusive?

#

cant find info on the docu

magic frigate
#

Are buffer elements supported by Visual Scripting yet? Can't seem to get a node related to them

fair condor
#

Anyone know if there is a way to hook into the conversion pipeline on a per-world basis, and not a per-entity? An alternative to IConvertGameObjectToEntity, that doesn't require a gameobject.

safe lintel
#

@fair condor maybe look into how subscenes are created given that they dont need individual ConvertToEntity scripts

pliant pike
#

yeah maybe try using GameObjectConversionSystem?

gusty comet
#

Hey, guys. Trying to wrap my head around ECS by making a simple tower defence game. How should I approach this task in a DOTS way? I want to have a collection of waypoints that enemy characters should traverse, one after another. The way I'm thinking about the task now is:

  1. Make an authoring script (say, WaypointCollectionAuthoring) with an array of Transforms, so that I could assign them in the editor.
  2. The same script should implement IConvertGameObjectToEntity and in the Convert method make a List<Translation> out of the Transform array.
  3. Assign that array to a property of a WaypointCollection shared (?) component.
  4. Each enemy will store the current index of the list, starting with 0, and will switch to the next one upon reaching current target waypoint via a dedicated system.

Is it a viable approach? Am I missing something? Thanks in advance!

safe lintel
#

i would store the waypoints in a dynamic buffer

#

but other options are a blobasset

pliant pike
#

yeah I'm using a blob for my waypoints

safe lintel
#

i dont think you want shared component in this case

gusty comet
#

Could you point me to an example or maybe post some code?

pliant pike
#

thats what I used to figure it out they have the node project on github

gusty comet
#

Cool, thanks!

tawdry tree
#

Honestly, in a tower defense with static routes (does not change during runtime) any kind of array will do, so the simplest that works in DOTS (including burst?) would be ideal. Haven't used arrays in jobs before, so don't know if 'vanilla' arrays work for that.

pliant pike
#

that's true I kind of need the nodes system because I have multiple routes

prisma anchor
#

I want to see if I have the correct understanding: I want a job that handles collisions of two entities. So I make two EntityQuery's for each entity and use an IJob to handle the logic?

vagrant surge
#

thats the straight use case of blob assets

#

and even the literal example for them (static level waypoints)

safe lintel
#

i tend to think of tower defense things as having changeable waypoints, to redirect the flow of enemies

vagrant surge
#

there are 2 main kinds of tower defense games

#

those where there is a VERY fixed path, and then you defend it with towers (cant block)

#

and those with more freeform terrain that let you put barriers

dry dune
#

the best tower defense game I saw is a Bad North by https://twitter.com/osksta

Gamedev. Made @BadNorthGame with @rtm223 and @MartinKvale (available on most platforms). Now working on a procedural town building toy

Tweets

4953

Followers

39676

safe lintel
#

anyone ever play those old matrix defence tower defence maps in starcraft 1?

gusty comet
#

no news on the next entities release?

silver dragon
slow epoch
#

I'm equally excited and scared of what the new entities package is gonna have/modify

dull copper
#

I haven't touched dots since last Unite as been waiting for new release :p

#

I doubt the changes will be monumental but I don't like doing extra work all the time (like you do all the time when you use dots and new updates come along)

gusty comet
#

this should be the preview for the 1.0 release though right?

#

didn't they say in the last roadmap talk that ecs burst jobs would be 1.0 with 19.3?

dull copper
#

well, jobs and burst have been released already

#

but I think they had some target like this for the actual entities package

#

it'll still take years for the other packages to catch up tho

#

and of course, these are not set to stone

#

we've seen dates get shifted for over year from some earlier estimates

#

(not for ECS but in general on these roadmaps)

#

from same slides:
DOTS Netcode: 2020.1
DOTS Physics 2019.3
DOTS Audio 2020.1 (experimental)

remote coyote
#

Netcode 0.0.1 preview 4?

#

😯

remote coyote
#

This code has [GenerateAuthoringComponent]

#

😮

slow epoch
dull copper
#
"registry": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"```
#

😄

#

well, I noticed Unity stopped using old staging altogether

#

I guess too many people started using it

#

now they are on fully internal loop again

remote coyote
#

yeh

#

are you able to import those packages?

#

or is this just internal to unity devs?

#

I'm at work and haven't had a chance to try it out yet 😄

#

[UpdateInWorld(UpdateInWorld.TargetWorld.Default)]

#

Is this new too?

#

Can't say I've seen this before

slow epoch
#

I think so

remote coyote
#

RequireSingletonForUpdate<InitGameComponent>();

#

Nice filter simplification in ComponentSystem. Not sure this was here earlier either.

remote coyote
#

[GhostDefaultField(10, false)]

#

Access to 'https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates/com.unity.burst' was denied

#

bah

slow epoch
#

What GhostDefaultField is supposed to do?

remote coyote
#

It populates the ghost collection I presume

#

on the Netcode Alpha you had to go to the prefab of what you wanted to ghost, and add the fields there

#

now we can do it with attributes from code it looks like

slow epoch
#

Oh okay

#

I have 0 idea about networking so i suppose i should look at other stuff first to get that

remote coyote
#

We'll just have to wait for the release anyway. We don't have access to their internal package registry, sadly.

dull copper
#

well, at least we know Entities will get bump from 0.1 to 0.2 on next package

#

(no surprises there tho)

stable fog
#

was here an update?

slow epoch
#

Just some examples that use new stuff that we cannot use yet

deft niche
#

Wow..the tease is driving me crazy!! 😐 just showing us something that we cant use!

safe lintel
#

pretty eagle eyed to spot that repo package update 🙂

vagrant surge
#

@dull copper the singleton for update thing was long needed

safe lintel
#

whats that about singleton for update?

vagrant surge
#

RequireSingletonForUpdate<InitGameComponent>();

safe lintel
#

ah

#

think thats essentially the same as If(HasSingleton<InitGameComponent>())?

vagrant surge
#

maybe its a bit more optimal than that

#

like not even scheduling the system if that component doesnt exist

dull copper
stable fog
#

My favorite game is programming

worldly pulsar
#

wait, RequireSingletonForUpdate<> was there for a while now

safe lintel
#

were all waiting, let the memes flow 🙂

tawdry tree
#

...there are no mods around, right...?

dusty scarab
#

Just an amateur question.. 6 months into Unity should I pursue DOTS or continue to work on the basic stuff?

coarse turtle
#

I think once you get the basic workflow down in Unity - you can try jumping into dots - but the workflow might change with major releases

deft niche
#

Probably better to continue working with basic stuff. You will have a better understanding on how to author components based on existing functionality that unity has.

dusty scarab
#

I'm pretty proficient in creating the basic functionality of whatever game I want to make. Dirty code, but it works

deft niche
#

If the entities package was ready for production, i would have given a different answer 😛

dusty scarab
#

And i tried understanding ECS via videos but there is a complete lack of them save for some which just go over some part

deft niche
#

Thats the thing. I think its better to learn it once it is actually production ready feature.

#

if you have just started working in unity that is..

night cargo
#

The best learning environment is when there's plenty of examples, plugins and community discussions on the subject you are willing to learn on. You'll find much more help in non-DOTS world at the moment. If you are willing to learn DOTS I'd suggest starting with Code Monkeys video series on it. Pretty much the best tutorial out there.

dusty scarab
#

@night cargo I tried the code monkey tutorials, but even after multiple attempts didn't really get the whole essence of what exactly is happening. I understand the architecture and what is supposed to happen but not how

#

@deft niche working on both at the moment. Will probably switch back to traditional methods in a while

#

Is Entities package documented yet?

night cargo
#

We've been using Unity for 8 years now and adopting DOTS is still a challenge for our organization. I'd suggest you stick to the traditional approach as Unity DOTS won't be completely production-ready until end of 2021. Anything regarding Animations and UI are far from being integrated into the DOTS world.

dusty scarab
#

All right. One last thing, apart from video tutorials any place you would suggest I could get studying material on dots?

dull copper
#

@dusty scarab you can find docs linked in the pinned message here

#

also most video tutorials you'll find will be horribly outdated

#

look for the official manual + official DOTS sample repo, they are kept up-to-date

#

both are linked on the pinned msg

dusty scarab
#

Got it! Thanks. Didn't see the pinned messages before, that should get me started i think 😅

dull copper
#

@dusty scarab tbh, if you are just now diving into DOTS, I'd wait for a week or so

#

new entities package will release any day now and it's going to have API changes again

#

plus if they really did what they planned to do, then the new package usage is simpler due to less boilerplate code

#

so at this point, it's worth waiting a bit IMO

dusty scarab
#

Okay, thanks for the heads up ;)

tawdry tree
#

Honestly, if you're new to Unity and interested in ECS... just keep reading news and articles, watch videos (the unite ones are good), and pay attention in this channel to see what people get stuck on. That's what i did, for the longest time.
Sure, I played around a bit in a 'sandbox' project (basically just me making various things with no overarching plan, aside from learning), but the understanding came slowly, and then a few pieces 'click' here and there.
The Unite video on entity interaction is highly suggested, assuming you know the basic 'what's going on' of ECS. https://www.youtube.com/watch?v=KuGRkC6wzMY

Interaction is fundamental in games, both in how players interact with a game and receive responses, and in how parts of the game interact with one another. ...

▶ Play video
#

I still suggest focusing on monobehavior for now.
That said: you should be aware of, and keep in mind, the parts of the DOTS stack that is deemed production ready (non-preview).
At the current moment, that'd be jobs, and burst (which you'd use with jobs).

worldly pulsar
#

One simple thing you can do to start is attach ConvertToEntity with Inject GameObject on everything, and then instead of writing Monobehaviour.Update() methods - write a system doing Entities.Foreach((MyMonobehaviour mb) => {});
Basically nothing has to change in the way you write code/think about things, keep using mb.transform etc. You will quickly start noticing that being able to do stuff before/after the Entities.ForEach() part, or query for something more than a single monobehaviour is really powerful.

I do however agree that if you are just starting you probably want to stay on the "classic" Unity until things mature a bit.

safe lintel
#

@dusty scarab i say spend a few days trying it out(make sure to check the samples repo in the pinned messages here) and see how you like it. if you arent super well entrenched in oop programming you might find it makes more sense to you than the old way of doing things.

prisma anchor
#

I have a brick breaker game, and I want to know if my paddle is too far from the sides of the game board. I have a component for the game board, so I know the width. and I know the paddle component. Is there a way to query two different entities in order to check if the paddle's pos is beyond the board?

coarse turtle
#

you'd query the width of the board first, grab the associative data for the board

#

pass the copy of the associative data to the job or function (im not sure what your set up is) to it and check if the paddle is within the bounds of the board

prisma anchor
#

Ok, That was my understanding of it all. Thanks for the help

onyx mist
#

"population = entityQuery.CalculateEntityCount();"

#

with 0 entities why is this giving me a value of 1?

deft niche
#

Are you destroying that entity immediately ?

onyx mist
#

excuse my ignorance but why would that matter? at >0 entities i get an accurate population count

#

its just when it hits 0 that things start getting werid

safe lintel
#

the system in the debugger also shows 0 entities?

onyx mist
#

hm

#

ill reproduce the bug and see

onyx mist
#

i dont know what to make of this, but basically the query includes everyone that has an age (equivalent to saying everyone with a pulse) but excludes everyone with, well, no pulse

#

but theres no entities

#

and yet theres a ghost left

#

The code works perfectly if there's more than 0 entities, but not if there's 0 🤔

#

The UpdatePop function is just updating the GUI with the population variable

hollow scroll
#

@onyx mist what about using this.RequireForUpdate(query); in OnCreate() ?? In that way the system will only runs when you have at least 1 entity that matches the query

#

sorry, this.RequireForUpdate(entityQuery), not query

#

And it's not necessary to do the same query again on update

#

you can just use entityQuery

mystic mountain
#

Any news of the mythical dots sample yet?

slow epoch
#

Nope, yesterday we got some new git examples but we cannot use them yet

onyx mist
#

@hollow scroll thanks for the ideas! unfortunately that still doesnt solve the mystery of why at 0 entities the population is 1

amber flicker
#

@onyx mist basic q but just to ask, are you sure it's getting past if(GrossDaysCumulative == neededDay)? Perhaps UpdatePop just isn't updating the ui?

#

in fact, if there are no entities to process, the system won't run (and hence won't update the UI) - you could try temporarily adding the [AlwaysUpdateSystem] attribute

onyx mist
#

yes

#

that was the issue

#

thank you SO much

#

and thanks everyone for the other tips given 😊

amber flicker
#

ace 🙂

mystic mountain
#

Anyone know how subscenes work, or got any vid of it? In my multiplayer game I'm trying to have three subscenes of Server, Mixed, Client. And want to load the level of Server, Mixed onto server world, Client Mixed onto client world(s). I do this by using the subscene script and prefabs, not sure if this is the right way to do it? But it doesn't like duplicated Mixed subscene asset in the hierarchy. Is there really a problem here, subscenes doesn't save any data back to asset right?, or is this just a unity non thought of use case I'm hitting?

remote coyote
#

You bruteforcing through on the Netcode alpha?

#

My guess is they've got around to test more of these use-cases with the next version (or, my hopes are as such)

#

I thought subscenes wrote to blobs/entity cache?

#

Might be something in here, but not sure

#

And if you find anything, I'd love to know too 😄

mystic mountain
#

Hmm ok! Yeah, only real problem I had with netcode was that it assumes a match on port, and an immediate server frame after it's connection call. (as it sends commands right away for some reason). Will check em out. Yeah, I'm not sure at all if it writes or not. I would imagine this is something you can specficy/opt out of?

hollow scroll
mystic mountain
#

Skimmed through some of these, will check again 😛

remote coyote
#

You managed to get Netcode alpha to run on latest Entities version? Or stuck back in the version Netcode alpha was released on?

#

I tried but gave up, thinking the next version would be released soon. Now three months later, still waiting 😄

#

Soon though, soon!

mystic mountain
remote coyote
#

yeah, so just on the entities package version set up in its manifest yeh?

mystic mountain
#

I have the com.unity.transport (ucg.matchmaking, ucg.uspq - though not using em right now) in Packages folder. Then NetCode & Utilities in Asset folder

mystic mountain
#

How do people usually deal with triggers? I.e. tag to change UI for example. I'm currently creating an entity with a tag that I destroy on PostUpdateBuffer. But I feel like as the project grows it gets hard to keep track of what Tags are meant to destroy entity, and which should only remove the tag itself. I'm considering either having a naming convention for components that does either, or having a second tag that marks that it should destroy at end of frame - so it's all sorted on creation of entity.

remote coyote
#

last option sounds nice

#

adding a clear summary for the tag could also help

#

I also find that separating code into isolated feature modules also helps a lot

#

e.g. tags should only really be used within that feature module

#

but I'm unsure how easy it is to achieve that kind of code separation with how Netcode generate code, and specially that ProjectName generated group, that you might want some of your systems to be grouped with.

mystic mountain
#

@remote coyote Can you elaborate what you mean with "isolated feature modules"?

remote coyote
#

Though rather than adapt his Frontend.cs approach with static APIs for interfacing the functionality, I'd rather opt to have non-static equivalents on the systems you're interacting with, to avoid use of statics.

#

I also find that extending World with a Get*System() can take away a lot of bloat

#

World.Active.GetHealth().Damage(target, 100); for instance

#

Whether they're then used as pure Packages or just put into separate asmdefs in the Assets folder, doesn't really matter that much

#

Apoc/Packages/Apoc.Modules/Apoc.Health/

#

I do this

#

Apoc/Packages/Apoc.Modules/Apoc.Health/Apoc.Health.Server/

mystic mountain
#

Hmm yeah ok. I already have asmdefs for base, editor, client, server, mixed. But would be interesting to divide and conquer it down to feature sets as well.

remote coyote
#

yeah, whether its worth it depends on the size of the project of course

#

and I'm not sure whether its a real best-practice yet 😄

#

I'm curious to see how Unity approach their TPS Netcode sample

mystic mountain
#

Hmm yeah, only annoying is to create and update the references on every assembly. And the deeper you dive into gameplay I would imagine there are more and more inter references, but it makes you think and care more of cohesion : )

remote coyote
#

Yes, ideally feature modules shouldn't talk to each other directly, but rather expose interfaces that your main game code implements to create a bridge between them.

#

But this quickly edges toward over engineering

#

The cool thing about writing interfaces like that though, is that now you can easily mock those, and can test each feature module in isolation

mystic mountain
#

@remote coyote How does this work with authoring components etc? First things that comes to mind is that you have to write all authoring in the main code anyway to not break prefabs etc when loading/unloading feature sets, and then call some interfaced method that adds the actual component to the entity in the conversion workflow? It feels like a lot of extra work x)

pliant pike
#

I dont suppose anyone can check my code and thinking as whether its correct

#
 if  (math.distance(prevpos, curmovpos.Value) > math.distance(prevpos, tempwaypointscurr[curryway.value].Position))
                {
                    var tempdistance = math.distance(curmovpos.Value, tempwaypointscurr[curryway.value].Position);
                    curmovpos.Value = tempwaypointscurr[curryway.value].Position;
                    curryway.value += 1;
                    
                    movedir = math.normalize((tempwaypointscurr[curryway.value].Position - curmovpos.Value));
                    curmovpos.Value += movedir * tempdistance;
                }```
#

I'm moving around waypoints in a job and using that to check when the entity's are going too fast they jump beyond the waypoint

#

so it gets the excess distance, then sets the position to waypoint and moves it round to the next waypoint with the excess distance

#

I'm trying to move entity's through a bunch of waypoints at high speeds while keeping them equidistant to one another

mystic mountain
#

At fast glance, the logic seems ok. Might not be the best way to solve the problem, but it should work of what I can tell.

#

dont have two waypoints at same place though

pliant pike
#

yeah thanks I'm sure their is better ways but thats the one I came up with

#

I'm thinking my problem may be something else then, maybe the spawn rate, I have to get them to spawn at exactly the right rate

mystic mountain
#

What is the behaviour you have and want?

pliant pike
#

like I said I want to move a bunch of entity's through some waypoints while keep them at specific distances from one another

#

they tend to bunch up and clip into one another the way I have it now

#

maybe I should just have a system that detects the distances between them and moves them apart, that would probably be easier in general

remote coyote
#

Packages can hold prefabs, or maybe it's nice to decouple implementation from presentation... it's all just ideas anyway ;-)

mystic mountain
#

@remote coyote Yeah, but then you have a player entity that wants movement, aim, inventory etc : ) But yeah, it's interesting.

#

@pliant pike I guess depends of what it is you're doing 😛 If they are "dynamic" as in to adjust if anything pops into between two, then I would go for that yes.

remote coyote
#

I'm not even sure its something you would want to do for all things

#

And DOTS allow you to have these things live in largely separate modules without having to know about each other. Its largely an approach targeting feature isolation naturally

dull copper
languid stirrup
#

guys, anyone came up with an efficient and safe way of appending to a nativearray in a ParralelFor job?

safe lintel
#

ive just been refreshing the main repository 😄

deft niche
#

Why ? Did anyone mention its coming out today ?

languid stirrup
#

basically im adding an array of from 3 elements to 10 elements from each parralel execute function and i want all of these combined in a grand array

safe lintel
#

i do it every day, multiple times a day 😦
i have a problem..

dull copper
#

it was supposed to come out some days ago already

safe lintel
#

weeks ago!!

languid stirrup
#

Entities update?

dull copper
#

but they got some issues

#

yes

#

they are still ironing out some things

languid stirrup
#

so... anyone have any good way of appending to an array from within a IJobParralelFor job?

#

nativearray that is.

deft niche
#

what do you mean by appending exactly ? Do you mean modifying existing contents ?

dull copper
#

(no idea on the actual question)

languid stirrup
#

cuz i would append to it by finding its last set index and contininuing from there. But once you allocate its memory, its .length is always the same

dull copper
#

and while that topic is about dots netcode, it's all tied together

deft niche
#

Don't think you can append to an array in a job

dull copper
#

they need to release entities, netcode and dots anim all at once if they want to ship that fps thing

deft niche
#

You got the answer to your question already 😛 Once the memory is allocated, it won't change

languid stirrup
#

so. I have 2 fields in the job. sourceArrayToBeWorkedOn and destinationArrayToAppendTo in a parralelFor job

#

so every job take from sourceArray and does stuff, and results in 3-10 Elements that need to go in the destinationArray

deft niche
#

you need to allocate the memory for destinationArray beforehand

languid stirrup
#

i know the memory wont change. i have allocated a memory of max 10 elements per job to the destinationArray. But if i save to the destinationArray with index*10 i will have gaps in my destinationArray right?

#

cuz in some jobs only 3 elements will return

mystic mountain
#

Can't you loop over the output?

languid stirrup
#

and eleminate any gaps? hmmmm only if the uninitialized values are set to null.... lemme check, cuz if the init values are 0 in an int array... then i cant know if the element is a gap or not

#

nope... looping over wont work... it sets the init value to 0... so i have no way of knowing if my jobs actually set it up with a 0 or they never got initialized

mystic mountain
#

What I mean is it possible in your case to iterate over the output array, and gather the data from the input array to fill each element? I didn't really get what determines the output number.

tawdry tree
#

Init, manually set all to some arbitrary value you're pretty sure won't be otherwise used(int.MinValue?), then do what you're doing, then check for the value?

#

More work, but setting all the values in an int array shouldn't be too bad, I think. And if it becomes a problem you could find a better way later

languid stirrup
#

ok, I have nativearrayAAA, whichs length is 1000. so i am running it in IJobParralelFor (1000,100) and nativearrayBBB is where i want the output in

#

so each parralelFor Ijob will process nativearrayAAA[index] and result in 3-10 elements of int type which need to go in nativearrayBBB

mystic mountain
#

what determines 3-10 elements

languid stirrup
#

the actual execute part in the job.

#

i can safely assume if everytime it gives 10 elements for every 1000 elements of A, then BBB's size need to be 10,000. which i have already allocated

mystic mountain
#

When you deal with multithreaded things you usually go over output and gather input, especially if you need to read from same place twice. So I'm asking if it's possible by index of output element, determine where input should come from?

tawdry tree
#

Actually, shouldn't there be some overload to set which value it inits to? Seems like an oversight if not

languid stirrup
#

@mystic mountain considering every job can return with max 10 elements, in can store the result in BBB[index10] . but then if index=1 gave 3 results, then index=2 will store results in BBB[210] and all elemtns from BBB[110+3] till BBB[210-1] will be gaps which i wont be able to identify... as they all initialize to 0 😦

#

@tawdry tree i doubt it. the results are actually float3 and they can be pretty much any value... unless i can set them to null.... lemme check!

mystic mountain
#

You're not reading what I'm asking x)

languid stirrup
#

hmm, i read that, didnt understand what you actually meant. my outputs are all zeros. input arrays determine what goes in the output array

mystic mountain
#

So you can't rewrite your code to know that e.g. index 0 of output array requires inputarray index 1-3 ?

languid stirrup
#

oh... err. index 0 -9 of output array requires info from index0 of A. but A could fill either from index 0-4 or 0-7 depending on what is at the index0 of A

#

wait, your image gave me an idea @mystic mountain to show you what i need!

#

to the batcave! to use the mspaint :p

mystic mountain
#

So if you can't directly map output from input, which means there is some dependency between inputs. Depending on problem you can either run singleThread and save index to write to next( I think?). Or make a middle-calculation which first runs to calculate the amount indicies for each job, and then create offsets to use in the calculation (so one part create indicies, then iterate and summize the offsets). Or similarly when you write 3-7 indicies, also write this to a seperate array, which you later use to copy memory to a continous buffer.

languid stirrup
#

hmmmm.... writing to a separate array how many elements were added in this particular job.... and then i know which ones are GAPS later... @mystic mountain thats a good start i think, i shall work on that

#

@digital scarab memory is not really a concern. But the GAPS are the useless items that the next function can not identify as useless...

#

either i eleminate the useless array elements from the jobs, or i find a way to tell the next function which output array elements to ignore

#

as nativearray by default, when initializes sets value of the element to 0. which is one possible useful value. and It doesnt let me set any elements to null... as int or float3 is not a nullable item

coarse turtle
#

You can likely assume a default value that can be implausible as a "null" entry

#

e.g if you needed a float3 to be 'null' you can likely assume that generating a float3 with a magnitude of infinity would be a 'null' entry

languid stirrup
#

Currently I have resorted to using a nativearray<bool> isElementSet lol to show if an element is actually set by me or not lol. It’s working. But it’s still irking me @mystic mountain @digital scarab thanks for the helpful discussion and concern!

dusty scarab
#

@tawdry tree Thanks! Started playing around myself in a sandbox project! All the Unite videos are in my to-do list

#

@safe lintel Yes, OOP doesn't exactly go well with me so I'm trying to understand this! reading up on everything pinned in the channel.
Thanks!

stuck hatch
#

Does ECS supports 2D graphics, SpriteRenderer?

tawdry tree
#

I think there are solutions out there, but they're all custom, no Unity-built stuff right now

deft niche
#

@digital scarab Any news on the update ? 😛

#

Cool.. sorry to bother you on vacation. Enjoy 🙂

dull copper
#

they are probably waiting for Topher to get back from vacation to fix some last part of their setup

#

🤔

dull copper
#

that really made it sound like it's happened before

tawdry tree
#

If you work in IT... you will eventually come to know it. Assuming you have some level of responsibility, anyway. I expect it's not so different in many other fields.

stable fog
#

Oh the joys of not having other people touch code you're responsible for

dull copper
safe lintel
#

now theyre just teasing us by having entities 0.2 as one of the options in the survey 🙂

stiff skiff
#

Soooooon

old pulsar
#

Looking at the AngryDOTS example code, a few entities are created by conversion from GameObjects and then used to instantiate entity copies, but these blueprint entities themselves are never rendered or accessed in any system, it seems. For example, an entity is converted from a 'Bullet' prefab, but that entity itself never acts like a bullet, and nothing in the example code explicitly marks it as inactive. Anyone understand what's happening here? Are entities from conversion somehow inactive by default?

untold night
#

Yes. Anything with the Prefab tag component is skipped unless explicitly queried for. Same for the Disabled tag.

old pulsar
#

@untold night Ah thx, I vaguely now recall hearing that. Do you know the doc or video source I have in mind?

#

btw, is the inspector display of tag entities bugged right now? Components following a tag component are improperly indented.

fair flame
safe lintel
#

dont think theres a fix for the debugger

old pulsar
untold night
onyx mist
#

iirc the commandbuffer systems are going to be able to be burst compiled in 0.2, what does this mean exactly? i thought burst compile only made jobs faster not general code, and arent commandbuffers by definition done on the main thread?

safe lintel
#

you cant burst compile a job that uses add or remove component for now

magic frigate
#

So that means burst can implement the call but doesn't really make it incredibly fast?

onyx mist
#

awe

#

i was excited to see a big improvement in the speed

#

oh well should still help a little!

languid stirrup
#

a huge algorithm is determing the X and the source Array. so i have no control over the value of X or the contents of sourceArray of that length

#

I am leaning towards the switch, but need more feedback, tests are coming inconclusive

old pulsar
#

@onyx mist Playback of a command buffer can only be done on the main thread, but you can record structural entity changes in a job. Such jobs can't be burst compiled in 0.1, but changes to EntityCommandBuffer (or the compiler?) will fix that.

onyx mist
#

Gotcha thanks

amber flicker
#

@languid stirrup imo A) is more legible and you can make it faster (if that’s important) by caching .Length... that said, the other values are uninitialised so I don’t know how you’d know which ones actually had results set but I guess that’s just because it’s example code. Easy to test which is faster but my guess is the difference would be negligible and possibly practically un-profilable

languid stirrup
#

hmm, yea from my tests the difference was neglible, hence wanted a second opinion, thnx for the feedback @amber flicker

gusty comet
#

What's the ECS way of dealing with singleton-like entities, like an inventory or smth? Should I get them with archetypes, too? How do I ensure their uniqueness? Am I mistakenly trying to use an OOP paradigm here, and there's a conceptually different way of doing this?

slow epoch
#

Check SetSingleton method that every query/system has

#

This blog explains really well how it works
https://gametorrahod.com/ecs-singleton-data/

Game Torrahod

You have these API to work with singleton data but how do they really works?

  • system.GetSingleton
  • system.SetSingleton(T data)
  • entityQuery.GetSingleton
  • entityQuery.SetSingleton(T data)

It's a singleton Entity
In the docs it says "singleton data", but actually you ...

#

Although it has a little bit of time so some stuff may be different

low tangle
#

woah!

#

prefab component

#

I've never noticed that before

#

holy shit that can fix something I had to work around

#

@untold night thank you so much for that tip. I had totally glossed over it

safe lintel