#archived-dots

1 messages Β· Page 178 of 1

tiny ore
#

If you don't do this, you risk going too much into the game-designer defined thinking, which is a BIT Object Oriented (although a composition based object orientation).

inland root
#

@stone osprey I understand you also. Archetype / Struct Inheritance is certainly much less risky and brittle than Function / Method / Code inheritance. Just something to be careful about when using it and why. Not trying to be a purist here.

tiny ore
#

So I don't the others were fully wrong.

#

You have to be careful when designing these...

#

At the same point, Unity's ECS is archetype, which kind of discourages add/remove (it's a bit expensive) in runtime (compared to say sparse set, in which these ops are super cheap)

#

Sorry to not have just pointed to "library or example X"

#

Just wanted to chime in the topic... In summary IMHO: useful, but if not used carefully it does "smell" a bit like OO

stone osprey
#

Thats understandable πŸ™‚ thanks a lot

inland root
#

@stone osprey @tiny ore @zinc plinth I value this kind of discourse as well so thanks all for your replies. It was a bit of a provocation 😁.

lost umbra
#

Hi all.. Should I be using 2019.3 or the latest version for learning dots?

deft stump
#

prolly go for 2020.1 to learn dots and also get the latest packages. as they stopped updating the packages on 2019.3.

lost umbra
#

Cool, will try again to get the DOTS sample working with it tomorrow

inland root
#

@lost umbra I'd recommend 2020.1 for DOTS as well... though worth noting if you did want to use 2019.3 for something, just use 2019.4 LTS in that case.

stone osprey
#

Another quick question... should we use properties in components ? Or just raw public variables ?

amber flicker
#

As you should fully use and abuse adding and removing components in runtime based in code... Not fully pre-defined archetypes that never change. - just to say @tiny ore, fully pre-defined archetypes where ICD's get enabled/disabled may be a really good way of working in the future so I'm not totally onboard with this sentence

pulsar jay
#

I am currently trying to figure out how/if to port my event system to DOTS. I feel like there are many 'systems' that heavily profit from having some form of events such as quests and achievements. How do you handle this? Also did a more in depth forum post btw.: https://forum.unity.com/threads/do-i-need-an-event-message-system-or-do-i-have-the-wrong-mindset.969627/

deft stump
#

though Erick did say that its expensive to add/remove components.

tiny ore
#

Interesting @amber flicker it does seem like a good trade-of between memory and cpu indeed

#

But to me it looks like a "valid" work around for one of the archetype model shortcomings.

amber flicker
#

it's all hypothetical until Unity release (what was supposed to be out a while ago) but it really should strike a good balance between the cost of changing archetype and the pain of bool checks everywhere

#

the structural changes are not only relatively expensive but sync points too

stone osprey
#

Properties or variables in components ?^^

tiny ore
#

I assume you are familiar with the sparse set model.
The "ifs everywhere" would be required to filter out disabled components... I mean:

  • what is the API-wise difference between an entity archetype with Transform+Collider from one with Transform+Collider+(disabled)Body?
pulsar jay
#

Properties or variables in components ?^^
@stone osprey As components should not have behaviours it woulndt make sense to have properties as properties define a behaviour that happens when setting/getting

tiny ore
#

The sparse set model solvers this well enough, specially if used with mask-based checks (but I'm getting into ECS model discussions, which is off topic a bit)

amber flicker
#

so the whole point would be that myICD.Enabled = false means a Query<MyICD> doesn't return any results - meaning you can take advantage of the queries in a similar way to changing archetype - it's just that behind the scenes it's basically checking bools.

north bay
#

So you still would not have real existential querying?

tiny ore
#

I'd say getter properties would not be so bad... Sometimes data-conversion setters are also fine (but that's just my personal opinion)

#

So you still would not have real existential querying?
No

#

Maybe we did not understand each other

stone osprey
#

Thanks ! So theres no guideline like : Always use raw attributes/variables instead of properties ?

north bay
#

I only use properties as helpers for stuff

#

Otherwise always variables

tiny ore
#

What I mean is:

  • if on the archetype model you can disable components and that will be (correctly) reflected in queries, a single query would have to be checked which archetypes MAY include it, combined with the "ifs" (could be mask based)
#

then it would loose the (hypothetical) advantage archetypes have compared to sparse sets

#

Maybe I did fully understand the changes required... But that's what it sounded to me

#

But maybe not, as I do not always query for specific archteypes. Nevermind

#

There's already an efficient filter for which archetypes match... That just needs to be DYNAMIC (as the enabled status might change the matching ones)

amber flicker
#

I was only talking about fixed archetypes + enabled being a good way to work with Unity's ECS. In general, I agree it's one of the shortcomings of their model v sparse sets - but it's not something I'm that knowledgeable about

inland root
north bay
#

Thanks, just what i needed πŸ˜‰

pulsar jay
#

Anybody using some kind of event/messaging system with ecs?

amber flicker
#

@pulsar jay whenever this comes up people refer to Tertle's event system. Though I don't know if many people are using it in practice. Have you checked it out?

tiny ore
#

@inland root the post is a bit vague and empty

#

This is their con about Archtype: "The drawbacks are that Archetype ECS is more difficult to code and use."

#

That's NOT the only drawback...

pulsar jay
#

@amber flicker doesnt ring a bell. So I guess I dont know it yet

inland root
#

@tiny ore Yeah that's why I made that disclaimer ha. You may not learn much from it just wanted to throw it out there

tiny ore
#

It does summarize well the main structures of both models though

pulsar jay
#

@amber flicker thx will have a look at it

amber flicker
#

From a very general pov, the main issue with events is multi-threading - jobs/ecs - ordering/timing becomes something to manage in addition to / in conjunction with the ordering of jobs & systems

pulsar jay
#

@amber flicker yeah that was the main pain point I was trying to figure out. The description of Tertle's events system looks to goog to be true so far πŸ˜…

coarse turtle
#

do subscenes "bake" in the data from the gameobjects that exist?

#

seems like the vertex info I want to bake from the UI isn't correct on runtime since I can see the scale be downsized considerably compared to editing time πŸ€”

pulsar jay
#

are there any good resources on NativeStream? the event system repo just mentions that you should know how to use them but there is not much in the docs

stone osprey
#

We cant use native hashmap inside components ?

#

What else can we use to store key/value pairs ?

coarse turtle
#

UnsafeHashMap

stone osprey
#

Ah that works, ty ! πŸ˜„

#

Is there somewhere a cheat sheet for all those data structures ? It gets overwhelming pretty fast :ΓΌ

coarse turtle
#

uh not that i know of online, I just mainly look at ILSpy and the Unity.Collections package for reference

#

just an fyi, with unsafe data structures in components, you need to dispose the memory yourself manually

stone osprey
#

Alright, thanks πŸ™‚

pliant pike
#

stupid question but is it better to just create a bunch of entity's using EntityManager not in a job or anything?

#

because that's what my profiler seems to indicate

finite breach
#

EntityMananger should be avoid in job since it will force that job to on main thread

#

Use EntityCommandBuffer inside jobs for Schedule and ScheduleParallel use

#

*avoided

pliant pike
#

but there's not much difference between creating 1000 entity's and setting a single variable in a job with an ecb

#

than there is with setting a load of variables in entitymanager on the main thread

#

I think the difference is 10ms with the entity manager vs 7ms with a bursted ecb

finite breach
#

Because it is not a heavy task to do. Setting a 1000 entities doesn't take much processing time so the difference will be negligible .

deft stump
#

if you have lots of systems running.
then you should use ecb. since when that EM system runs all systems that uses sched before it will be forced to complete.

finite breach
#

The thing is EntityManager will create a sync point, while the ECB does not. Might be important if you are running lots of jobs at the same time

pliant pike
#

its not going to be run lots of times just at the start

#

but it would save me time not having to turn it all into a job

finite breach
#

You can just start with EM, if you get performance issues later, you can still move it to ECB & jobs.

#

Chances are, you will never have to switch, unless these systems are creating 10.000's of entities every frame or so.

pliant pike
#

yeah, I guess jobs aren't always optimal or necessary

finite breach
#

If the task is simple enough and doesn't require too many entities per frame, doing it jobless might be cheaper (since a job has a very small setup overhead).

#

However with DOTS it think chances are higher of running into algorithm bottlenecks, then bottlenecks over job or no job usage (for simple functions). Keep in mind SyncPoints of course.

deft stump
#

speaking of sync points.
Does moving a managed GameObject in ecs causes sync points? I have UI that's following the player.

finite breach
#

What do you mean by moving?

deft stump
#

updating the transform.position

amber flicker
#

Just to say, if it's specifically instantiating entities - as much as possible, do all instantiations at once and use EntityManager is good (obviously unless you do it in the middle of frame and it's responsible for causing a hard sync you wouldn't have otherwise had).

#

batch EM instantiate is much faster than anything else afaik

#

Speaking of which, I wish there was an EntityManager.Instantiate(NativeArray<>, NativeArray<> * n) overload

pliant pike
#

yeah I'm surprised at that, at least I did test it I guess

amber flicker
#

I don't find it that surprising... The only reason ECB is ever faster is you can burst add & execute but they haven't bothered for EM yet (except instantiation and possibly some other things). Otherwise ecb would always be slower - creating a big list of tasks and then executing later, disposing list etc. (sync points aside - assuming use of EM at sensible times)

pulsar jay
#

Is it possible to use concurrent .NET types with dots such as ConcurrentDictionary? This would make it much easier to port my own event system to dots

amber flicker
#

I don't think so @pulsar jay but I could be wrong

pulsar jay
#

I guess just pushing an event into a concurrent dictionary and then reading it in another system should be pretty simple and straight forward πŸ€·β€β™‚οΈ

finite breach
#

@pulsar jay Don't think so. ConcurrentDictionary lives in Managed C# space.

pulsar jay
#

And it even allows objects in contrast to native containers

amber flicker
#

well.. if you want to use them with burst, definitely not I guess

pulsar jay
#

I see. So it would prevent burst but should work with multithreading?

finite breach
#

You should look into a NativeStream for what you want to do with Burst

amber flicker
#

the job system? I'd guess not - but you can do multi-threading manually. I'd just switch them over to NativemultiHashMap or NativeStream ^ though. When I say just... obviously not super simple.

pulsar jay
#

Yeah I had a look at tertle's event system. It used NativeStreams and later swtiched to a custom container. I thought I could get away with sth simpler which would better integrate with my 'legacy' events

#

As the current system uses classes inheriting from an Events base class this obviously wont work with all the Native containers as they only allow structs

amber flicker
#

I'm not sure what the point of making it DOTS would be if it's in Unity and already works?

#

If it's managed you're likely not going to get any perf benefits

pulsar jay
#

There are a lot of systems that would benefit from dots in the next project. It cannot be pure dots though as there is too much stuff missing still (especially for VR). So I would need some way to properly propagate events between the two

#

I did watch the codemonkey video and it has some nice and simple approaches but its more of a starting point

#

E.g. it couples event queues tightly to specific systems

amber flicker
#

I didn't check it out but just in case it hasn't come up yet, instantiating an "event entity" is fairly common I'd say.

pulsar jay
#

yeah I was also thinking about that

#

is there any way to ensure that an entity lives exactly one frame? because I would like to make sure each system has a chance to see it and then clear it up

amber flicker
#

sure.... a really nice way in fact

#

you just give an entity a tag like EventTag then have a system that runs at the end of the frame that destroys all entities matching a query for the tag. The EntityManager batch query methods are your friends. For the case where your event might be created in the middle of a frame but used at the start of the next, you can have that cleanup run just before your event system creates the new entities.

pulsar jay
#

So I guess I would have to make it run right before the ECB

finite breach
#

Yes

pulsar jay
#

yeah that might work. As I should be going the way of composition instead of inheritance I think I should have an Event component and then additional e.g. EnemyKilledEvent components on each of thos entities

amber flicker
#

ooooh if anyone else comes across this, the reason my Blob ICDs weren't being instantiated was because I actually changed the ICD to ISystemStateComponentData... doh. Annoying. Does anyone know if it's necessary to dispose of blobs manually or if they're reference counted & destroying an entity will do so?

coarse turtle
#

from the top of my head, doesn't the EntityComponentSystemSamples have a blob asset example? You can probably look there to see if they dispose it manually πŸ€”

amber flicker
#

hmm ok.. don't think I've seen those samples πŸ‘

#

Looks v barebones, hard to say - they don't destroy any entities. Guess it warrants a forum post.

coarse turtle
#

ah dang, that sucks - I'd be interested to know too if we have to do it manually

amber flicker
#

If we don't have to do it manually I'm slightly surprised as it must mean there's reference counting going on somewhere. I suppose I could try and go through source...

#

The blob asset is created in unmanaged memory. Call <see cref="Dispose"/> to free the asset memory when it is no longer needed.

#

I might look harder at BlobAssetStore - it has GetBlobAssetRefCounter for example

#

Oh except maybe you can only increment that if you're using a Unity Object πŸ€”

safe lintel
#

I hope this isnt yet another week without some sort of dots public communication silence 😎

little moon
#

I think they won't release any news until Unity IPO on September 17th

safe lintel
#

thought the little dots blip was kinda funny, considering they went through a lot to hide it from users lately

north bay
#

I mean there has to be something big coming

#

Otherwise i will be really sad 😦

safe lintel
#

sort of doubt, its like a drip feed at this point, i just want a bit more big picture information

deft stump
#

hopefully unity doesn't bail on dots. Or i'd be really pisssed XD

amber flicker
#

What does For those of you who prefer to wait until the software is out of beta, we expect the full release of Unity 2020.2 to ship later this year with a TECH release level of stability mean?

rancid geode
#

it means it is expected to be as reliable (stability-wise) as 2020.1 release, if you are expecting more stability then wait for 2020.3 LTS

ebon scaffold
finite breach
#

Well you are adding 350 batches to each frame for the Renderer to handle

#

The RenderMeshSystemV2 does not like that. You'd need to optimize your meshes.

ebon scaffold
#

right but the mesh im using is just 2 quads

finite breach
#

Same materials and UV offsets?

ebon scaffold
#

mhm

#

materials using a unlit graph

finite breach
#

Well generally speaking if the meshes use different materials they cannot be combined into batches which increase the amount of batch calls. Even if it is just a simple quad.

ebon scaffold
#

ye but all the meshes use the same material

calm edge
#

I have entities for world chunks, and sometimes I need to rebuild the mesh for world chunks but it could take more than a frame.. is there a way to work with entities over mulitple frames? Can I somehow query to get a few entities and schedule a job?

finite breach
#

@ebon scaffold Then I am out of advice 😐

ebon scaffold
#

damn

low tangle
#

schedule a job in the system and query the handle every frame till its done. in said job you work with native arrays then produce the final entity edits when all of said native data is done. @calm edge

drowsy igloo
#

Looking for suggestions / documentation on how to link a camera to an entity so that I can move it with the entity. Appreciate any resources / help

coarse turtle
#

you can view the info in the community dots wiki - but hybrid components sounds like something that might help you with the camera

drowsy igloo
#

@coarse turtle Thanks, that helps a ton! I also found that the DOTS physics samples also have a player controller entity that I'm looking into right now.

frosty siren
#

Hi all. How today we should create own worlds in dots? We are creating new world, it shows up in entity debugger, systems being created, but there is no update for this world.

hollow sorrel
#

@frosty siren if you're using the default root groups (init, simulation and presentation system groups) you can just do ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(world); and it'll tick every frame and systems show up in entity debugger

#

if you are manually ticking your world, entitydebugger doesn't support this unfortunately

finite breach
#

Anyone know the most up to date sample code of using DrawMeshInstancedIndirect() with SPR/URP and DOTS?

frosty siren
#

@hollow sorrel thank you. We try to tick world manually through World.Update() but system doesn't update. but calls OnCreate() method.

coarse turtle
#

I messed with it a bit recently - the workflow is pretty similar to a non DOTS workflow with URP

  • Set up draw args (probably need to cache the compute buffer and indirect args)
  • Set up compute buffer for transform data + bind to material
  • Gather chunks and collect the LTW matrices to set transform data
  • Queue the draw mesh instanced indirect call
    @finite breach
hollow sorrel
#

@frosty siren did you attach your system under init/sim/presentation systemgroup?

frosty siren
#

not yet. will try it a bit later)

hollow sorrel
#

asking because world.update only updates those groups

pliant pike
#

we can't use 2 dimensional nativearrays can we?

#

I need to store two values like a minimum and maximum value together

coarse turtle
#

Yeah, probably flatten it out or you store T** a pointer to pointer

#

so you can treat it like an array of arrays of sorts

pliant pike
#

a nativarray in a nativarray you mean?

coarse turtle
#

yeah

pliant pike
#

or maybe I could just store two values in one value πŸ€”

coarse turtle
#

yea that works too

pliant pike
#

use a float then have the minimum value be the value before the decimel and the maximum after the decimel

tight blade
#

Finally managed it, friendos

charred lodge
#

Neat

#

I'm currently going through code monkey's tutorials on dots and ecs

amber flicker
#

@pliant pike you may just want to use float2? You can of course pack your data tighter if you need to but I'm not sure if you need that level of optimization and there's a certain amount of false economy there too.

pliant pike
#

of course, that makes sense, I know about float3 I forgot about float2 leahWTF , Thanks @amber flicker

amber flicker
#

there's also e.g. int2 if you want smaller data

pliant pike
#

so many data types my brain can't remember them all

mint iron
#

@tight blade thats sexy AF

tight blade
#

thank you! and those are all physicsbodies with physics shapes, so its physics enabled, not just visual!

#

I really became convinced yesterday that I was never going to get it working. spent the day rethinking features

#

and then this morning I doodled something in my notebook and tried it out

rapid agate
#

You need to post that to oddly satisfying @tight blade

fluid kiln
#

So I have a prefab that reference prefabs in authoring components, during the conversion I use declare prefabs thingy but when the entity is instantiated, the children prefabs are prefabs and not actual entities

#

What do I have to do to have these entities not flagged as prefabs once the prefab is instantiated

#

I don't think this makes any sense but we'll see

mint iron
#

i think if you want to do runtime conversion you have to call like GetPrimaryEntity on the embedded prefabs or something like that. I dont have any examples on hand but maybe this helps: https://gametorrahod.com/game-object-conversion-and-subscene/

Game Torrahod

GameObject based data are not ECS compatible. It would be great if it is easy to author the data like before but instead getting ECS data at runtime so that we could work on them efficiently.

#

if your problem is that once you've instanitated entities, they have a prefab component then you could just remove it.

fluid kiln
#

I do this, the actionPrefab entity has all the components converted and the Prefab component

#

The anctionEntity entity has NO components except a transform

#
{
    public List<GameObject> actions;

    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        Dictionary<int, Entity> actionEntities = new Dictionary<int, Entity>();
        foreach (GameObject action in actions)
        {
            Entity actionPrefab = conversionSystem.GetPrimaryEntity(action);
            Entity actionEntity = dstManager.Instantiate(actionPrefab);
        }

        //ADD entity in buffer
    }

    public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
    {
        referencedPrefabs.AddRange(actions);
    }
}```
mint iron
#

uhmmm, i think if you're creating entities you have to do it in a specific way

#

its like .CreateAdditionalEntity() or summin

coarse turtle
#

yeah CreateAdditionalEntity(Object/Component) will let you create another entity in the conversion system

fluid kiln
#

So reading the article you've linked, it appears it's impossible to reference a prefab, and instantiate it in the same Convert method because at this point in the conversion the prefab entity doesn't have all the other components

#

Which makes sense anyway

drowsy igloo
#

Anyone know why DOTS, Entities, and other packages are not listed in the preview packages for Unity 2020.1 or .2?

deft stump
#

because unity

drowsy igloo
#

A bit discouraging for learning DOTS and makes me think it's probably not worth starting projects on DOTS now unless they're purely experimental projects. Thoughts?

deft stump
#

unless you're a madlad, like most guys that are here almost every day, there's nothing stopping you from making your game in DOTS.

fluid kiln
#

madlads unite

#

All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -1).

#
        {
            Entity action = ecb.Instantiate(learn.actionPrefab);

            var buffer = GetBuffer<GrimoireBD>(learn.character);
            buffer.Add(new GrimoireBD()
            {
                action = action,
                id = GetComponent<ID>(action).value
            });

            ecb.DestroyEntity(ent);
        }).Schedule();```
#

Any idea as to why I'm getting this? This isn't the first time I create entities with ECB lol

#

Ha it's because I can't call GetComponent in the same frame as the instantiation

zenith wyvern
#

You can't call it on your new entity since the buffer hasn't played back yet. You can call it on your prefab though, it should have the same ID right

inland root
#

A bit discouraging for learning DOTS and makes me think it's probably not worth starting projects on DOTS now unless they're purely experimental projects. Thoughts?
@drowsy igloo This has always been the case, that is: DOTS has not and is not ready for production projects. Like all experimentals / alphas /betas / previews, only use it / learn it if you want to be involved in the development of future Unity features and provide feedback, suggestions, bug reports, etc. The benefit for you is by the time DOTS is production ready, you (or your team) will be in a small pool of in-demand experts right out of the gate, and perhaps even shaped or guided DOTS development significantly. while others will be just starting to learn DOTS. That's the risk / reward. It's not for everyone. 🀠

dull copper
#

DOTS evolves a lot, you learn something today, you need to relearn it in few months

#

in addition, overall DOTS framework (meaning all related packages) development has been quite slow paced, so if you need engine features, you have to build some wonky hybrid anyway

#

it's definitely not production ready and will not be in years at this pace but there are some parts of it that are already pretty robust

#

just... whole game in DOTS today... that's a nope unless you are willing to roll a ton of your own systems

#

I personally thought things would be quite good shape by now, but it's really far from that

#

like, when I started testing DOTS early on, everyone expected it to be more mature faster

#

it's been years now and Unity now even hid the packages from users - which should tell you enough how production ready it is

inland root
#

@dull copper I think some at Unity had that same optimism? Not necessarily the developers though more likely the product managers and execs until reality sunk in how monumental of a project this is for a such a large long standing engine with so many use cases in various industries, and with other features in heavy development

#

@drowsy igloo The main thing that Unity has changed recently here is just setting clearer expectations around this and not rushing things into preview or beta and having it one click away in the package manager, which ultimately disappoints most people by giving them the wrong idea about its current state of usability and causes a bunch of noise in support and discussion channels.

tiny ore
#

The "clear expectations" is also PR talk, so we can't possibly know what they are planning/doing internally.

#

So everything is just speculation... I am carefully optimistic to be clear.

inland root
#

@tiny ore yeah i mean I hope so.. better to underpromise and overdeliver, as the saying goes

tiny ore
#

But as you said, it's better to take things as they are, study, evaluate, etc...

amber flicker
visual mist
#

so you can't put dynamic-sized arrays in an IComponentData?

dull copper
#

@inland root to me it did appear that the overall dev pace suddenly stalled or they hit bigger issues that took them more time to solve. I was hyped about the dots editor (where you had entities in place of gameobjects) etc but these all got put on hold for the time being. There's been a ton of things that I've expected to be there by now, like crossplatform deterministic Burst compilation but Unity keeps postponing it all the time

#

original plan of the latter was so that the feat would have been out for ~2 years by now

#

I've pretty much abandoned DOTS myself besides few select things from it, it's not safe for my use cases and it's not evolving in ways and direction in short term I'd want to see it go

#

I also really dislike the whole conversion setup

inland root
#

@dull copper ah yeah that makes sense, thanks for that info

dull copper
#

I do support Unity on their recent action of hiding DOTS packages from users tho

blissful gorge
#

Just learned some cool generic-foo

Generic arguments in a generic constructor can't be inferred, but you can create a static generic method that can be inferred. For example...

public struct MyGeneric<A, B, C> 
{
  public MyGeneric(B b, C c) {}
}

// Making this a generic static class since ``A`` can't be
// inferred from the type arguments anyway
public static class MyGeneric<A>
{
  public MyGeneric<A, B, C> New<B, C>(B b, C c)
  {
    return new MyGeneric<A, B, C>(b, c);
  }
}

// instantiating the generic with static method (``B`` and ``C`` are implied):
var x = MyGeneric<A>.New(b, c);
// instantiating normally...
var x = new MyGeneric<A, B, C>(b, c);

This gets significantly nicer the more complicated your generics become.

dull copper
#

but I'd still rather have them have some "experimental" package setting somewhere for use cases like this

inland root
#

@dull copper and yeah I understand why the entity and hybrid conversion workflows exist but they are so jankey i'd rather they just skip them altogether and work on fully DOTS enabled editor features first.

dull copper
#

it's actually the opposite, they are not working on direct dots editor anymore, it's on hold. instead they focus on making the conversion / hybrid work well first

inland root
#

rather than getting all slowed up with backwards compatibility tech debt integration

#

ahh well at least they are working on one thing at a time

#

i'll take that lol

dull copper
#

they do have "DOTS editor" package to make the usage easier though but it's been rough

#

last iteration of it that I tried, actually lists all entities in gameobject like hierarchy and you can select items from it for examination, that alone is a big deal

#

I just wish you could also edit and add stuff there πŸ™‚

inland root
#

ah yeah having inspection / visibility in editor is a good first step anyway

dull copper
#

it would be like third/fourth iteration currently πŸ˜„

inland root
#

ah yeah fair lol

dull copper
#

first versions of that package worked very differently and then there was full dots editor (only for tiny) and then there's entity debugger which was more like debugging tool for initial development but kinda stuck there as there were nothing else

zenith wyvern
#

so you can't put dynamic-sized arrays in an IComponentData?
@visual mist

You can store unsafe containers in an icomponentdata but you're responsible for creating and destroying them. Or just use a dynamic buffer

hollow sorrel
#

@amber flicker whaaaaaat

#

pretty sure C# source generators are a new .NET 5 thing

amber flicker
#

hmmm I don't know anything about them but if they're using it for editor it doesn't mean we'll be able to use 5 right?

visual mist
#

@zenith wyvern thanks, so it's not a bad idea to put some DynamicBuffer<Entity> fields in an IComponentData?

hollow sorrel
#

yeah i don't think it would be available for runtime already so soon
but to use them wouldn't that mean they use it in editor? seems soon for that too

#

not sure how they are going to handle it

zenith wyvern
#

You don't put it in the component, you attach the dynamic buffer to an entity. The dynamic buffer itself is a component on an entity. And no, it's not necessarily a bad idea to have a DynamicBuffer<Entity>, depending on what you're doing. You just have to be careful of referencing dead entities

hollow sorrel
#

sounds exciting news tho

amber flicker
#

it's like the first time in months that anyone's said they're working on something πŸ˜… - it's dumb but somehow that's reassuring

tight blade
#

This is such a hilarious and fun community. We're like early prospectors before the full gold rush has started. All telling legends to each other about the gold in the hills, cursing the day we picked our picks and pans, and selectively sharing info to help coordinate a search

frosty siren
#

@hollow sorrel can u please tell more detailed about proper world creation at runtime. I tried do ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(world); but there is no AddWorldToCurrentPlayerLoop in ScriptBehaviourUpdateOrder. And how to attach created system under simulation group in new world?

hollow sorrel
#

@frosty siren oh sounds like you're using an older entities version
try ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world, PlayerLoop.GetCurrentPlayerLoop());

#

as for attaching systems, just world.getexistingsystem<simulationgroup>() (assuming you already added it) and then .AddSystemToUpdateList with your system

safe lintel
#

@hollow sorrel can you explain the significance of the c# generators? I saw that post earlier but dont really know what he meant or why thats a big deal πŸ€·β€β™€οΈ

frosty siren
#

@hollow sorrel thank you. Finally get it worked)

hollow sorrel
#

@safe lintel C# source generators lets you run code after compile kinda like analyzers and also add your own code in there after compile step (but not modify existing)
i think the 3 things joachim mentioned pretty much sums up why it's a big deal, faster compile, easier codegen (for unity) and better debugging
seems to be an evolution of existing codegen and should let us debug entities.foreach (unless that's already possible? haven't tried tbh)

#

also it should be able to replace reflection in most cases, since you can just analyze the assembly during compile and have no runtime cost

#

but it's only supposed to be out in .NET 5 with C#9, considering we're still on .net 4.6 that's like 4 years behind so i don't know how they're gonna support source generators

safe lintel
#

ah thanks @hollow sorrel

tiny ore
#

@hollow sorrel they can also be using their own compiler/code-gen (like we do for quantum) that generates plain C# code...

hollow sorrel
#

sure but that's what they're already doing

#

that's not C# source generators

tiny ore
#

What the post means is that they are re-writing that part of the ECS engine (it's their 4th iteration - they've written already with: 1) dynamic injection, 2) manual job interfaces, 3) IL-weaving, and now 4) C# code-gen)

#

Indeed it can be .Net 5's one... But no guarantees just from that post IMHO.

#

They have NOT used C# code gen at all before AFAIK.

#

They did dynamic injection and IL-weaving, which are different than generating plain C# code.

#

This is AFAIK... I might be missing something, of course.

hollow sorrel
#

not sure how to spot the difference between actual codegen and IL-weaving

#

is there any clear giveaways

tiny ore
#

Easier debugging?

#

As it's easier to trace back the original code... That's one thing, I think.

#

Also any tools made available to C# in general will work (and your generated code will make use of them).

#

like flagging code for inlining, etc... But this is good if they fully go for 5, from my limited PoV.

hollow sorrel
#

mmm

#

well you can read the codegen'd lambda jobs C# in the dots inspector but i'm not sure if that's still IL weaved or actual codegen

#

but anyway C# source generator is a specific name for a specific tech, if they were just resulting to codegen they'd just say that

#

regular codegen wouldn't have the benefits of faster compile and better debugging

tiny ore
#

ye, the last sentence makes sense.

#

Maybe they are referring to the specific tech indeed

pliant pike
#

stupid question but I dont suppose anyone knows why this does not work

#
   BaseMoneyAvailable[0].x = 0;```
#

its saying cannot modify because value is not a variable

#

so what is x πŸ˜•

amber flicker
#

@pliant pike BaseMoneyAvailable[0] = new float2()

#

or var val = BaseMoneyAvailable[0]; val.x = 0; BaseMoneyAvailable[0] = val;

pliant pike
#

ok thanks Timboc, I dont understand why you have to do it that way

coarse turtle
#

native array index accessor returns the dereferenced pointer internally, which would return a copy of the value

pliant pike
#

I think I understand some of those words, thanks πŸ˜†

stone osprey
#

Im back with another design question : Spawning of entities... lets say we have the following structure : Chunk spawns Spawner based on weight, spawner spawns resources based on weight... the weight should be highly customizable. How do we realize this inside an ecs ?

#

The dirty part here is storing the "What should i spawn" method callbacks... we dont simply wanna spawn a empty archetype, we also wanna fill it with default values ( thats what the method reference is for )

deft stump
#

I have 2-approaches:

  1. ) can't you have the spawner entity already in memory? I assume that the spawner holds references to your resources as entities, (which is already in mem).
    then have a system, query for spawner entity, does ifs and elses on weights, goes through the list of referenced entities and ecb-spawns it.
    OR.
    2.) skip the spwaner entity entirely. have all relative resources prefabs to-be spawned in memory. since they're prefabs, you can add in your default ICDs and just set them during ecb.
    have a system, query for all resources to-be spawned, check ifs and elses on weights, then spawn only the ones you want as you go down the list of resources to be ecb-spawned.
#

I lean on the 2nd approach though, since... you dont need to re-list the list.

stone osprey
#

@deft stump Thanks for your answer ! Thats an interessting approach, so instead of spawning... we create those types "once" and use them to determine what to spawn. And the chunk simply references to the already existing entities, which acts as "templates". I never thought of that, but it would work ( Im not quite sure how to "clone" those existing entities )... my mind still thinks that one entity should be used to spawn another one...

deft stump
#

you can just ecb.Instantiate the existing entities. and it'll clone them.

stone osprey
#

Oh thats insane, didnt knew that ^^

zenith wyvern
#

There's also the prefab tag for things like that

stone osprey
#

I wonder how other games realize this... such mechanics are a bit "difficult"

stone osprey
#

are callbacks inside a ecs really a performance killer ? Lets say we have a spawn-system that iterates over spawn requests and each spawn request contains a method reference to the method used for spawning an entity... that method gets called. Would that really be a huge performance killer ?

zenith wyvern
#

I'd be more worried about the maintenance cost than the performance cost. Function pointers make your code a mess, most of the time there are better alternatives

#

Why do you need function pointers?

stone osprey
#

Of course, in unity i would use that instantiate for cloning existing entities... but im more talking about my server side code ( no unity )... there i have no easy way to clone prefab entities, so i need some way to fill them with default values

#

artemis odb ( java ) ^

fluid kiln
#

That's sounds tough haha

#

But can't you serialize entities?

deft stump
#

@stone osprey i'm guessing that you need to fill it with default values on instantiate huh. since you need to call db

stone osprey
#

@fluid kiln Well that could get used... currently using the "Protoype-Pattern" for instantiating entities.... @deft stump Yep, thats what i thought i need callbacks for... .spawn += createDefaultResource;

finite breach
#

@stone osprey I am using a similar system, I am constructing "template" Entities loaded from an XML + reflection with default values. I then use ecb.Instantiate() to clone those entities when needed.

tight blade
#

If I'm purely processing a native array, and dont require any reference to entities, what's my most performant option? IJobParallelFor?

#

Obviously that's a super vague question, but maybe theres a hierarchical answer of some sort. "The fastest would be IJobParallelForBatch if you could blah blah, otherwise blag blah"

tight blade
#

why in the world would they want to execute, e.g. position[6]=position[6]+velocity[6] * deltaTime 64 times??

dire crown
#

its not

#

its batch size

#

so 64 operations in a batch

#

its how the scheduler breaks up the work

#

not the amount of work being done

tight blade
#

lol. Im an idiot. I think this is because I was imagining this job occurring with my own inner forloop, and I was planning to pass in my own batch size, and then just have each batch run through i->i+batch_size

#

now I see that the point is I dont have to do that.

#

lol. thank you.

#

everyone forget I asked this question now.

dire crown
#

np πŸ™‚

drowsy igloo
#

@inland root @dull copper @deft stump and any others I may have missed, thanks for the input on their change to DOTS packages displaying. I've been somewhat (but not super closely) looking into DOTS for the past year and a half or so and I love the fundamental idea. I just recently started experimenting with it and, although there's a relatively steep learning curve, I've been finding it makes more logical sense to me too. Guess I got too hopeful that they were further along than they are. I think I saw in their reddit AMA that they'll be posting more about the future of DOTS in a blog post. Any idea when that will be?

deft stump
#

AMA that they'll be posting more about the future of DOTS in a blog post. Any idea when that will be?
That's what we're asking XD

dull copper
#

the AMA just said they'll write the blog some time this year

#

and it being such loose timeframe, it might not even happen this year (just trying to set the expectations right)

buoyant ivy
#

when you convert a gameobject to an entity, if there are multiple gameobjects of the same prefab, do they end up automatically sharing the same mesh in ecs ?

craggy orbit
hollow sorrel
#

@craggy orbit some use cases:

  • a server could run one match per world, having each world being completely seperated from eachother, so you could run multiple matches in 1 game instance which would be better than 1 game instance per match
  • loading/procgen in a seperate world then merging it back with the main world when done
  • seperating simulation from rendering to make deterministic simulation easier

as for performance, the main thing is that seperate worlds don't have to wait on eachother's sync points

craggy orbit
#

ah gotcha. that last one would be useful for me. thank you very much!

tight blade
#

Alright one more then I'll stop self congratulatory posting

#

But man I am really putting linear memory access to work and it feels so good.

amber flicker
#

How does the profiler look for that? If you're willing to be so vulnerable 🀣

dusty scarab
#

That looks really good!

swift heron
#

are there any general considerations for making method/function calls from inside a ForEach lambda?

#

like, should you try to keep all the code/logic inside the lambda? or is it ok to call other methods in the system?

#

or should other methods be static? or lambdas themselves?

amber flicker
#

I think static methods are great for factoring out heavily reused code - you just need to pass everything they need into them so you lose a bit of niceness with the Get/Set/Has component methods and have to pass in CDFEs etc. Don't think I'd use any non-static methods?

swift heron
#

ok, so don't make regular system class method calls, right? I was just trying to neatly organize some functionality like you would expect in a MB

tight blade
#

@amber flicker if you're willing to help me out with profiling, I'd absolutely be willing! lol

#

Im terrible with profiling.

swift heron
#

it's not for code reuse at all

amber flicker
#

@tight blade just take a screengrab of the timeline view of your profiler - that will say a lot πŸ™‚

#

hmm @swift heron perhaps an example would help? I don't think I can think of a good use-case for that but I could be wrong.

tight blade
amber flicker
#

@tight blade cool but can you do one with a frame selected - that lower half should have some data

tight blade
swift heron
#

sure... it's actually the most simple use case you can think of. just off the top of my head, anything like this...

Entities.ForEach((Entity entity) => {
var data = FetchSomething();
var result = DoSomethingWithData(data);
TheseAreAllMethodsLocalToTheSystem(result);
});
tight blade
#

oh wow, that is really useful

amber flicker
#

@tight blade nice - you can expand the 'Job' dropdown if you want but initially that looks good - lots of thread utilisation

#

need to open that up and zoom in a bit to see your jobs - clearly some physics going on

tight blade
amber flicker
#

@swift heron the point of the lambda's is to have the data you want immediately there (linear memory access) and you're sorta bypassing the safety system if you work like that too

tight blade
#

except for worker 8. that lazy pos

swift heron
#

@amber flicker thanks that's exactly what i was afraid of

#

although, you're not reading into my made up method names, right?

#

πŸ™‚

#

i'm just checking that it's ok to call any method outside of the lambda or not

amber flicker
#

well... I haven't tried doing that (other than static methods) so I couldn't say for sure that the code gen would always work. To my eyes, doing that looks very confusing - I don't really understand the point still - but it might work. Obviously if those methods reference managed code you won't be able to use burst or threads and you'll have to be careful not to do any structural changes in the methods too.

#

@tight blade I have a suspicion that's not as fast as it could be but on the whole, great stuff - all using burst and workers πŸ‘

tight blade
#

Well, theres something that demo wasnt showing that may affect that analysis

#

and north and south

#

those are the actual extents of the simulation node range. the part in the center is a 100x100 grid. the part outside is a 1000 by 1000 grid. all the nodes are participating in the simulation, but I just restricted spawning entities to the 100x100 grid

amber flicker
#

if you're simulating 1mil nodes that looks pretty great to me then πŸ‘

tight blade
#

since things kind of fall apart above 75^2 entities even without my simulation

amber flicker
#

fall apart? πŸ˜„ - do you mean rendering cost of all those dynamic cubes?

tight blade
#

I actually have no idea haha, I just know that if I spawn like 75^2 or more entities, the player cant maintain above 60fps.

amber flicker
#

are you assigning a material to the cubes that has gpu instancing enabled?

tight blade
#

theyre just default primitives

amber flicker
#

yea - try that (new material)

tight blade
#

probably rendering then, you think?

amber flicker
#

the timeline view will show you what it is - my bet is rendering, yes

tight blade
#

the actual visuals will be totally different. I'm going to pass the simulation computed array to a shader and have it just set vertices of a plane to those positions

#

or at least, naively, thats my plan

amber flicker
#

this is probably the point you could expect someone to point out this might all be better done in a compute shader πŸ˜†

tight blade
#

I mean hell, and I think you may have intuited this by now, I'm like scrappy but lack a lot of knowledge. so... uh, if thats a thing that could help me out I'd definitely be into it

#

Do I have to write compute shaders in hlsl or what have you? because my head breaks every time I look at that stuff

amber flicker
#

the advantage of doing this on cpu is ease of use for e.g. buoyancy for objects or something but likely gpu would be much more optimal. There are also ways to read back from the gpu - especially if a frame delay is fine. (Obviously) compute shaders is a whole thing - likely not too hard now that you've worked out the parallel aspects of the simulation though.

tight blade
#

wait, so compute shaders are gpu then? the name was leading me to believe it might be cpu

amber flicker
#

gpu, yea πŸ‘

tight blade
#

so if I want to run this on a phone, still need the ole cpu

coarse turtle
#

well if the phone supports compute shaders - should be able to run it πŸ‘€

amber flicker
#

old phones.. most modern phones are fairly capable

#

only other reason to use cpu is if you were heavily gpu bound and had plenty spare cpu

swift heron
#

it's definitely confusing. i have a pretty unique use case. all of my position data is loaded from an external source that represents real world position data of satellites. there is no input from the user. these systems will run on fixed timesteps and will do nothing but back-load data so it is available in real time to the system that is actually moving my entities. all that being said, i don't like monolithic code and was just trying to encapsulate bits of functionality for readability's sake.
just a little testing: i have one problematic method call that unity is currently barking at for operating on a reference type. changing the method logic to a lambda function does not resolve the issue. the error goes away if i make the function static or if i use a local function inside OnUpdate. looks like i'll just make sure i use static functions. thanks a lot for the advice @amber flicker

amber flicker
#

Ok - I don't know how helpful I've actually been but wish you best of luck! You may also wish to look into 'SharedStatics' if you have data being loaded via some monobehaviour that you want available in your lambdas.

tight blade
#

and uh... no one has built a 3rd party tool for making compute shaders with a shadergraph like interface. have they?

swift heron
#

it's very helpful, and i'm actually loading all my data inside of systems, not MBs. i can share my class in a gist or something so it's a little easier to see what i'm doing/talking about

tight blade
#

and yeah, thanks a lot for the knowledge you're dropping on me, guys! @amber flicker you've already set me ahead significantly!

swift heron
#

it's a total mess, lots of test/debug code as i just try to figure out the right way to organize this code

#

100% possible for me to just inline all the logic inside the lambda

buoyant ivy
#

when you convert a gameobject to an entity, if there are multiple gameobjects of the same prefab, do they end up automatically sharing the same mesh in ecs ?

amber flicker
#

@buoyant ivy what happens when you try? If the gameobjects have the same mesh, I believe they will both have the same IsharededComponentData value so be in the same chunk.

buoyant ivy
#

how can i check that ?

#

i think the component in question is the RenderMesh or something right? i think that extends that isharedcomponentdata. but how can i check that its the same reference on all the entities ?

amber flicker
swift heron
amber flicker
#

@buoyant ivy easiest way is if you use the entity debugger, the gameobjects/entities should appear to be in one chunk (unless they have different components)

swift heron
#

ya i really have no idea how else to handle it. all of the data must come from these external sources. i will load about 170 entities that represent satellites. each of those has about 10MB of data that needs to be fetched once an hour

amber flicker
#

systems require data to run. They will run when that data exists. So simply create the entities with reference to that data once the data is loaded.

swift heron
#

i have 3 systems responsible for handling this, 1 to instantiate new satellites, 1 to keep the next hours worth of data loaded, and 1 to move the next data point values into the current position component

#

one system runs once per minute, one runs once per hour, and the other once per day

#

i just want them to be "in the background" all the time

amber flicker
#

I wouldn't be afraid to leave the systems running every frame and just create & destroy entities when new data comes in

swift heron
#

the system that needs the data to exist to move and render the satellites only knows that it has the current position and the destination position at any given time

buoyant ivy
#

i read about chunks but how do i see what a chunk is in the debugger

swift heron
#

but i can't fetch 1.7GB every frame πŸ™‚

buoyant ivy
#

i dont see any field or anything called "chunk"

#

oh i see a little chunk info tab

amber flicker
#

@swift heron you don't need to fetch 1.7gb every frame..

buoyant ivy
#

ok i see it thanks

amber flicker
#

very crudely I'm thinking.. data.OnReceived => DefaultWorld.EntityManager.CreateSatellite(data) - that method creates a satellite entity maybe with a BlobAssetReference filled with the data.

swift heron
#

so when my "app" starts, there are no satellite entities. a system runs immediately and then again once a day to see if we have launched any new satellites. at this point i'm just grabbing all of the "Operational" satellites and creating empty entities for them

#

another system will loop through each satellite entity once per hour.

#

it will capture the next hour's worth of positions, each 1 minute apart, and store them in a dynamic buffer attached to the entity

#

the 3rd system will run once per minute and pull 1 element from the buffer and load it into the data compoment

#

and the movement system then interpolates each frame between those 2 points

#

i hope i explained that well enough to make sense

amber flicker
#

sure - does my approach above not make sense in that context?

#

can be a dynamic buffer instead of a blob (10mb dynamic buffer's quite big though)

swift heron
#

so i'm just not clear on what data is or it's OnReceive callback πŸ™‚ the http portion of this was also definitely a concern... because the http requests happen relatively infrequently, i don't want to block. i thought if i just scheduled the calls AND they were async, the systems and jobs could continue to run and the data would just be available when it's available

#

at this point, there are no satellite entities -- this is the entry point for creating them

#

once this runs, it should let the system responsible for making that 10MB call to fetch the position data on each satellite, as the entity query will start to match

amber flicker
#

This is becoming a bit specific/involved - I should probably get back to what I was doing haha - a few very quick thoughts:

  1. No need to kick off async in SystemBase - I might personally use a coroutine but not that important
  2. My code above was very psuedo code - the point being that after async getting the data, creating entities with blob/buffer to data means that your other systems don't need to know anything - just that an entity with a reference to data now exists.
  3. Modifying the buffer every minute (like I think you're doing now) is fine. So probably would destroying and creating a new entity every minute. If modifying, instead of creating a satellite entity on data load, I'd create e.g. a 'NewSatelliteData' entity with an id (common to the existing satellite entity) and have a system update the Satellite entities float3 newTargetPosition for example.
swift heron
#

ha ya this is all above and beyond and very much appreciated!

#

i think your pseudo code is a match for what i'm doing now

amber flicker
#

cool

swift heron
#

i think i'm close on #3 too -- except when i create the satellite entity, i'm just attaching a "NewSatelliteTag" component to it, which will be removed once it gets its data

#

and i'll keep diggin on #1

amber flicker
#

I think that's a bit of an important difference. Rather than it 'fetching' data - creating an entity once the data exists. Said slightly differently, once the data is loaded, create an ecs representation of it. Then systems can just require that data be present.

swift heron
#

aww man now you're confusing me again! πŸ˜„ so i need to "fetch" the data so that i can create the entities

#

ah yes

#

ok, that is exactly what i'm designing and implmenting! whew...

#

thanks again! i am walking away from this convo with very useful knowledge

amber flicker
#

ace - best of luck and caveat, all just my opinion - some may disagree with what I've said

pulsar jay
#

I was just looking at the Unity DOTS Sample (FPS) again and now I am wondering why did they use a Monobehaviour Singleton as an "entry point" instead of a system?

zenith wyvern
#

DOTS Sample is a badly named prototype. Not at all representative of how you're meant to make dots games

#

Even unity devs say more or less as much

tight blade
#

yeah, the DOTS Samples are all horrible. they only serve as a starting point to google forum posts about how bad they are so that you can get a decent answer

south birch
#

Could anyone explain to me why the "live conversion" workflow from GameObjects to Entities is the only option? What if I want to do a Pure DOTS approach without GameObjects? This whole GameObject <-> Entity conversion thing gives me the feeling DOTS is not finished yet.

pulsar jay
#

Could anyone explain to me why the "live conversion" workflow from GameObjects to Entities is the only option? What if I want to do a Pure DOTS approach without GameObjects? This whole GameObject <-> Entity conversion thing gives me the feeling DOTS is not finished yet.
@south birch Well thats the problem. It is not finished yet

zenith wyvern
#

As far as Unity is concerned "Pure dots" just means no gameobjects at runtime. We're meant to use gameobjects/prefabs at edit time

pulsar jay
#

I was just wondering if it would make sense to have some kind of initialization and gameloop management system. So I took a look at the sample and found that they just use a Singleton πŸ˜‘

tight blade
#

gives me the feeling DOTS is not finished yet.

that's perhaps the kindest outlook on DOTS we see around here

south birch
#

Alright, noted. Let's hope their elimination on GameObjects is on the end of the todo list..

pulsar jay
#

Alright, noted. Let's hope their elimination on GameObjects is on the end of the todo list..
@south birch I am not even sure if thats still planned at all

#

They used to sell project tiny as a solution which is completely build on entities

tight blade
#

DOTS is like self driving cars. getting rid of human driven cars might eventually happen, but no one is considering that the active plan

south birch
#

@tight blade Okey that made me laugh

pulsar jay
#

But now they are mainly focusing on the point that edit time data should be completely separate from runtime data

zenith wyvern
#

Even project tiny still uses gameobjects at edit time

pulsar jay
#

Even project tiny still uses gameobjects at edit time
@zenith wyvern Oh does it?

#

Then I am misinformed πŸ˜…

south birch
#

Time to make an optimized MMORPG in project Tiny!! lets gooo

zenith wyvern
#

You set up your scene with gameobjects and then convert everything to entities via subscenes or when you hit play. This is how Unity intends it to work

tight blade
#

yeah, @south birch , you get to use the sweet networking package that totally exists and is a real thing

pulsar jay
#

Was it like that all the time? I thought they were pushing the all ecs way with tiny at the beginning

zenith wyvern
#

Tiny is special in that it literally cannot use gameobjects at runtime, but you still use them in the editor. In normal unity you can use both and it's fine.

south birch
#

@tight blade They just released 0.4.0, it's almost done and since it's DOTS you can obviously use it in Project Tiny, right? right?

pulsar jay
#

good to know

safe lintel
#

they did have a 1:1 dots editor a long time ago

#

but they ditched it, because after the most basic of stuff, doing it that way is kind of awful

pulsar jay
#

they did have a 1:1 dots editor a long time ago
@safe lintel thats what I thought. so my info is just out of date

south birch
#

@safe lintel That's really interesting, could you give an example?

safe lintel
#

components dont have default values for one

pulsar jay
#

I still dont understand why authoring entities would be so bad (except for the transition from legacy tools) as they are basically just "objects" without a hierarchy

zenith wyvern
#

Because they would be giving up the countless years of work they have put into gameobjects and prefabs

#

Better to leverage that work at edit time and use super efficient entities for runtime

pulsar jay
#

yeah thats what I meant by: I see the need for the transition period

zenith wyvern
#

Of course right now the process is super arcane and awkward and buggy. But in a perfect world it will be seamless and smooth...eventually

safe lintel
#

if you look at how animation is converted and the resulting entity, theres like so much crap going on you need some sort of conversion to handle it. people complain about boilerplate in code, but you will be entering in so many fiddly details in the inspector, its the stuff of nightmares

zenith wyvern
#

Hopefully. Maybe

safe lintel
south birch
#

@zenith wyvern That sounds logical I guess.. I mean the nested prefabs took them years. If you ditch that now you could say it was all for nothing.. But that would be a bad attitude imo

safe lintel
#

like does anyone want to be manually adding all those components just to make a plane renderable?

#

that doesnt even cover own game logic @south birch

south birch
#

I wouldnt need the HybridChunkInfo and RenderBounds now would I? At least from a normal workflow perspective. It's just extra info provided, not a mandatory component to add.

#

But I could be wrong.. πŸ™‚

safe lintel
#

might be added automatically, ill get another example πŸ™‚

south birch
#

Cheers

pulsar jay
#

I guess the example is good enough. I can see your point

#

So what are you guy using as an entrypoint? If I remember correctly there is a hook where you can setup all the systems yourself. I like the way unity sets up the default systems (physics etc.) itself though. So a system to initialize my custom gameplay systems might be intersting

safe lintel
south birch
#

Well damn

safe lintel
#

since dots encourages flattened hierarchies, i also have entities(where they would be class objects) that arent part of the hierarchy but necessary for it to work so more clutter to the editor hierarchy

south birch
#

Alright, this does bring your point across, lots of 4x4 matrix, lot's of Vector4, It's almost as if you want that to be converted to more convenient data types and shown on the editor, oh wait.

tight blade
#

that doesnt even cover own game logic @south birch
@safe lintel

game logic in dots is a myth!

safe lintel
#

a character is worse, https://imgur.com/a/VKa9g6t its a fairly old example of what the dots conversion results in, but so many ugly buffers and really obscure data, also zero actual gameplay components there so for a AAA type project, id imagine just a horrifying amount of crap to exist there.
this also ignores that - all dynamic physics entities at runtime are unparented so for characters or complex setups they wont be neatly tucked away inside a transform hierarchy, you will have like 30 odd rigidbody entities just hanging out in addition to those two root character entities(that get converted from a single character gameobject).
in my own project a door was 4 separate(non hierachical) entities πŸ€ͺ

ive come to the conclusion that while i think conversion is totally necessary, still not sure if explicitly relying on converting from unity's old stuff is the way to go. a new dots authoring type mightve made more sense? anyway theres a lot of room for unexpected setups. they have so much ground to cover before its seamless.

tight blade
#

there are only cubes -_-

south birch
#

Thanks for making your point @safe lintel I'm convinced.. I guess it's a main disadvantage of data oriented development.

mint iron
#

someone will probably just write their own conversion system that is better and make bank on the marketplace πŸ˜„

safe lintel
#

the sheer quantity of amazing assets and how fast they get new features and stuff makes me wonder why official things in unity take so long

mint iron
#

there are some advantages to not being forced to support older client versions.

safe lintel
#

true but many of the top assets do seem to support older versions. im still annoyed monobehaviours still have .rigidbody .collider .camera etc when they have been made obsolete for years, but then other stuff unity just zaps out of existence without warning

hollow sorrel
#

true

mint iron
#

it drives me crazy too, like back in the mid 2000s i was working with json.Net who had completely figured out interface and dictionary serialization, and it took unity like 15 years and we still have terrible serialization support, their new JsonUtility is not really any better. No interface serialized field support in the editor. Someone like odin comes along and just knocks it out of the park. I feel like a company of Unitys size should be able to get these sort of things handled.

amber flicker
#

I made an asset for tagging (unique guid's per gameobject/entity) and decided to override .tag in my assets tag monobehaviour - my asset replaces it's functionality so I did it to avoid confusion.. but it was a hard call - does anyone use Component.tag?

#

Apologies if this question is unwelcome but would anyone value a nice UI for creating/renaming/categorising ICD tags?

tiny ore
#

why would it be un-welcome? πŸ™‚

safe lintel
#

also the opposite of that is how they buy things and then they just languish - like textmeshpro exists as its own thing that doesnt feel integrated, probuilder hasnt really had any improvements since being bought, its experimental stuff is still marked experimental since prior to being purchased. the next slow motion fiasco may or may not be bolt.
the mecanim default human avatar/bug eyed dude triggers me so hard, it looks sooooo unprofessional and yet it remains

also @amber flicker didnt even know it existed outside of gameobject tags

amber flicker
#

haha @tiny ore I guess because it's commercial/market-research question? ||current asset: https://twitter.com/timboc_/status/1302981776051261440 , http://u3d.as/1ZsW- wondering whether to add support for ICD tag generation as it would be easy||

#BTagged 1.1 now up!
➑️Easily reference GameObjects anywhere
➑️Avoid messy hierarchical references
➑️Event callbacks for anything tagged
➑️All project uses at a glance
➑️Supports editor functionality
➑️MB/DOTS examples + all source included
Get it here✨https://t.co/JVfw3XqPo...

β–Ά Play video

Discover the best assets for game making. Choose from our massive catalog of 2D, 3D models, SDKs, templates, and tools to speed up your game development process.

#

@safe lintel I think Component.tag just accesses GameObject.tag? Which is just dumb? Or maybe I'm wrong πŸ˜…

north bay
#

That looks fancy

#

You should definitely add IComponentData generation than that thing is a must have

amber flicker
#

Roger that, thank you. Will have a think of a clean way to integrate it into the UI.

swift heron
#

just trying to validate another hunch... is

            Entities
                .WithAll<UpdateMovementComponentTag>()
                .ForEach((Entity entity, ref EtlHeaderData headerData) =>

more performant or in any way superior to

            Entities
                .ForEach((Entity entity, ref EtlHeaderData headerData, in UpdateMovementComponentTag tag) =>
#

i don't need the tag, just need to query for entities with it

amber flicker
#

I would like to know for sure but my assumption is 1) is better. In fact, I don’t know if with the debugger on it allows you to do 2)?

stone osprey
#

Are callbacks (Lambda, method, delegate ) used in systems or components really bad for the performance ?

#

I often use method references for injecting unique gameplay elements... like executing different and dynamic actions on the death of an entity

swift heron
#

@amber flicker that was my assumption as well. #2 does work fine, i suppose since the tag is nothing more than an IComponentData with no values, but i suppose i'll stick with #1

#

@stone osprey not speaking from experience, but i've read many times that callbacks are very bad for performance

low tangle
#

theres a point where you have to make tradeoffs to actually be able to implement logic with less effort on the developer part

#

in my c based ecs game I just stuff function pointers into components from a suggestion that was posted here

#

gives you the ability to swap out functionality super easy

stone osprey
#

@low tangle Yes, thats what im also doing rn, either real method references or lambdas ^^ for example to react to events, like collisions... sometimes i have the feeling that realizing certain advanced mechanics with a pure ecs approach is nearly impossible.

low tangle
#

'pure ecs' doesn't mean you cant use function pointers and void data. if reactionary systems were much easier to write, like in say EnTT or FLECS you wouldn't need so many callback based things

#

theres some real missing functionality in UECS that is holding it back a lot

vagrant surge
#

on a personal non-unity project, im storing OOP-ish "brain" objects in a component

low tangle
#

I've been thinking about it lately after switching to UE4, and I think the thing I was really missing from ecs was the fact there isn't any low level engine inlets to allow you to finish ecs for your project. so things like animation which are just now becoming a thing, were (I'm probably wrong) impossible to submit the matrices for skinning avatar bones etc, until that low level api was added for their animation package. if unity had exposed a lot of the low level submit structures for ecs, then I would've been able to finish up the systems as needed, and if those changed over time it would've been fine, as long as there was some way. as it stands everything had to come back though the old cpp object components to properly register into the unity rendering pipeline, aka gameobjects and components

vagrant surge
#

closed source is a bitch

low tangle
#

100%

stone osprey
#

@vagrant surge Phew... im not the only one ^^ heres how i inject logic mostly ( java, serverside )

vagrant surge
#

you maybe be able to edit that in ue4, but doesnt make its easy

stone osprey
#

No acess with unity pro ? Atleast i thought that you gain acess to the source code with pro*

vagrant surge
#

a lot of ue4 stuff goes directly against ecs stuff, and injecting/hooking stuff will be very painful

low tangle
#

no, you have to get a direct license from unity for source

#

and its pricy

vagrant surge
#

the code above is for this prototype im making

low tangle
#

nice will check it out

vagrant surge
#

ill eventually put it on unreal or unity (making multiplat on raw cpp + sdl is a huge pain)

#

made that in 2 days, its pure ECS

low tangle
#

yeah I'm not worried about ecs as much, as I simply have to finish the game at this point

vagrant surge
#

entt + SDL lib

low tangle
#

thats what I've been working on as well lol

#

entt + sdl + taskflow + xxhash

#

taskflow for all non ecs jobs in the engine

#

but thats just a side project when not working

vagrant surge
#

i found SDL render api works incredibly well with ecs patterns

low tangle
#

can confirm

#

flat c structures

#

cant beat it

vagrant surge
#

this is basically my entire render loop

low tangle
#

excelent

vagrant surge
#

the thing is that SDL is stateless

low tangle
#

yep

vagrant surge
#

you just call RenderCopy to render a sprite

#

no need to create a sprite object or similar

#

another fun thing is that the game i posted runs at around 0.5-1 ms for the entire game loop

#

so yeah basically unlimited amount of sprites no prob

low tangle
#

crank it up till it hits 30hz

#

console experience

vagrant surge
#

goal is to eventually make it run game logic at 120 fps no matter what

#

so that the entire thing can be 100% consistent

low tangle
#

throw a fixed timestep in then

vagrant surge
#

yes, fixed timestemp at 120, decoupled from rendering

#

just wanted to dev something very simple that i can develop to a good point in a week or two

low tangle
#

yeah those little projects are critical to keeping the mind happy

#

regular work cant experiment, waste time on new things that might not work

vagrant surge
#

want to see if i can convince nintendo to give me switch devkits using that game

#

and actually release it once finished, maybe

low tangle
#

devkits are pretty expensive

vagrant surge
#

ill just hire freelancers to do art, sounds, and fx once i have at least 50% of the content locked down

#

oh thats no prob

#

im preparing a porting studio

low tangle
#

you can just sign up to the dev portal with your business info

vagrant surge
#

and im already on talks to port other games to switch

#

so just gotta get them devkit

#

yeeee not so easy

low tangle
#

switches and 3ds both you can buy direct now

vagrant surge
#

specially nintendo

#

did they change it?

low tangle
#

took one day, yeah

vagrant surge
#

one day?

#

i contacted nintendo through their dev portal last friday, didnt receive anything yet

#

i did contact xbox

#

and already signed ndas

#

playstation i already have it

low tangle
#

should be pretty easy then

vagrant surge
#

lets see. I have a significant budget for the business, so buying devkits for everything doesnt even make a dent

#

will port unity and unreal games mostly, tho ill ready some non-engine tech demos

low tangle
#

nice

#

good money in that

vagrant surge
#

more than money, i kinda see it in a fairly different way

#

in my country, spain, i constantly see very nice games that sell literally nothing on PC or mobile

#

i believe offering porting/publishing contracts to those can make a lot of profit

low tangle
#

that makes sense

#

get them out to a wider audience

fluid kiln
#

Any idea why netcode creates 3 GhostCollections even tho I only have 1 in my hierarchy during conversion?

#

Any idea why netcode creates 3 GhostCollections even tho I only have 1 in my hierarchy during conversion?

#

It creates a bunch of useless prefabs and bloats my entity list ;_;

vagrant surge
#

@low tangle btw did you see the size of the .zip

#

take that, unity tiny

#

XD

#

i wonder what would the size be if i tried to do an emscripten build

#

given that emscripten implements SDL, which is the biggest hit to the size

#

i think it could end at sub 0.5 mb

low tangle
#

lol yeah

#

no cruft

swift heron
#

i need to make http requests for 165 of my entities once per hour. when the system starts making these requests, unity falls to its knees. each request is ~10MB of data and i need to parse the response and finally append about 60 elements to a dynamic buffer for each entity. outside of a foreach lambda, i can make all the requests async and it takes about a minute to finish.

#

but inside the foreach, instant death

#

these processes are not time sensitive -- it's just a background process that ensures data is ready when it's needed. can anybody offer advice on the proper way to handle these longer running background tasks?

opaque ledge
#

dont write inside for each imo, run it on main thread

#

Addressables also gives issuses if you do something with it inside ForEach

#

i mean you dont have to do EVERYTHING inside systems or ForEach

low tangle
#

if it has to be done inside a system, you should create the array of async tasks, and check them over and over

#

honestly you should just stuff them into a monobehaviour though

#

then stuff them into the entities once done

proven minnow
#

You could do it in a non-entities job?

low tangle
#

165 entitiy updates one frame eventually is nothing

#

more work than its worth

proven minnow
#

And make sure that it can run cross-frame

low tangle
#

async stuff doesn't belong in jobs

opaque ledge
#

yep pretty much

#

hey June, been a while πŸ‘‹

proven minnow
#

It's a pity there's no job-async integration tbh

#

both of them are sheduled things that have dependencies

swift heron
#

ya so, this is my first forray into ECS. i had all of this working with MB already, then in standalone ECS, then with client/server using DOTSNET

#

so trying to force this into systems is strictly for my learning πŸ™‚

opaque ledge
#

async in Unity works weird tho

#

if you use Task.WhenAll it will hang forever for example

swift heron
#

i also read to not user coroutines inside the lambda

#

so i'm not entirely certain how to ensure all of these requests are ran in the background using systems

#

if it's just not reasonable, then i'll abandon the effort

#

the array of async tasks sounds interesting... i'm assuming that would be in a dynamic buffer? since i don't want to be storing state in the system?

low tangle
#

you can store state within systems

#

and should

#

there is some runtime only data that isn't gameworld related

#

that is non game requests, io, http, assets etc

#

native memory for plugins, those kinds of data should be stored within the system or globally

swift heron
#

so does this throw a monkey wrench in things... previously, i had a static list of "things" (ids of satellites) that i manually built and iterated over outside of any entity query. i just finished a system to dynamically check this list of operational satellites once per day and instantiate any new ones that may have launched. now the system i'm working on is the one responsible for fetching the future position data for each of the 165 satellites. it obviously only runs after the first system has created the entities.

#

hmm.... ya well i suppose it just won't really work for this use case

low tangle
#

it would work?

#

nothing in there screams that it cant

#

System1: Has it been a day? Spawn a update req, Start the req (send the actual http requests off), update local timer so we're done for this day
System2: is there a update req? check if its done? if done, update all sat positions, remove req

#

store the actual async objects that represent the request somewhere and your done

swift heron
#

that is pretty much the solution i'm trying to work towards

#

but, i'm doing everything with entities

low tangle
#

can be done within one system as well, just with a state bool for switching

#

that is with entities or not

#

same logic

swift heron
#

right

#

i've had that exact thing working without entities... still in systems, but without entities until late

low tangle
#

logic - what your doing, then the data to support that

swift heron
#

now, i'm trying to immediately start with entities. but making those http requests in the 2nd system completely locks up the editor

low tangle
#

creating the async tasks?

#

create a monobehaviour so you can make the task creation async as well then, attach it to the update req using a hybrid component

#

then you can make the task creation slower and not choke up one frame

stone osprey
#

any idea how i could buffer the change of one simply variable ? CommandBufferSystem only allows the replacement of whole components... i basically need to modify one simple attribute of one component ( Working with prefabs here, dont wanna override the whole component )

low tangle
#

pull the value of the component modify the value then place back

#

if not, you have to pull that value out into a isolated component, if you really cant read then modifiy it

stone osprey
#

I can acess the component when its not created yet ?

tight blade
#

you can just sign up to the dev portal with your business info
@low tangle
yeah no its super weird. The switch dev kits are like getting membership into some secret society

low tangle
#

for sure

#

I checked after saying that

#

I'm trying to work though so I didnt update my post here mb

tight blade
#

its such a funny experience. it reminds me of old MUD games where other players try to prevent newbs from finding and joining the thieves guild.

swift heron
#

thanks a lot @low tangle -- one final question... i've had the async solution working in a system without an entity query. is doing this specifically in a MB an important aspect? or would it work just as well in a system?

low tangle
#

would be fine within a system, just have to manually poll the async tasks

#

instead of just awaiting them within a mb

swift heron
#

and it seemed to work, but i don't know if i just got lucky and i'm doing some things seriously wrong...

low tangle
#

well the same async system unity has for mb might work within systems, but I wasn't aware of that

#

async is a mono runtime component not really class based

swift heron
#

thanks a bunch @low tangle! your help is really appreciated. i'm going to move all this data loading work into MBs and see how we do πŸ™‚

tiny solar
#

I have a NativeArray of colors that have all the information I need to generate an image. My NativeArray<Color> can update at 200fps no problem, but when I use SetPixels and Apply it can take 30 seconds or more if it's a large image. Is there a more direct path? I tried Texture2D.SetPixelData and it didn't seem much faster.

I should note that I've tried methods of not updating mipmaps and that only helped a little.

After a bit more searching I've found Graphics.Blit and Graphics.CopyTexture as possible options, but I'm wondering if this actually bypasses the need for the slow .Apply()

low tangle
#

those only operate on textures that are on the gpu

#

which is what apply is doing, copying your pixel data to the gpu

#

one of the set pixels that requires a proper stride is the faster copy method

tiny solar
#

Since the NativeArray is really fast, and GPUs are really fast, my hope is that I can make it display really fast πŸ˜›

#

So maybe my question is, what's the fastest way to copy pixels to the GPU? Which may not be dots related at all.

opaque escarp
#

it's probably either the Apply, or a ComputeBuffer

tiny solar
#

ComputeBuffer sounds promising.

inland root
#

@tiny solar yeah ComputeBuffer or GraphicsBuffer. You will still pay a penalty in latency for the memory copy from CPU mem to GPU mem however unless you are targeting a platform with a shared memory architecture.

tiny solar
#

I'm done with work in 30 minutes and I will try.

#

I don't feel like I'm the first person to want to do this though - maybe if I understood what was happening in Apply() then there would be a way to format my data better. Right now it's in NativeArray<Color> but it could be anything

inland root
tiny solar
#

oh snap

#

I tried ComputeBuffers like 5 years ago, so I'll have to relearn it but shouldn't be too bad

inland root
#

@tiny solar you could even do additional SIMD optimized processing on that data in a GPU compute kernel (written in HLSL) before actually rendering it if you wanted at that point. a lot of possibilities to balance your CPU and GPU performance budgets that way.

#

probably someday the Burst compiler will just target the GPU as well, i think there was some kind of hackweek proof of concept? but don't hold your breath on that yet :)

tiny solar
#

Right now I'm at such a disconnect between my data being calculated and displaying an image that I feel like any step like this is going to be a dramatic improvement

#

200fps on the array, and >60 seconds getting an image

#

I'm about to start, my guess is that I should try and copy the array to a ComputeBuffer and then output it to a RenderTexture via ComputeShader.SetTexture, but I might be missing a Texture step

inland root
#

I'm about to start, my guess is that I should try and copy the array to a ComputeBuffer and then output it to a RenderTexture via ComputeShader.SetTexture, but I might be missing a Texture step
@tiny solar that would work, but you can skip the texture if you don't need it and have the material shader read the ComputeBuffer directly via Material.SetBuffer https://docs.unity3d.com/ScriptReference/Material.SetBuffer.html

tiny solar
#

Yes I want to skip the texture, thank you

inland root
#

it's all kind of converging sooner or later i guess πŸ™„. shader programs, whether for graphics or general purpose compute are strictly "data oriented" by design, as dictated by GPU architecture / intrinsics

tiny solar
#

I've been learning all sorts of stuff on my DOTS journey

#

Very appreciated, I'm going to try this

tiny solar
#

It works, and it's beautiful, thank you @inland root

#

It's literally over 10,000 times faster

blissful gorge
#

I'm finding a need for an easy burst-compatible delegate past FunctionPointers. Would y'all be interested in something like that?

You'd declare a ValueDelegate in your jobs that is constructed from delegates.

public struct MyJob : IJob
{
  public ValueFunc<int> Func;
  public void Execute() 
  { 
    Func.Invoke(); 
  }
}

// calling the job
var job = new MyJob { Func = (ValueFunc<int>)(() => 0) };
job.Run();

It would have the same limitations as Entities.ForEach, and I'm not sure how to get around forcing a cast when defining the lambda

tiny solar
#

@inland root I've been watching this thing generate ever since I got it to run in realtime. I dedicate this one to you:

visual mist
#

if I have some conceptual hierarchical data, say a Deck that contains come Cards, should I have some DeckData : IComponentData that contains:

  • a DynamicBuffer<CardData>?
  • a DynamicBuffer<Entity> where the entities will supposedly have some CardData?
  • neither of these and I'm thinking about this wrong?
deft stump
#

Or just have lots of Card entities with an ICD of WhereInDeckData and store an int value.

visual mist
#

but what relates the Card entity to which Deck it is part of?

dull copper
#

ECS samples updated for Entities 0.13 and they also just updated physics samples one minute ago

#

previous update to the ECS samples was from Feb

#

hmmm, wonder why they updated the ECS samples to such old version

deft stump
#

but what relates the Card entity to which Deck it is part of?
@visual mist I mean, you can have another int in the icd called deckID or something.
or slap another ICD on the card.

visual mist
#

ok, so in this case more of a "reference" rather than nesting components within one another

dull copper
#

Physics now updates in the FixedStepSimulationSystemGroup

#

Physics bodies can now be smoothed if the Physics step and Rendering steps are out of sync. New options have been added to PhysicsBodyAuthoring to support this functionality, similar to the interpolation option on classic Rigidbody components.

#

about time

amber flicker
#

nice

amber flicker
#

have the DOTS team just come back from a few months r&r? 🀞

#

also re upcoming .enabled states: Hi, did I miss the new feature or were you a bit optimistic in the ETA ? Joachim_Ante: I was yes. πŸ˜„

stone osprey
#

Im back with another design question ^^ At the start of my game i spawn or load in chunks... if a chunk contains no spawner, it should create a spawnerRecipe and if that recipe is allowed to resolve the spawner, the recipe spawns in the spawner. Im using the command buffer system, so this whole process is "asynchron"... that means when my chunk system checks if its allowed to create spawner recipes, it does not know if the command buffer already has recipes enlisted... this causes each spawner to create 2-3 times the amount of spawners... is there a way to determine what is buffered in a ecbs ? Or do i need to rework my chunk/spawner structure ?

#

Chunk -> If chunk contains no spawners -> create spawner recipe -> if recipe is allowed to resolve -> recipe creates the actuall spawner -> spawner gets inserted into chunk

frosty siren
#

Can we somehow access singleton entity not from system and not using entity queries? I mean with such a clean way like GetSingleton/SetSingleton.

deft stump
#

so 2020.2 just broke subscenes

#

aargh it was a bad idea to update to 2020.2

#

so here's what subscene is supposed to look like

#

here what the panels looks like when I apply subscene

#

kawabangga baby

amber flicker
#

have you cleared the cache?

deft stump
#

nope. where is it located? inside library?

#

aaah subscene cache you mean?

amber flicker
#

I think DOTS->Clear entities cache or something - longshot but just wondered if it might help

deft stump
#

i'll try

coarse turtle
#

I haven't tried subscenes with hybrid renderer

#

but it seems to work for me on some custom stuff πŸ€”

stone osprey
#

Whats a pure ecs approach of a "Spawner" ? Lets say our spawner should choose N locations, have a set of entities to choose from ( for spawning ) and each of these entities have one or multiple conditions when they are allowed to spawn... any help here ? Cant find any usefull and flexible structure for this :/

#

One example is minecraft... i know that each entity is weighted and have conditions... like monsters are only allowed to spawn in at night, other ones only in the sea

deft stump
#

@amber flicker yup that works

amber flicker
#

sweet

coarse turtle
#

from the top of my head, maybe if you had n collections of entities to choose from, each collection can refer to some kind of rule (I"m not sure how these rules be set up - enum/bit flags?). You can check if the rule is applicable and then spawn the set of entities per region? @stone osprey

stone osprey
#

@coarse turtle That would work ^^ But we would need to check that rule for every spawn point the spawner choosed... nevertheless, how do we keep those rules flexible ? I think its no good idea to hard code them all in one method/system...

#

For example to allow modders / other developers to easily change rules or add new ones...

coarse turtle
#

oh hmm πŸ€” that's a bit tough

#

you could try to generate unique ids/hashes per rule sets depending on whatever info is piped

#

I have something similar in my card system, define the card's category and the concatenated categories generate a hash that i would generate/bake in editor time and read in runtime

stone osprey
#

well that makes sense, thanks πŸ™‚ And how do we add new rules ? Or new code that processes those rules ? the only way i could imagine is using method references... like "Oh the set uses that rule ? Lets check our dictionary what method processes that rule..."

coarse turtle
#

yeah i have something like that - just stored it into a hashmap to check if i can execute the card

stone osprey
#

Thanks ^^ so theres no way to solve this flexible rule system without using callbacks ? Looks like pure ecs is really, really tight in case of useages :p

coarse turtle
#

for my case, I didn't really care if it was pure unity ecs - it was just going to make it harder to build + I needed to iterate and test out viability of certain cards (i think once Unity supports c# 9's unsafe function pointers it might just be easier to do it in ecs)

deft stump
#

C#9 might come when C#10 is around the corner XD

stone osprey
#

Alright thanks ! Probably i just need to realize that pure ecs is very limited

coarse turtle
#

fwiw, most of the other parts of the gameplay works well with an ecs architecture (physics/physics events, platforming, game states/rounds)

stone osprey
#

Thats true ^^ its only the dynamic stuff that does not work that well with ecs architectures

toxic mural
#

I would create an AllowedSpawnType component, that has an Entity field pointing to a entity prefab, and use per-monster-type systems to add/remove them from spawn location entities

#

Then when the spawn system goes to spawn something, it looks at the AllowedSpawnType(s) on the spawnpoint, and sees if there's a match to what it's been instructed to spawn

stone osprey
#

@toxic mural Thanks, thats also a good idea ^^

#

spawning mechanics are pretty hard to design... i think im gonna try the following now : Spawner generates X locations -> Spawner validates entities that could get spawned on there -> Spawner applies weight to them and creates the entities itself

#

I think im gonna split this into three parts... Location -> Validation -> Weighting / A component for each those tasks... just have no idea how to combine them, because there 9 different combinations of those... spawners having only location and weighting, spawners only having location and validation, spawners only having location :p e.g. any idea how we can process those without writing 9 different systems ?

#

Or is there even a way ?

amber flicker
#

I haven't really been following but have you got down to the fundamental data you require. It seems for the system that instantiates you need a type (entity prefab) and a location (float3?). For the spawn system you need a list of possible prefabs (DynamicBuffer of entities?) and a probability for each (float?). Does that miss anything?

stone osprey
#

@amber flicker Thats it ^^ do you mean its too much to divide those into three different components for the spawning process?

amber flicker
#

I think... this is super straight-forward.. I'm not really understanding the issue so I can only say that I'd approach this backwards - what is the minimum data required, then how can that data come into existence in ecs land.

stone osprey
#

Alright, i just dont wanna make the mistake to hardcode any stuff that should be flexible ^^ thats why i thought it may be good to split this behaviour into multiple components

amber flicker
#

In psuedo code, to me one version looks like this:
SpawnPoint : ICD { float SpawnInterval; float3 SpawnLocation; DynamicBuffer<Entity> Prefabs; DynamicBuffer<float> Probabilities } then (optionally e.g.) NormalizeSpawnProbabilities { copy Probabilities, normalize, write back, remove NeedsNormalizingTag}
then SpawnSystem { ForEach(spawnPoint) => if(timeSinceLastSpawn - Time > SpawnInterval) choose entity, EntityManager.Instantiate() }

#

If you want to add in more functionality later (like spawning multiple in the same frame or whatever), you can just add that as you need.

#

I feel like I'm missing the issue 🧐

#

reading back I see the question is more with regard to rules like 'at night'. Your spawn system can check for the presence of tags e.g. if(HasComponent<SpawnOnlyAtNight>(spawnPoint)) .. spawn if night time

coarse turtle
#

~~hmm I have a question unrelated to the current topic, How do you initalize an UnsafeList? Seems like most constructors always explicitly define that Ptr is null πŸ€”

I could always just assign a pointer, but seems odd that UnsafeList initializes likes so~~

#

ah nvm, I can't read the debugger 😐

stone osprey
#

@amber flicker Thanks πŸ™‚ I just searched for a way to prevent myself from hardcoding the spawn mechanic... Found a solution, theres another component ( Spawn ) that stores a entity id and spawn point queue... and that component processes them, polls one entity, one location and instantiates that entity at that location... this way we can let other systems or components run before that spawn system to modify either the locations or the entitys to spawn ( algorithm to choose location, condition and weightning )

storm ravine
stiff skiff
#

New physics update

#

But its still making me sad 😦

#
int numChunks;
using (NativeArray<ArchetypeChunk> chunks = StaticEntityGroup.CreateArchetypeChunkArray(Allocator.TempJob))
{
    numChunks = chunks.Length;
}```
#

Why is this a thing xD

safe lintel
#

i really hate how for some packages it no longer says that a new package is available

craggy orbit
#

im on 2020.2b2 so the Unity version shouldn't be a problem

#

i suppose i could just manually update

safe lintel
#

not sure why, maybe close the package manager window and open it again or restart the editor, i just updated without too many hitches(flushed all dots data to fix my first runtime errors)

craggy orbit
#

ah i probably should've just restarted the editor. maybe they pushed the release while it was still open or something. oh well. it's loading after a manual update

spark glade
#

I have to say, Joachim is a fucking beast... he's answering dots forum questions on the day of the IPO of the company he founded.... πŸ‘ πŸ‘ πŸ‘ πŸ‘

#

This guy is eyeing the tres-commas-club and still got time for us ❀️

safe lintel
#

when you put it like that 😍

tight blade
#

yeah that is pretty cool

tiny solar
#

I hope that he makes a boatload of money and doesn't care πŸ˜›

#

(basically I want him to keep doing what he's doing!)

swift heron
#

very cool!

craggy orbit
#

i've gotten to the point where im successfully creating multiple worlds, but i can't figure out how to remove default systems (physics, rendering) in the main world to move them to the special worlds. if i try to destroy physics systems in the main world, i get a bunch of errors every frame, and soon after the editor freezes and i have to force quit. any ideas, or do i just have to disable them in the main world and add them to the new world?

hollow sorrel
#

@craggy orbit what errors are you getting and how are you destroying them?

craggy orbit
#

ill have to check the logs for the specific errors, since i can't scroll up in the console to check after the editor freezes, but im using World.DefaultGameObjectInjectionWorld.DestroySystem(BuildPhysicsWorld) (same as with Step, Export, and EndFrame) to destroy the systems

north bay
#

Are you also destroying the debug draw systems?

craggy orbit
#

no, are those added by default?

hollow sorrel
#

i'm guessing you're missing a couple physics systems that are dependent on those so they throw errors

craggy orbit
#

if i pause before playing, the editor doesn't crash, at least.
"InvalidOperationException: object is not initialized or has already been destroyed"
in the system update loop. so yeah i must've missed a system πŸ˜… ill go have another look at all of the systems

visual mist
#

I'm using DOTS and VSCode, and while VSCode shows compiler errors, it never shows more DOTS-specific errors (stuff like doing unsafe accesses within a ForEach). Is it normal? Is it better with Visual Studio?

craggy orbit
#

i've never seen DOTS specific errors outside of Unity either

visual mist
#

cool, just wanted to make sure I wasn't missing out on some plugin goodness

craggy orbit
#

oh wow i missed a ton of systems when removing. i was only looking under the Unity.Physics.Systems namespace

hollow sorrel
#

dunno if you found em already but here's a list for 0.4.1

DisplayBroadphaseAabbsSystem
DisplayColliderAabbsSystem
DisplayBodyColliders
DisplayCollisionEventsSystem
DisplayContactsSystem
DisplayJointsSystem
DisplayMassPropertiesSystem
DisplayTriggerEventsSystem
BuildPhysicsWorld
EndFramePhysicsSystem
ExportPhysicsWorld
StepPhysicsWorld
craggy orbit
#

got em from the docs, but thanks!

craggy orbit
#

still getting the same vague error as before :/ here's the full error
https://pastebin.com/RcAuXsb2
unfortunately if i try to edit the script from where the error is thrown (error line 7) the script reverts back after reentering Unity, so i can't add additional detail like what system im at in the update loop

#

oh never mind this time it stayed

#

FixedStepSimulationSystemGroup is the "not initialized or been destroyed"

#

if i don't destroy that system, instead it debugs all of the physics systems that i destroy

hollow sorrel
#

might need to take them out of that group's update list too

#

not sure if destroy does that automatically

#

guess not

craggy orbit
#

how odd. ill look into that, thanks!

deft stump
#

I spent like... 2 full days making an Archetype Authoring-like component... for my ease of use...

#

and then it hit me...
prefabs exist, prefab variants exist

#

:notlikethis:

north bay
#

It's package update day wish me luck 😨

deft stump
#

which packages were updated?

opaque ledge
#

i think he meant he is going to update packages to current ones

#

only 'big' one is physics i think

visual mist
#

hi everyone, I'm a little confused, I want to run a ForEach on some selected entities, but I'd also like to know how many entities were actually ran, so that I can keep track of some count elsewhere. I thought I could do an EntityQuery and use its CalculateEntityCount, but now I'm unsure how to turn that query into something I can ForEach over

#

I see online people doing Entities.With(query), but for me this gives 'ForEachLambdaJobDescription' does not contain a definition for 'With' and no accessible extension method 'With' accepting a first argument of type 'ForEachLambdaJobDescription' could be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]

zenith wyvern
visual mist
#

thanks, this compiles at least, now to solve my thousand runtime errors to see if it actually worked! πŸ˜‚

stone osprey
#

Is it usefull to use the ecs architecture for "producer/consumer" patterns ? Like... "SpawnPointsSystem" produces locations by an algorithm and inserts them into "SpawnPoint" component, "SpawnSystem" is a consumer and takes the locations to spawn entities in ? The only problem with such a pattern this needs to run sequential after another.

#

The advantage here is that its pretty easy to customize and to extend... we simply need to make sure that the consumer gets what he deserves :ΓΌ

vagrant surge
#

incredibly common @stone osprey

#

i use it constnatly

#

most often, its used with a singleton entity that has a queue/array of some kind

stone osprey
#

@vagrant surge Thanks ! Thats great to hear πŸ™‚ The only huge withdraw here is that theres tons of boilerplate code...

#

Those "...To..." systems are only used for copy data into the next step

vagrant surge
#

thats overkill

#

this is how i spawn objects in my non-unity bullet hell game

#

so essentially, its literally just a function that creates the entity, sets default parameters, and "clones" it from a different world where the prototype entity is

#

this is done "directly"

#

alternatively

#

i do

#

have a spawn system

#

that iterates BulletSpawner and creates the stuff

stone osprey
#

Is this entt ? Used that framework some time ago for a opengl university project ^^

vagrant surge
#

but both of them just call the build_bullet function which creates the bullet "instantly"

#

yes

#

its miles ahead of dots in usability, yuo can spawn entities inside iterations and things like that

#

and you dont have to setup a system

#

you can just from anywhere perform a query (registry.view<stuff>)

#

because it has no concept of a system, my loop just looks like this

#

each "system" is just a pure function i call from the main game loop

stone osprey
#

thats right ^^ so you mean my 9 systems for the producer/consumer ecs style is too much ?

vagrant surge
#

way too much

#

specially on unity ecs where systems have significant overhead

#

you do not need that

#

for spawning, you have generally 2 types of spawning

stone osprey
#

Actually its not unity either πŸ˜„ this is part of my serverside code ( artemis odb )...

vagrant surge
#

one is where game AI/logic spawns it

#

and other is when you actually have a spawner entity that spawns in a loop

#

i recomend you keep those as a different thing, and basically allow "instant" spawn from anywhere

#

or close to it

#

in here i just have a BossAI object (virtual update) that ticks AI logic and spawns some specific bullet patterns on its own

#

tho it also creates spawners for the "allways spamming" logic

stone osprey
#

I pretty much tried to implement a "spawner" for mobs... to keep it flexible i thought its a good idea to split it up into 4 pieces : Location generation, Conditions, Weight and the actuall spawn process

vagrant surge
#

highly overkill

stone osprey
#

Thats why i ended up with that many systems

vagrant surge
#

a important typo in ECS, is that you shouldnt over-componentize stuff

#

until it makes sense to do so

#

creating 5 components and 8 systems for "one logic" is not that good of an idea

#

in your case, you will generally allways pack those components together, and the systems run on the same entities

#

so just make it monolythic

#

once you need the different combinations for different types of spawners

#

only then you divide stuff

stone osprey
#

Hmmm... that makes sense... tbh, spawning is bretty hard for me to implement. I wanna have it as flexible as possible, different algorithm, with weights, without weights... with conditions or without them... but probably this is really too much

#

Otherwhise i dont wanna shoot me into my foot later on... i had projects where i hardcoded stuff that were pretty hard to change later on. Mostly OOP projects, but well

vagrant surge
#

dont go overkill until you need it

#

one of the interesting parts of ecs is that replacing code entirely is easy

#

so embrace that

stone osprey
#

Thats right... So splitting up code only makes sense when we really need the flexibility

vagrant surge
#

you can start with 1 spawn system on a relatively fat component, and split it later

#

after all you can even automate the splitting by having a system that copies the fat component and splits it, while you develop the split version

stone osprey
#

Thats also a good idea but im not sure if that works in c# or java that well ^^

vagrant surge
#

it will be fine lol

#

ive done so on entitas before

stone osprey
#

Alright thanks... one last question... is it still considered as a producer/consumer style when we design our components like the following : Input, Attributes, Output -> LocationGenerator{ input: someLocation, attribute1: width, attribute2 : height }, LocationSystem : Taking the input and attributes to generate locations and put them as a output into LocationGenerator ?

vagrant surge
#

thats fine

safe lintel
#

animation package update πŸ₯³

#

ah and the samples remain the same πŸ˜…

proven minnow
#

Is there a way of making a subscene automatically update whenever there's a git update to a source file?

mint iron
#

i guess you could write an editor tool that connects to github and compares the files, downloads new data if required, or you mean at runtime?

hollow sorrel
#

just use that version attribute on your authoring components

#

[ConverterVersion("poop", 1)] i think it was

#

and then increment the 1 when you make a change

proven minnow
#

@hollow sorrel Thanks, that's the one I know about. Would just be very convenient if I could bump ConverterVersion whenever there's a change to specific files.

#

I'm very willing to write an editor tool for this, but unfortunately tags are evaluated on compilation, I think

hollow sorrel
#

oh you mean like when non-authoring components change?

proven minnow
#

Yeah. My intended workflow is like this

#

I have about 500 fbx files that I currently load via Resources.LoadAsync.

#

Process them a bit, and then make into parts that slot together

#

Ideally, I'd be able to have a ConverterVersion that bumped whenever I made a change to those files

hollow sorrel
#

ah yea

proven minnow
#

So I could put all of those in a subscene

hollow sorrel
#

i don't think there's a builtin way to do that right now and tbh even the converterversion way is pretty bad at the problem it intends to solve imo

proven minnow
#

Thanks

viral sonnet
#

does it matter if I use EntityCommandBuffer with ref or not in methods?

#

I never saw it used with ref but it does seem to work without it

swift heron
#

i think you only have to use it if you're making structural changes

#

that is adding/removing components? you should be able to update values on referenced components without an ecb

swift heron
#

am i doing this wrong? i should metion that i'm using DOTSNET. i have a prefab on the server that gets instantiated about 165 times and each entity gets synced to each client, but i'm not certain if having the model on the prefab is bad in ECS? is it pushing around lots of extra data? is there a better way to do this?

shy pilot
#

hello all

#

i have a quick question

#

i'm playing around with the netcube example for netcode
i'm maily trying to turn it into something with first person-esque controls
But i can't get relative movement to work :( Can any of you tell me what i might be doing wrong?

#

thank you all in advance :)

shy pilot
#

shameful bump

shy pilot
#

does anybody have any experience with this?

fair flame
#

Well you are applying the rotation to the Rotation component but then using your LocalToWorld to adjust your input vector which wont be updated by Rotation until the TransformSystemGroup updates. You are also multiplying your input vector by LocalToWorld.Forward which is another vector, I'm not 100% sure but I think this does component wise multiplication (ie. (a.x * b.x, a.y * b.y, a.z * b.z)). I think what you want is something more like

trans.Value += math.mul(rot.Value, inputVec) * deltaTime * 10f;
shy pilot
#

ah, thanks :)

#

will try that now :)

#

thank you so much @fair flame it works perfectly :D

#

you wouldn't happen to know how i might determine if a client owns a ghost instance?

#

@fair flame (sorry for pinging >_<)

fair flame
#

I've been using GhostOwnerComponent

#
var localPlayerId = GetSingleton<NetworkIdComponent>().Value;
Entities.ForEach(Entity e, in GhostOwnerComponent owner)=>
{
  if(owner.NetworkId == localPlayerId)
  {
    // e is owned by this client
  }
}
#

GhostOwnerComponent should already be setup if you are using client prediction

shy pilot
#

thank you so much!!! you're a lifesaver :D

fair flame
#

you're welcome

shy pilot
#

just checking, there's no way to add a camera to an entity is there?

#

you have to do the janky thing where you move the main camera to the entity constantly right?

deft stump
#

convert camera into entity? then follow the entity around?

#

i believe you can do that with Hybrid.
But honestly, I'd just use cinemachine for it.

fair flame
#

You can use EntityManager.AddComponentObject(entity, camera); or store a Camera reference in an IComponentData class.
If you add HYBRID_ENTITIES_CAMERA_CONVERSION to your scripting define symbols then you'll get a GameObjectConversionSystem that converts cameras with AddHybridComponent(). You won't be able to use burst with cameras though because they are a reference type.
I'm not sure but I think the AddHybridComponent method might manage its own transform but otherwise you'll have to update the cameras transform yourself but that's pretty easy with the CopyTransformToGameObject component and then adding the transform via AddComponentObject

half jay
#

When new ECS package update will be available ?

opaque ledge
#

thats.. thats the question of the century

deft stump
#

that's what we're asking XD

#

how would I go about changing a material's color?

#

just googled. so I attach an ICD onto the thing I want its color changed

#

lemme try

visual mist
#

can't [GenerateDataAuthoring] on an ISharedComponentData?

deft stump
#

you can

visual mist
#

but then when I try to add the script to a game object, it tells me it cannot find the BlahAuthoring class

deft stump
#

[GenerateAuthoringComponent]

visual mist
#

oh yes that's what I meant

visual mist
#

it does not seem to work with my ISharedComponentData

visual mist
#

anything obviously wrong with this? http://paste.awesom.eu/cn3z
I try putting large objects with Box Colliders right in front of the camera, but the ray never hits :\

#

the object's distance is about 50, less than 200 most certainly

#

hmm used Debug.DrawLine and the ray is definitely where I think it is and touching that object

amber flicker
#

I haven't touched unity.physics at all yet but I wonder if this is because your code needs to execute at a very particular point with dots physics - I think after export physics world or something? Is there a raycast example you're following?

visual mist
#

ah the latter indeed has some annotations, let me try that

amber flicker
#

the only other guess I have is some filtering mis-match

visual mist
#

still does not register, but I'm sure this was at least something good to have

#

yeah let me try adding back that filter param

#

Ignoring invalid [UpdateAfter] attribute on UI.DragAndDropSystem targeting Unity.Physics.Systems.BuildPhysicsWorld. This attribute can only order systems that are members of the same ComponentSystemGroup instance. ah, I may need to figure this out

#

ah yeah I need to do that final job handle awaiting it seems, will work something...

#

how do I figure out what ComponentSystemGroup the BuildPhysicsWorld system is part of?

mint iron
#

find it in the entity debugger and see what group its in, or look at the source code, attribute at the top of the system.

visual mist
#

well I'm a dumdum, turns out I had to use a Physics Shape and not a Box Collider! πŸ™‚

tight blade
#

oh damn, sorry I wasn't around to help with that. Yeah colliders screw everything up. If the colliders are even attached to your entity at all, they screw up all collision filters, even if you have a physics shape attached also

sick prism
#

hey all

#

does anyone know the meaning of this error I'm getting, trying to use a NativeArray of a struct inside a job

#

InvalidOperationException: HumanPoseWrapper used in NativeArray<HumanPoseWrapper> must be unmanaged (contain no managed types) and cannot itself be a native container type.

#

here's the code

#

the allocation is: _poses = new NativeArray<HumanPoseWrapper>(poseFrames.frames.ToArray(), Allocator.Persistent);
frames is a list of HumanPoseWrapper inside a scriptableobject type

mint iron
#

it means something is not unmanaged inside HumanPostWrapper

sick prism
#

perhaps the float array

mint iron
#

yeah

sick prism
#

how would i work around that?

mint iron
#

you could make it fixed, or use an UnsafeList, raw allocation, etc

sick prism
#

huh nativearrays can go inside nativearrays?

#

they're not serializable tho, right?

#

think i could just fix the size, i think it should have a fixed amount anyways

#

the data comes from mecanim, so i guess ill have to trust it wont change

#

or i guess i can make another intermediate data structure that can go straight in the job

mint iron
#

probably depends on how efficient you need it to be, how much you care about wasted space etc. like if there's the possibility of there being 20 muscles, but 99% of the time there's only 3 muscles, and you allow space inline for the max amount your iterations are going to be slower having to skip accross all the wasted space.

sick prism
#

i can probably trust it'll stay at 95 muscles, hasn't changed in any of the rigs i've tried yet

#

hmm to fix size buffer i need to make it unsafe

mint iron
#

do it and never look back πŸ˜„

sick prism
#

do i need to enable unsafe in unity project settings?

mint iron
#

yeah

sick prism
#

this data structure is mostly for serialization tho, so i think id better think about another way to represent it in a job

#

i was just hoping i could cut out the middleman πŸ˜„

#

dump the data straight in

#

unity API has HumanPose which isnt marked serializable thats why i do this

mint iron
#

if you're doing any processing on it in burst you should also switch to float3/quaternion instead as they're optimized

sick prism
#

yup, right now im prototyping, will switch to unity.mathematics after i make sure this is feasible

#

im open to any suggestions, how would i perhaps structure that data to go neatly in a job?

#

not very experienced with all the jobs stuff yet

mint iron
#

hmmm, what kind of serialization are you talking about, and whats the job do

sick prism
#

the job would interpolate between multiple humanposes

#

the reason i gotta make a wrapper is unity API HumanPose is not serializable

#

ie i cant slap it into a scriptableobject

#

animationjob btw

mint iron
#

mmm, i think id probably copy what unity does for their colliders

#

but you wanted without unsafe, so that rules out pretty much everything πŸ˜„