#archived-dots

1 messages ยท Page 22 of 1

rustic rain
#

I'd say it won't be as efficient

whole gyro
#

yeah maybe, but I'm only syncing the main character so don't really care about performance. I don't think I knew about the built-in options when I wrote it and haven't gone back to it yet.

safe lintel
#

companion transform already creates garbage per companion so id say anything else is gonna be better unless 1.0 brings improvements

whole gyro
#

IIUC, the scriptable object bridge thing is mainly there to make it easier to access input from lots of different mono behaviors. If you go the ECS route, most of the input handling will be in systems instead. It is still possible to do something similar, but the workflow will be different.

#

I would stick with normal game objects in this case. And just keep DOTS in your back pocket as an optimization tool.

gloomy venture
rustic rain
#

ECS is totally other way of thinking

whole gyro
#

From my experience, ECS is great once you get the hang of it, but even then, I spend a ton of time figuring out nicer ways to handle certain problems. Input is actually one of those areas that I've been meaning to come back to. There aren't really best practices for a lot of things yet so you'll need play around with things and be willing to refactor everything.

rustic rain
#

I have found a nice approach for input for me

#

using components as input, and making systems run based of existance of queries

whole gyro
rustic rain
#

yeah, this

#

tbh

#

this approach is not THAT good, now that I think

#

because you can always extend any input

#

by creating new input component

#

and extensibility was key for me

gloomy venture
# whole gyro From my experience, ECS is great once you get the hang of it, but even then, I s...

I'm ok with this, I've been "around" Unity for a long time, but never really had time to settle into a committed period of working on it. Meaning I start getting some things figured out, then life and work happens and I step away for 6 months, and when I come back it's ground zero again. I have been wanting to jump on the DOTS bandwagon, as I think it's the future, but I also have some hard deadlines for this prototype, so will need to balance desire with reality.

whole gyro
rustic rain
#

someone else's approach

#

by creating huge struct of all inputs

#

is just better

#

the idea is this

#

you create entity, give it this component data struct

#

and never touch it ever again

#

it'll be static entity, kind of like world time entity

#

you grab pointer reference to that struct

#

and viola

#

the fastest access

#

to any field of this struct you want

#

for now I just don't see how to ease all code boiler plate it brings

#

as in my approach I used reflection

whole gyro
#

I assume some system needs to update the component data and would need to be done safely. And I would still need to check for an input in each system instead of conditionally running the sytem. It seems pretty much the same as the GetSingleton<MyBigInputStruct> approach but presumably faster and without and dependency tracking

rustic rain
#

which is done even before Initialization group

#

so it would be safe to use as pointer

#

quite literally just like Time component

whole gyro
#

Ah, didn't know when it ran. I use the C# class generation thing to receive callbacks but then write input in a system at the start of the init group

#

That seems like a good option for performance, but you can no longer make systems conditional on some input.

rustic rain
#

well, you can

#

but you shift that check

#

into Update method

#

tbh, not even sure what's faster

#

early return in Update, or not calling system at all through query

whole gyro
#

yeah that's basically what I'm doing now with the early return. But GetSingleton is a query so I guess its probably similar to the RequireSingleton approach. So I guess your pointer idea avoids any query.

rustic rain
#

GetSingleton is super slow

#

if it's only one entity

#

which gets this singleton

#

you should cache entity

#

and then use GetComponentData instead

whole gyro
viral sonnet
rustic rain
#

while get component data looks for exactly what you want

viral sonnet
#

read again ๐Ÿ™‚ not what i'm getting at

rustic rain
#

but I didn't mean RequiresSingletonForUpdate to be required

viral sonnet
#

when you don't need RequireSingletonForUpdate because the singleton gets created in OnCreate of the system, sure thing. with the update requirement the query would still get evaluated

rustic rain
#

still, GetSingleton is simply slower, because it has to find required query

viral sonnet
#

problem i see, most singletons are not created in the systems that also use them. otherwise, why make a singleton and not just cache the data directly in the system

#

i'm not saying otherwise

pliant pike
#

GetSingleton is slow leahWTF

#

my world is destroyed, I use that all the time

whole gyro
#

Let's say I want a system to update when left mouse button is pressed. From the options we talked about:

  1. Have one big input singleton. Return early if GetSingleton<Input>().LeftButtonPressed is false. Can use RequireSingletonForUpdate on the big input singleton, but let's just assume it always exists.
  2. Same as above, but cache the singleton entity. Check GetComponent<Input>().LeftButtonPressed instead.
  3. Have singletons per action. Use RequireSingletonForUpdate<LeftButtonPressed>.
  4. Create something like the world Time component.
gloomy venture
#

I may be grabbing the cat by the tail here, but I would think the Singleton pattern won't work well with Jobs and the Burst compiler. Unless the info in the singleton is read only?

whole gyro
rustic rain
gloomy venture
#

The new Input system is Event -driven though, so the singleton approach kinda pushes it back to the old Input. Is there no better way to take advantage of this event-driven model in combination with DOTS?

rustic rain
#

and if it does

#

it doesn't matter anyway

#

because input rarely gets to work with jobs

#

all of my input systems are ISystems

#

that run on main thread

viral sonnet
#

icomp singletons are nice for options/settings the player has. shared between many systems, mostly readonly and only some options menu can write to it

whole gyro
whole gyro
viral sonnet
#

i have written a few ways but i settled on nothing special, not even a system. MBs Update run before entities update so I gather inputs there and done ๐Ÿ™‚

gloomy venture
#

again, at the risk of being the noob in the room, is anyone using ScriptableObjects? it sounds like many of these singleton problems can be solved with them.

rustic rain
#

how do you imagine that?

whole gyro
viral sonnet
#

not quite, it's manually done and written to the correct entity. player/ai are all driven by the same input format so singleton wouldn't work. well, it would just for the player but it's not necessary, i know which entity to write to anyway

#

about singletons in general, use them when the data is shared between systems. otherwise, just use system data. that works also fine

#

(or just work with a known entity)

rotund token
#

unless your system has like 100s of queries getsingleton isn't that slow...

#

(i'm all for caching things though)

viral sonnet
#

agreed, it never catched my attention to anything i've done. if it makes life easier go for it. (i keep queries/systems down to a minimum - i can see a point where it could get problematic - some devs have like 300 systems or something crazy ^^)

rotund token
#

everyone enjoying their dose of dots news?!

viral sonnet
#

yeah forum is very active recently

rotund token
#

i for one love the, everyone speculates before release /s

viral sonnet
#

i'll say the same thing i say every week. next week!

rotund token
#

we'll see ๐Ÿ™‚

viral sonnet
#

eventually i'm right. just a matter of time

#

i've said this a couple of times, i'm a bit dissapointed there's no mention of other things. sure, the new baker is nice and looks very streamlined but what about the other stuff. there must be more

rotund token
#

no one's asked

viral sonnet
#

lol, maybe that's it ๐Ÿ˜„

gentle gyro
#

Sorry, I meant specifically rendering ECSs using the hybrid renderer on Quest 2...

whole gyro
# viral sonnet i've said this a couple of times, i'm a bit dissapointed there's no mention of o...

Personally, I'm most excited about the better editor integration stuff they showed off: https://www.youtube.com/watch?v=p4ct4vHWYt0

This video covers the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It also addresses a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with...

โ–ถ Play video
viral sonnet
viral sonnet
devout prairie
#

given it's basically a mobile platform with quite limited performance

rotund token
#

(though I am still concerned about 128 entity limit, but i'll profile and bring it up once i get to test rather than jumping on the anti-hype train)

whole gyro
#

Also, I don't remember if I they confirmed in that video, but scene view picking of entities is something I've wanted for a while now. Based on some commits to the graphics repo a few months ago, I think it is going to be in 1.0

rotund token
#

i can just give you this

whole gyro
#

Oh nice. I have something similar that works in the game view already. Hover an entity and press a button to pull it up in the inspector. But haven't tried to get something working in the scene view.

rotund token
#

even works with skin meshed renderers that you've attached to entities as hybrid

whole gyro
#

If you want to share it, that would be cool

rotund token
#

i think this is the primary code - it's definitely going to miss something small

#

i keep saying i'll release this core library but i keep getting lazy to cleanup some editor tool i need to remove first

#

i'll see if i can do it today because it's getting ridiculous

gentle gyro
devout prairie
#

a quick search on here brought this comment:

#

as far as i know, hybrid renderer does support vulcan so i'm guessing it's a case of getting the right combinations of unity editor and graphics driver version

#

in the Hybrid Renderer docs:

gentle gyro
rotund token
#

and release when i'm back

errant hawk
rotund token
#

Read forums, flurry of posts

wraith hinge
#

(probably biased because i work on the team for those things though)

viral sonnet
#

great to hear, i'm mostly excited about ISystem stuff. are nativeContainers also working now in ISystems or do we still have to use UnsafeContainers?

wraith hinge
#

yep nativecontainers work now

viral sonnet
#

๐Ÿคค

#

thanks for answering! ๐Ÿ™‚

wraith hinge
#

np! also p.s. enableable components and unmanaged shared components are pretty good too

viral sonnet
#

includes "actually working" ECB system too? that was also a roadstop for some of my systems

wraith hinge
#

EBC?

#

ECB! yes

rustic rain
viral sonnet
#

wow you got it all covered!

wraith hinge
#

ehm. let me check.

#

(i would be kind of surprised if that was a big deal either way? because the burst call overhead should be small compared to a whole system update. but checking...)

rustic rain
#

add to that stacked systems and it save quite some overhead

wraith hinge
#

it's 10 separate calls because it wants to have a catch around each update, and you can't catch in burst. i would be very interested in a profile where burst call overhead made a big difference here

#

i should say that in 1.0, systems are [alwaysupdatesystem] by default, and you have to sign up if you want to require matching queries for update. this is because everybody was always going insane because their systems weren't running and they forgot to say alwaysupdatesystem.

also, if you don't require matching queries for update, and you have a bursted isystem, you can just check if the queries match at the top of your update, and it should be just as fast

#

(i haven't profiled this comparison, it's just my intuition)

viral sonnet
#

interesting, that change is probably for the best.

devout prairie
viral sonnet
#
{
    // This reference provides read only access to the Turret component.
    // Trying to use ValueRW (instead of ValueRO) on a read-only reference is an error.
    readonly RefRO<Turret> m_Turret;

    // Note the use of ValueRO in the following properties.
    public Entity CannonBallSpawn => m_Turret.ValueRO.CannonBallSpawn;
    public Entity CannonBallPrefab => m_Turret.ValueRO.CannonBallPrefab;
}``` so this look like unitys way of giving us reference types without unsafe code. otherwise i'm confused what the purpose of the aspect is when every value is in Turret anyway
viral sonnet
#

uh [BakingType] attribute is cool. we are then able to put a dynamicbuffer or whatever on the entity which is removed after conversion

#

and GameObjectConversionSystem is obsolete in favor of [WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)] on SystemBase/ISystem

devout prairie
#

i always felt what was missing was a good baking system

#

deceptively hard to get a good sponge

viral sonnet
#

yep it felt a bit tacked on and not very streamlined

devout prairie
rotund token
viral sonnet
#

is that question related to the aspect?

rotund token
#

Yes

#

Because that's what aspects can solve

viral sonnet
#

burstable transform access?

wraith hinge
#

i mean you could just directly access the underlying components of a transform. aspects are just convenient

rotund token
#

Like translation is local

#

So is you want you want to set world position you need to check for parent, use local to world

#

Update translation to make sure you're world value isn't overridden

#

It's a huge pain replicating game object transform in entities atm

#

This is what I believe aspects can help solve

viral sonnet
#

well isn't the problem also that we can only get access to transform in IJobParallelForTransform? TransformAspect looks like a built in helper for that

rotund token
#

I'm not talking about gameobjects

#

I'm talking about replicating the same easy to use api that object transforms have but for pure entities

viral sonnet
#

ah i see

rotund token
#

In entities 0.51 how do you set an entity in a hierarchy to (10,0,10) world space

viral sonnet
#

but how would aspects solve that problem? the comps are local to the entity still and the same kind of data queries need to be done to determine what has to be set

rotund token
#

It wraps all the data for you and provides an api

viral sonnet
#

yeah sure, not 20 ComponentTypeHandles needed then

#

as you can directly query aspects the question comes up, how does it handle comps that are not added. like where we are using chunk.Has<T> now

rotund token
#

Without actually having source, hopefully transformaspect provides, position, localposition etc

devout prairie
#

Does it manage getting parent/hierarchy translation data etc in order to get set world and local values to a child?

rotund token
#

That's what I'm hoping

#

Otherwise I'll be implement my own anyway to do that

devout prairie
#

So I guess it could potentially be expensive if not done optimally

viral sonnet
#

if it doesn't it's kind of superfluous, just reducing boilerplate code isn't enough to get me to use aspects ๐Ÿ˜„

rotund token
#

To me aspects are the most important feature of entities in the future

devout prairie
#

That was kinda my thought tbh enzi

rotund token
#

It's what will let entities go mainstream

#

This reminds me of subscene hate

devout prairie
#

But yeah i think that's very true also

rotund token
#

I'll be preaching for 6 months and finally convince everyone

viral sonnet
#

it's not the same as subscene hate. it's like Entities.ForEach hate ๐Ÿ˜›

#

when aspects give the same control, fine. ๐Ÿ™‚

devout prairie
#

ForEach are great tho ๐Ÿ˜›

viral sonnet
#

same goes for, can i get the pointers

#

and does it actually play nice with burst and simd

rotund token
#

If you want entities to be popular you need to make it as easy to use as gameobjects

#

And the first step is making transform usage that easy

devout prairie
#

Kinda true tbh

rotund token
#

Stop people having to write complex maths to do basic operations

devout prairie
#

The ground level stuff is currently way too involved, I do see the point

viral sonnet
#

yeah agreed - i have to say though, because i have written the current project so often in different forms. entities will never go actual mainstream. OOP is just too convenient and fast to write

#

i've been doing this a long time now and my productivity just can't catch up to OOP shenanigans.

#

so in that sense, a LOT has to happen for entities to get really mainstream

devout prairie
#

I think theres still too much obvious stuff not benefitting from dots, animation etc

rotund token
#

Most gameplay programmers will never touch a pointer in their life

devout prairie
#

One of the true benefits of unity is rapid prototyping and the ability to just throw together a game in couple of weeks.. that's really not possible with dots atm, too many hidden traps etc

#

Conversion is the ballache of all ball aches

rotund token
#

How so

devout prairie
#

Jeez, dont get me started, it's all over the place

#

Monos subscenes this works this breaks that breaks this but not that etc etc, endless headaches

rotund token
#

Works flawless for me ๐Ÿ˜…

#

Though I will say I put a lot of effort into getting my architecture how I want

viral sonnet
devout prairie
#

Once you know what you're doing and have a workflow yeah

whole gyro
# rotund token In entities 0.51 how do you set an entity in a hierarchy to (10,0,10) world spac...

I feel like that's a tricky problem to solve. Are you are suggesting that Aspects should be able to read/write data from other entities? Even if that were true, I feel like there are complications. Like what if the parent's Translation was modified earlier in the frame but that change wasn't been written to the parent's LTW yet. And then you try to set the world position of the child. Is the aspect supposed to use the parent's LTW or recompute the parent's LTW from the parent's TRS components?

rotund token
#

You have a local to world

#

You just have to know if you're a child or not

viral sonnet
#

i'm definitely a child

whole gyro
#

lol

viral sonnet
#

๐Ÿ˜„

rotund token
#

All this type of stuff is secretly done under the hood for you in game object land

whole gyro
viral sonnet
#

i think the simple answer is, don't do it ๐Ÿ˜„

whole gyro
#

I'm curious if the transform aspect will write to LTW immediately when you modify the local position.

viral sonnet
#

and cases where LTW is not up to date could mean an ECB is involved

rotund token
#

You can make your world changes after transform system group is you need up to date positions

viral sonnet
#

but we don't even know if TransformAspect covers this. it's just speculation

rotund token
#

Entities promotes flat hierarchies where possible

#

Which is good, it's performant and why this problem hasn't come up that much

whole gyro
rotund token
#

But there are still cases where you might want to move a child in world space

wraith hinge
#

aspects are just convenience; all this stuff you're talking about is to do with the new proposed transform system (not for the first experimental release), which is supposed to help with some of the harebrainedness, but still has some kinks to work out

safe lintel
#

are there any more tidbits about the new transform system you can share? will physics utilize it?

#

also will it(new transform system) be part of the upcoming experimental releases this year (if it is not in the initial release)?

rotund token
#

it should be non-destructive in the sense that adding it to your project should change nothing by default (if you open settings though it will generate a scriptable object)

viral sonnet
#

lots of great stuff in there. you should make a readme at some point what's all included ๐Ÿ™‚

rotund token
#

in 0.5-2 years i'll release my game library

rotund token
viral sonnet
#

haha, i was half joking

rotund token
#

ah bloody hell i already screwed it up didnt delete a meta updated

viral sonnet
#

so for a simple close button in UIToolkit i can write btnClose.clicked += () => { asset.ShowVisualElement(false); }; the asset (main container) is snapped there. all good, but what about when i want to move this to a method? i haven't found a way to provide the necessary paramaters to a clickEvent

rotund token
#

what do you mean?

#

can't rider just generate a method that matches the delegate for you

viral sonnet
#

i can make a delegate but that would also have no parameter. It's just a simple Action, no parameters. there's also RegisterCallback<ClickEvent> - it's really the typical problem that UnityUI solves with EventSystem.currentSelected or something. a method has been called but it doesn't know from where. the UIToolkit sample mostly uses methods that rely on private variables from the class. i haven't found anything else.

viral sonnet
#

okay! i mean, oh K is in there.

rotund token
#

you want to have have multiple buttons mapped to same method?

viral sonnet
#

btnClose.RegisterCallback<ClickEvent, VisualElement>(Clicked, asset); private void Clicked(ClickEvent evt, VisualElement root) { root.ShowVisualElement(false); } that's kind of sick. i'm warming up to UIToolkit ๐Ÿ˜„

rotund token
#

i find it hard to remember all the events

#

and what elements support what events

viral sonnet
#

hehe, i wondered the same thing with ClickEvent. how many events exist? - in my case, i can remove it. i just need the root which needs to be closed by the button

viral sonnet
#

what i find really cool is how we can provide parameters for methods. that was usually not so great

rotund token
#

i just want this, but on a single page

#

instead of having to click through each individually

viral sonnet
#

yep, overviews are always nice. first time i reported a problem on a help page because these basic examples are kind of meh. without a forum post i would never have guessed RegisterCallback has a custom parameter. on 2nd view, rider would've shown me but i missed it

rotund token
#

honestly i didn't know

#

i don't recall having a case for it, but my UI use is pretty basic atm

#

learning these things is why i hang out on discord!

viral sonnet
#

how do you handle close button events now?

rotund token
#

i just change UI states

#
        {
            var state = this.GetSingleton<ClientState>();
            state.Value = new BitArray256 { [K<ClientStates>.NameToKey("host-game")] = true };
            this.SetSingleton(state);
        }

        private void JoinButtonOnClicked()
        {
            var state = this.GetSingleton<ClientState>();
            state.Value = new BitArray256 { [K<ClientStates>.NameToKey("join-game")] = true };
            this.SetSingleton(state);
        }

        private void OptionsButtonOnClicked()
        {
            var state = this.GetSingleton<ClientState>();
            state.Value = new BitArray256 { [K<ClientStates>.NameToKey("options")] = true };
            this.SetSingleton(state);
        }```
#

rest is handled for me by my UI management/state systems

#

switching states would close current panel

#

(i probably need to add a shortcut for this in the base class to clean up this api a bit - been ages since i've touched it)

viral sonnet
#

oh i see ๐Ÿ˜„ you circumvented the need for it

rotund token
#

yeah for example when that clientstate for options is set

#

my OptionStateSystem starts running

    protected override void OnStartRunning()
    {
        this.UIStateSet(K<UIStates>.NameToKey("options"));
    }
#

and changes my UI state to the options window

#

the menu knows nothing about my actual options UI

viral sonnet
#

it's a good system. i have the use case where i build several shops that include upgrades and every shop is another panel. so i don't have that 1:1 relation but a 1:n

#

building a system for each would be a bit of an overkill

#

how to kill productivity in 2 simple steps: install entities, install uitoolkit ๐Ÿคฃ

rotund token
#

oh i'm definitely going to have sub panels and stuff at some point

#

i just haven't really built anything for it yet

#

these states are only used for top level panels

#

so i'm sure i'll have more regular back buttons etc at some point

viral sonnet
#

this whole UIToolkit thing has set my knowledge about making UIs pretty much to zero. but i think it's for the best and probably a lot better once i've figured it all out. right now it's a veeeery slow process ^^

rotund token
#

entities 2.0 experience

rotund token
#

no

safe lintel
#

are we still waiting on worldspace for uitoolkit?

rotund token
#

yes - definitely a big limit atm

rotund token
#

i don't understand why anyone uses github for personal game projects

elfin spire
rotund token
#

been using it for years

#

the moment i hit the 1GB cap on github was time to move

elfin spire
#

I was told gitlab is mostly used by europeans, github by US folks

#

habits

rotund token
#

well i am neither

elfin spire
#

where from?

#

leaves australia

rotund token
#

i should probably use bitbucket (actually I used to)

#

(but yes australia)

coarse turtle
viral sonnet
#

does UIToolkit even have some kind of update event? i have a simple (cost) label that turns red when player has not enough funds. i mean, it's better when i loop over every active cost, evaluate and set - still wondering if there's any form to quickly prototype.

rotund token
#

what do you mean by update event

#

on value change? a tick every frame? etc

viral sonnet
#

tick every frame, something that related to a MB update

rotund token
#

no - at least i'm not aware of anything

#

it's reactive

viral sonnet
#

no wonder it performs better. it disallows shitty code ๐Ÿ˜„

#

i already stumbled over this but i forgot where. i know it's possible to query all those active cost elements

rotund token
#

do you just mean .Q<T>() ?

viral sonnet
#

yep and then followed by foreach

#

these selectors are pretty cool

#

that only works with query _rootVE.Query("shopContainer").ForEach(shop => { });

#

untested but Q has no ForEach

rotund token
#

oh yeah Q returns single element

viral sonnet
#

yeah, right. man, i knew that at one point - i'm getting so much information overload haha - anyway, works great to select it like that. kind of cool to have batch processing

#

the selector isn't a full css selector, is it? wonder if shopContainer:visible works

#

have to find that out tomorrow. now it's time for bed ๐Ÿ˜…

dense storm
#

Hey, just got started with DOTS.

#
public partial class RelativeMoveSystem : SystemBase
{
    protected override void OnUpdate()
    {
        new RelativeMoveJob
        {
            DeltaTime = Time.DeltaTime
        }.Run();
    }

    public partial struct RelativeMoveJob : IJobEntity
    {
        public float DeltaTime;
        void Execute(ref Translation translation, in Rotation rotation, in VelocityComponent velocity)
        {
            translation.Value += math.mul(rotation.Value, velocity.dir) * DeltaTime;
        }
    }
}

If I want this to run on multi-threaded jobs, I just change Run() to ScheduleParallel() and that's it?

#

And I'm getting this warning message, not sure how to fix.

dense storm
#

Is this everything I need to do to create an efficient system? What about disposing? When do I do that?

rustic rain
#

You can optimize it further by using ISystem instead of systembase

#

Since you don't use anything managed here

dense storm
dense storm
gentle gyro
#

Has anyone attempted to use the DOTS hybrid renderer on the quest 2?

rotund token
deft pilot
#

is this crazy? can you have a base type for a component?

#

ie/

public abstract FooBaseComponent : IComponentData
{
  public float Value;
}

public class BarComponent : FooBaseComponent
{
  public float OtherValue;
}
rotund token
#

no

#

well i guess if you used a class based component?

#

but 99% of the time you should be using struct components

#

and structs can't inherit

deft pilot
#

ahh right

#

structs can only inherit interfaces

karmic basin
deft pilot
#

what makes more sense in an ECS system for types of projectiles (tower defence game):

Have different components for different types of way a tower can fire: ie/ TowerProjectileDefaultComponent, TowerProjectileInstantComponent, TowerProjectileBeamComponent

where Default is like shooting a single projectile to a certain location that has flight time, Instant has no project just hits the enemy as soon as it fires and beam is well... a beam and hits whatever comes into contact first

Or should i just have a common component called TowerProjectileComponent that has a field that contains the type and I have one system that does everything?

#

or do i go even deeper and have the projectile built out of components

#

so TowerProjectileComponent just really only has data to build the Projectile

rustic rain
#

I'd say make some component of Default tower shooter
Which will have most standard settings for basic towers.
System will use it for shooting

#

In case you need something special, you'll use different component and different system

#

meanwhile Projectile is a whole different story

deft pilot
#

so package the whole shooting into a component

#

hmm

#

the problem is

#

there is no default

#

default is do nothing (i guess)

rustic rain
#

I meant that for towers

#

that shoot

deft pilot
#

thats defined by the user

rustic rain
#

projectiles each should have their own logic I think

#

I don't think having smth generic for projectile specific logic should be the case

#

again, aside from basic logic

deft pilot
#

for context - you build towers with components

rustic rain
#

like for example normal movement, from tower to target (like arrow)

deft pilot
#

each component changes what its suppose to do

#

so there isn't really a default behaviour

#

so you are given a base tower that literally just does nothing

#

and upgrades you drag onto the tower to give it abilities

#

like to shoot

#

(and how it shoots)

#

only came up with this idea cause testing out ECS

rustic rain
#

ECS is composition

#

not inheritance like OOP

#

so you should probably drop any good practices while thinking in ECS world

#

in ECS logic will be hardcoded 99% of times

deft pilot
#

it is hard coded thou?

#

there is nothing "inheritance"-cy about this

rustic rain
#

then maybe I didn't quite understand you well

deft pilot
#

so consider an entity

#

that gets lets say afew components added to it

#

systems act on those components driving functionality right?

rustic rain
#

systems act based of queries of required component

#

they will go through all entities that match query

deft pilot
#

thats a low level overview

rustic rain
#

regardless of how many components you added

deft pilot
#

yes

#

so you agree right?

#

at a high level thats how it works

#

you could literally replace "driving functionality" with what you said

#

if you want

#

i just didn't think i needed to go that indepth for that

rustic rain
#

if you want "replacing" functionality of logic

#

Unity ECS has write groups

#

which can filter entities if they have components that belong to chosen write group

deft pilot
#

i'm not asking for help on how to write this on a low level

#

i'm trying to figure out what the best way to tackle this is

#

cause it depends on how i want to separate out the responsibilities depends on how i write my systems

#

which was basically the question

#

anyway dw about it i'll just think on it maybe i'm not wording the question right?

#

thought i was as clear as i could be in the initial question

rustic rain
#

Nah, it's just me not being smart ๐Ÿ˜…
If I wanted to make TD I'd first figure functionality categories
Tower shooting | Projectile movement | Unique projectile logic

#

so most towers will have most basic shooter, smth like CD based with different settings
For some unique towers, that need to shoot differently (for example based of player input) - their own component, which can also be shared among different types of towers

deft pilot
#

but you are under the assumption there are tower templates right?

rustic rain
#

for projectile movement I'd just implement logic for each kind of movement required. Linear, drop from sky, make some zig zags and etc

deft pilot
#

would you make each type of movement a component or a value in a component?

rustic rain
#

component

#

obviously can store it all in one though

#

but that would be pretty messy

rustic rain
#

I'm just imagining old TD game

deft pilot
#

fair enough

rustic rain
#

what was it called... hmm

#

it's from WC3

deft pilot
#

elemental td?

#

line tower defence?

#

dice td?

rustic rain
#

Element

#

yeah

deft pilot
#

yeah so traditional tds

#

have a set tower

#

and set upgrades

minor sapphire
#

There is no one size fits all solution of course, you just need to think about all your requirements up front. Projectiles can move , maybe they can pierce, when they hit or end what do they do... Damage, debuffs, these things can be aoe...?

Imagine now how you want to configure a projectile with these things in mind, think of how that data will drive through into systems.

#

You may have a debuff system here, a damage application system, the concept of damage instances, how to determine damage instances (aoe? Immunity?)

#

There are many ways this problem could be broken down

deft pilot
#

yeah

minor sapphire
#

Imo start with understanding your requirements, then draw up a mock config for yourself

#

The problems will start revealing themselves

deft pilot
#

basically yolo'd in and had to refactor so many times so its why i've stopped and considered this question

minor sapphire
#

In my company I'm the diagram guy now cause thats how I figure out how to proceed with a new feature haha

deft pilot
#

hmm so my main problem with the solution right now is

#

if you allow a user to "build a tower" - so lets say they add a projectile to it

#

and they add another projectile to it so lets say it fires with two different projectiles now

#

you can't actually do that

#

due to unique constraints on projectiles

#

since you can't make them a component

#

so i'd have to make them an entity

#

but then if i make them an entity how does other things the user adds to the tower effect the projectile

minor sapphire
#

You're revealing some requirements

deft pilot
#

lets say they add the on hit effect AoE as you mentioned

rustic rain
minor sapphire
#

A turret can shoot multiple projectiles

#

So turrets spawn projectiles. Seems perfectly fine.

#

Why can't they shoot 2?

rustic rain
deft pilot
#

cause you can't add two components of the same type to a entity

#

so lets say we have TowerProjectileArrowComponent or something

#

you can't add that again

minor sapphire
#

Dynamic buffer

#

Add as many as you want

deft pilot
#

so TowerProjectileBuffer

#

that takes eh...

#

some base class of projectiles?

minor sapphire
#

I'm just saying, given you have your requirement, this is one possible solution

#

Some projectile config

deft pilot
#

right

#

projectile config

rustic rain
#

yes, you can't add same type of component, but why do you even need it?

deft pilot
#

that would make more sense

minor sapphire
#

Projectile settings

deft pilot
minor sapphire
#

Thst can define appearance, audio, speed, aoe, piercing, etc. Oorrrr do it differently

#

Maybe you just give it an entity prefab

rustic rain
#

If you want tower to shoot 2 different projectiles based of some upgrades to it, you should probably make component set that allows for that

#

like mentiond dynamic buffer + config

minor sapphire
#

Sooo many possible ways

deft pilot
#

okay let me try this first

#

see how it goes

minor sapphire
#

Don't imo

deft pilot
#

i'll be back probably

minor sapphire
#

Start with thinking through other options lol

deft pilot
#

this makes sense however

minor sapphire
#

Just jump on first suggestion

deft pilot
#

it fixes most of the problems

#

i've had

minor sapphire
#

Ok up to you lol

deft pilot
#

i can't think of any edge cases right now

rustic rain
#

just do smth first kek

deft pilot
#

anyway thanks guys @rustic rain @minor sapphire

minor sapphire
#

Maybe you have a 'firing' config

#

Thst references projectile prefabs

#

Defines what you shoot when

#

The projectile entity has lots of components on it to define its behaviour

deft pilot
#

yeah that will be driven by the dynamic buffer config

#

rather then a prefab

minor sapphire
#

Ok enjoy ๐Ÿ˜„

deft pilot
#

config will be created by an SO i guess

minor sapphire
#

Go forth and compile

deft pilot
#

thats my train of thought so far

muted star
#

Hey everyone, where can I find the ECS pool table example scene on github? I heard that it somehow uses physics deterministically.

I would like to use deterministic physics but couldn't get it to work with my initial attempt.
The positions and rotations after the physics simulation are always slightly different between machines.

How I tried making physics deterministic:

protected override void OnUpdate()
        {
            ...
            
            fixedDeltaTime = (float)env.GetVirtualTickRate().TotalSeconds;
            physicsSimulationWorld.SetTime(new TimeData(elapsedTime, fixedDeltaTime));
            elapsedTime += fixedDeltaTime;
            physicsSimulationWorld.EntityManager.MoveEntitiesFrom(
                EntityManager,
                entitiesToTransferQuery
            );
            physicsSimulationWorld.Update();
        }
#

(physicsSimulationWorld is my only world where the physics systems are present)

karmic basin
#

IIRC they use another world that they tick multiple times in the future to predict positions and collisions

#

and com.unity.physics is supposed to be deterministic between nearly every platforms yeah

muted star
#

Thanks @karmic basin I'll have a look.
As far as I remember MoveEntitiesFrom jumbles up the entity IDs non-deterministically,
so my suspicion is that this causes the physics systems to behave non-deterministically aswell.

errant hawk
#

any DOTS updates I should know about?

robust scaffold
errant hawk
safe lintel
#

well its company training, not end user training unfortunately

errant hawk
viral sonnet
balmy thistle
#

What makes you say that?

muted star
#

Hi everyone, I don't think I can use Unity physics for my project.
I would like to simulate physics for up to 1000 objects every 33ms.
I need a deterministic simulation. I think this should be possible with PhysX or Bullet.
(I know ECS physics can do this aswell, but not in my case)

Do you have any recommendations for a physics library which would be a good match for Unity ECS?

#

2D physics would also be fine

viral sonnet
rustic rain
balmy thistle
misty wedge
#

It probably wouldn't be deterministic enough for something like lockstep networking, maybe that's what he's trying to do

karmic basin
#

@muted star There's also a framework by DreamingImLatios if you're unaware might be worth a look

viral sonnet
#

afaik dreamings is deterministic. at least as far as possible, true determinism over several cpu architectures doesn't exist yet in unity

#

it would require a custom datatype. (has a name, but i forgot) photon engine uses that

karmic basin
#

Ooh I thought I remembered even Unity were pretty close to a 99%+

#

but maybe I remember wrong

balmy thistle
#

Well, there's physics determinism, netcode determinism, and cross-platform determinism which are all kettles of fish

#

Unity physics AFAIK is deterministic

rotund token
#
  • on same hardware
balmy thistle
#

yeah that's why I called out cross-platform determinism

viral sonnet
#

has anyone tested out the performance of uitoolkit queries?

#

i'm not sure if it's wise to build systems that rely on querying each frame

viral sonnet
#

hm, i really have some conceptual problem with how updating should work best with uitoolkit. if you imagine a spellbook that has like a 100 spells, not all visible and they can turn active/inactive based on if the player has the resources. previously such a spellbook button would have a simple cost and Update method that turns the button either white/red. now with uitoolkit, hm, i don't really know. should i build data in parallel to the visualElement. one system that queries visible spellbookButtons and then updates from that (would require some kind of hashmap to get the associated data) - bunch of ideas for it but nothing really great

dense storm
#

How do I transfer data between GameObject <-> Entities?

viral sonnet
#

the simplest answer is, don't. at least make it one way only. that aside, the entry point is relevant. from a gameobject you can just query entityManager and the components. from an entity, it only really works in non-burst code and having a Transform on the entity. other MonoBehaviours are supported but not all so the question is bit broad to answer specifically

rotund token
viral sonnet
#

to determine visible spellbook buttons. otherwise i don't even know what to update - can't update all

rotund token
#

spell X unlocked, set X spell visible

#

what you need is to determine when a spell is activated/inactivated

#

i don't think you should be querying your UI to determine this

#

should be part of your model

#

also i assume you would be populating this spell book dynamically from your game data off a template

#

so you don't even need to query the elements, you would be creating them and already have the reference you can map somehow

viral sonnet
#

hm, i'm very familiar with the MVC pattern. big difference there, i can have code in the view, which is nice and powerful. here it's just a bunch of xml tags. and what i want to avoid is creating more code - i don't feel like that's elegant at all

rotund token
#

hmm i disagree

#

i think you should be writing code to build yourself custom elements to encapsulate their behaviour

#

i think you should have a SpellElement for example

viral sonnet
#

and that spellElement is a monobehaviour or what do you mean with that?

rotund token
#

spell element

#

is a VisualElement

#

this is the kind of thing unity does if you look through their code

#

they build elements from a collection of other elements and attach logic to them

#

etc

viral sonnet
#

ohh i see ๐Ÿ˜„ well that makes sense

#

where are these examples from?

rotund token
#

just first thing i found in this project

#

searching : VisualElement

#

๐Ÿ˜„

viral sonnet
#

nvm yeah found it ๐Ÿ˜„

rotund token
#

they were from the Version Control package

viral sonnet
#

collaborate namespace threw me off

#

at least that solves the issue of where do i even store model data ๐Ÿ˜„

#

thanks man ๐Ÿ˜„ these are the kind of concepts that i wouldn't have found in the docs

urban ore
#

Is there any public list of changes coming in ECS 1.0? I just ran into a really odd situation around the BlobBuilder, and was wondering if there's going to be an update to it or if this is just the way it has to be?

rotund token
#

just fragments here and there

#

what was the issue?

urban ore
#

Well, it's not necessarily an issue? It's just that it's a disposable struct. So if you wrap it in a using statement, you can't pass it by ref into a helper function.

#

So in order to get it to work, I had to unroll the using statement manually into a try/finally. Which is just really odd, to me.

rotund token
#

ah yeah, classic c# limitation

urban ore
#

Yeah. There's a lot of words online about how disposable structs aren't really a good idea. But I'd guess that this is probably a struct because it needs to be in Burst or something?

#

What really caught me off-guard is that I was just using Resharper's automatic extract method functionality in my code while refactoring... and it broke it because it didn't pass it by ref into a helper function.

#

Which it obviously couldn't do because... disposable struct with a using statement... Just odd. Was wondering if there's anything for it in the next version. If there's no clear documentation yet I'm perfectly happy to wait!

viral sonnet
#

sooo, the dragon crashers uitoolkit sample uses monobehaviours as controllers (mostly individual) and for something like a progressbar (ability cooldown in their case) a simple Update routine. really not much difference here other than everythings decoupled from UIToolkit

#

the big question now, why the roundabout way and not just a link from a templateContainer/visualElement to a mono script

#

i still don't quite get it. the nice thing about UnityUI was that with a gameobject enable/disable the UI and scripts were disabled. now i have to manage them in some way and it's quite hard to build a generic system for it. if i have any cost label that should turn red when the player doesn't have enough gold/resource i need to handle every occurrence where a cost label could show up and toggle the script based on the visibility of the uitoolkit element. this form of decoupling is total nonsense - doesn't help in the slightest

#

(pardon my negativity as I'm figuring this out) ๐Ÿ™‚

wraith hinge
# viral sonnet the simplest answer is, don't. at least make it one way only. that aside, the en...

this is true for high-throughput stuff, but if youโ€™re not transferring very much data, itโ€™s actually totally fine and indeed necessary to control things like cameras, audio, and anything else that may not have a dots-native interface. if nothing else, you can just have a static variable on a monobehaviour that you update from a systemโ€™s onupdate or similar, as long as itโ€™s not bursted. (If itโ€™s bursted you can still do it but it gets complicated.)

rotund token
#

sigh been putting this off for a couple of months as i knew it was going to depress me

#

but i finally tested entities 1.0 128 entity per chunk cap

#

and my effect system update time goes from 2.03ms +-0.1ms to 4.74ms +0.2ms

#

on 10mill idle effects

rustic rain
#

1.0 is here?

rotund token
#

no

#

soonโ„ข

minor sapphire
#

Ouch

muted star
muted star
muted star
muted star
muted star
rotund token
#

moving entities between worlds though would definitely require the exact same tick on physics though

#

moving then would have to be done in fixed update

muted star
# rotund token moving then would have to be done in fixed update

Do you mean fixed update from a monobehaviour?
This is how I'm doing it currently.

        protected override void OnUpdate()
        {
            ...
            
            Debug.Log("Moving Entities from Simulation World to physics World");
            fixedDeltaTime = (float)env.GetVirtualTickRate().TotalSeconds;
            physicsSimulationWorld.SetTime(new TimeData(elapsedTime, fixedDeltaTime));
            elapsedTime += fixedDeltaTime;
            physicsSimulationWorld.EntityManager.MoveEntitiesFrom(EntityManager, entitiesToTransferQuery);
            physicsSimulationWorld.Update();
        }```
rotund token
#

no fixed update system

#

what you're doing there doesn't look deterministic at all to me though

#

you aren't updating a fixed update potentially multiple times in a single frame

#

it's update could drift quite far away from what it needs to

#

hmm actually wait no

#

maybe that's fine

#

i can't tell if your fixedDeltaTime

#

is actually fixed?

#

you seem to set it every frame

#

implying it's not the same

#

but if you're using fixed step simulation group inside your world this doesn't matter

muted star
#

fixedDeltaTIme is always the same, I could have set it in OnCreate

rotund token
#

so you're passing a fixed time to a world

#

in a regular update?

#

aren't you just either ticking your world faster or slower than it should be

#

or did you remove FixedStepSimulationSystemGroup

muted star
#

I removed all physics systems from all my worlds except for the physics world

rotund token
#

yes but do those physics systems still update in FixedStepSimulationSystemGroup?

#

and if so why are you passing in a fixed step to the world from a non fixed update

muted star
rotund token
#

FixedStepSimulationSystemGroup manages the fix step for you

#

converting non-fixed time to fixed time

#

hence i'm unsure why you're managing this yourself

#

and it's doing my head in if it'll actually be a problem

#

i think it definitely could be if you haven't set the timesteps up to match

#

but i'm pretty sure it is. if you're updating at 100 fps (10ms tick) and fixedDeltaTime is 50fps (20ms tick) then you're passing 20ms into the physics update and updating every frame when it should only be updating at 10ms and skipping every 2nd frames

#

yeah the more i write this out the more wrong it seems. you're basically updating your physics world in Update with the wrong delta time

#

you can quickly test if i'm right/wrong
change your (float)env.GetVirtualTickRate().TotalSeconds to be x10 larger

#

if the simulation is the same i'm wrong

#

if it speeds up 10x i'm right

#

save me thinking about it

muted star
#

I can try to explain how my code works overall perhaps it will be more clear then:

  1. Simulation world systems run.
    The last system in the simulation world transfers all simulation entities to the physics simulation world and manually updates it (once all long running jobs were completed).

  2. The last system to run in the physics simulation world immediately transfers all simulation entities to the presentation world.

  3. The presentation world copies all the data from the simulation entities to presentation entities.
    The last system in the presentation world immediately moves all simulation entities to the transfer world.

  4. The transfer world's only job is to wait for the next message from the host.
    The host sends a message to all clients every 33ms in production. (This is the GetVirtualTickRate().TotalSeconds seen in the code above)
    Once the wait is over, the transfer world moves all the entities to the simulation world and the process starts from step 1 again.

#

TLDR: It's fixed lockstep

rotund token
#

hmm so it's lockstep
have you set your FixedStepSimulationSystemGroup to use the same FixedStep?

#

that said it shouldnt matter

#

it might just tick twice per frame

muted star
muted star
rotund token
#

yes

#

FixedStepSimulationSystemGroup sets the fixed update to 1/60

#

so your physcis world is ticking at 16.67ms

#

if you're updating it at 33.33ms

#

it's going to tick twice per update you call

#

maybe once, maybe 3 times depending on float rounding

muted star
#

Could it be a solution to move all the physics systems outside of the FixedStepSimulationSystemGroup then?

#

(if thats even possible)

rotund token
#

easier to just set FixedStepSimulationSystemGroup.RateManager = null

#

so it stops running it's own fixed update

#

and will use whatever you pass in

muted star
#

okay I'll try that ๐Ÿ™‚

errant hawk
#

is there a parallel way to do GetComponentDataFromEntity ? I need to access some nested entity components and errors get thrown when I don't use [ReadOnly] but I need write access

#

disabled parallel restriction, seems to work fine

rotund token
#

thats the way

errant hawk
#

I guess CDFEs are atomic internally when it comes to R/W?

rotund token
#

no

#

you are responsible for ensuring what you are doing is thread safe

#

when you turn off safety

#

you are saying that no other thread will be reading this element

errant hawk
rotund token
#

the specific entity/component

errant hawk
#

so why does the CDFE need to be a container-type?

#

I did some digging in the source code, and I couldn't find anything

rotund token
#

what do you mean by container type?

errant hawk
#

it's a native container

rustic rain
#

is it?

#

I thought it's just wrapper for index type

#

and r/rw access type

errant hawk
#

why else would it require NativeDisableParallelForRestriction for parallel r/w?

rustic rain
#

because that's what safety is for?

errant hawk
#

yeah that's the thing

rustic rain
#

if you aim to do parallel r/w on it, you can get into race condition

#

unless you know for sure you don't

errant hawk
#

if it's not a container type needed to be initialized from the system, why are we not able to initialize a CDFE from within a job?

rustic rain
#

when you write to component

#

you also write version

errant hawk
#

Well, instead of using a CDFE, why not just a utility struct that you need to initialize for each job?

rustic rain
#

? what utility struct?

errant hawk
#

Hypothetically

rustic rain
#

I don't get it

errant hawk
#
var ecs = m_Access->EntityComponentStore;
ecs->AssertEntityHasComponent(entity, m_TypeIndex);

CheckComponentIsZeroSized();

void* ptr = ecs->GetComponentDataWithTypeRO(entity, m_TypeIndex, ref m_Cache);
UnsafeUtility.CopyPtrToStructure(ptr, out T data);

return data;
#

that is what is being done to read a component from a CDFE

rotund token
#

because you don't have any safety?

rustic rain
#

yeah, reading is very fast

#

but I still don't get what you meant ๐Ÿ˜…

errant hawk
#

What Im saying is why does there need to be an individual CDFE for each type in your job when it could be just some utility struct that also has safety like a CDFE

rotund token
#

because safety is per component

#

otherwise your utility struct would cause a dependency on every component and every job

rustic rain
#

yeah, if system doesn't know what component you'll use

#

your job will be isolated from any other

errant hawk
#

this safety shit is starting to really annoy me lmao

rustic rain
#

I think that's what dynamic type handle does

rustic rain
#

if your solution is thread safe

errant hawk
#

yes it's thread safe, hence why I find it odd needing CDFE in the first place

#

absolutely nothing other-than a single thread is accessing the specific component, and no other system ever will write to it

rotund token
#

but your job is running in parallel?

#

otherwise it wouldn't be an error

rustic rain
#

what if other job wants to write to that component

errant hawk
#

It wont lol

#

again, these are nested entities

rotund token
#

yes but entities doesn't know this

#

you could well be giving it non-nested components for all it knows

errant hawk
#

it does since I cached them in a DynamicBuffer ๐Ÿค”

rustic rain
#

what nested means?

errant hawk
rustic rain
#

no, I don't know definition ๐Ÿ˜…

errant hawk
#

child entity, exactly the same as GameObjects being children to a parent GameObject

rustic rain
#

ah, what makes them special then?

errant hawk
#

ok so to be more specific, I have a component called a VehicleBase and a buffer DynamicBuffer<WheelBase> that is of type WheelBase. There are x amount of wheels per VehicleBase and each WheelBase has a reference to an Entity (along with other data)

#

it works perfectly fine the setup I currently have

#

but

#

I always questioned the requirement of CDFEs (disregarding safety) for my specific use case

#

when I could in theory just read/write to a pointer of that specific component

rotund token
#

which is all cdfe is wrapping for you?

errant hawk
#

that's what I mean, why is it even needed per-type when a simple utility struct can be used instead

rotund token
#

because safety

#

cdfe is just a utility sturct

rustic rain
rotund token
#

and provides caching for speedup

rustic rain
#

you can make your own clone

errant hawk
#

idc about safety because I am r/w to isolated components that are never accessed outside of a single thread

rustic rain
#

or use Enzi's unsafe implementation

#

that won't write to dependency

#

and can access any component

#

with internal access pretty much anything is possible

errant hawk
#

Pretty much all I want is a utility struct that allows me to r/w to any component in complete disregard for safety, while not having to specify for each type.

errant hawk
#

I would, but idk how to actually access a component outside of a CDFE

rustic rain
#

it's pretty simple

#

considering internal implementation does it for you

errant hawk
rustic rain
#

there's Assembly Reference asset

#

which gives you it

#

with internal access everything is so much brighter ๐Ÿ˜…

errant hawk
rustic rain
# errant hawk not sure what that even is or where to find it
errant hawk
#

one thing I wont be doing is modifying packages

rustic rain
#

you don't modify package

#

you reference it in your own

#

and extend it from different assembly

#

Unity works with it

errant hawk
#

oh alright, I'll look into that eventually

rustic rain
#

create folder somewhere, create assembly reference asset
choose whatever assembly you want to extend this way
And then create class with that attribute for assembly

#

in attribute you can simply define string namespace

#

of your choice

#

sad part, that only works on initial developper

#

modders can't access it

#

BUT

#

modders have publicizer

#

which is even better, cause it makes even private fields public

#

kek

errant hawk
#

I imagine 1.0 will add more unsafe stuff

rustic rain
#

I only hope 1.0 will swap most private fields to internal

errant hawk
#

doesn't make sense if they only made NAs have unsafe alternative

rustic rain
#

allthough doubt

#

they want to add more unsafe

#

I have a feeling that at some point

#

they will even have some sort of safe wrapper on pointers

#

kek

errant hawk
#

well, I notice a lot of their methods are public, but struct/class is internal

#

my guess is they just want people to work in a safe context only for now

rustic rain
#

yeah

#

pretty much

errant hawk
#

so they dont get bombarded with issues/questions regarding unsafe context that unity devs dont want to answer right now

#

which makes perfect sense

rustic rain
#

But ppl demand more unsafe stuff ๐Ÿ˜…

errant hawk
#

so far the only issue with DOTS for me has been the physics engine lag that appears out of nowhere

#

and a few GUI glitches

rustic rain
#

not just lag...

#

it's glitching

#

somehow

#

in editor

errant hawk
#

yeah but they're nothing horrible

#

usually just a refresh or similar will work

#

On a more unrelated note: I'm finding Span<> to be a bit faster than a NA when allocated on the stack. Nothing massive, but a 0.1-0.3ms decrease is pretty good imo

rustic rain
#

how does it look?

#

any example?

#

I'v heard about it a lot

#

but never really saw

errant hawk
#

well, it's a stack allocation so it's always going to be faster than an array (which NAs are similar in preformance to IIRC)

#

plus, no need to manage memory as it does it for you

#

best way I can put it is "unsafe safe code"

#

better than NAs initialized in a job imo

rustic rain
#

I just ask for some screenshot of codeblock as example

#

in Unity ECS context

#

if possible

errant hawk
#

Span<ContactData> contacts = stackalloc ContactData[buffer.Length];

#

for contact solving for my wheels

rotund token
#

but yes it's just stackalloc with safety

errant hawk
#

and my ContactData is just a wrapper for some data:

        public readonly struct ContactData {
            public readonly WheelCollider wheelCollider;
            public readonly RaycastHit hit;
            public readonly bool collision;
            public readonly float force;

            public ContactData (WheelCollider wheelCollider, RaycastHit hit, bool collision, float force) {
                this.wheelCollider = wheelCollider;
                this.collision = collision;
                this.force = force;
                this.hit = hit;
            }
        }
rotund token
#

Alternatively unity has fixedlist etc

#

For stack allocating

narrow scaffold
#

Quick question:
When I want to represent a temporary state on an entity, for example a "poisoned" status effect. My first intuition would be to just add a component containing the relevant data to that entity as soon as the state is triggered. However I have read that adding and removing components during runtime is not the best practice performance-wise because of the chunk system. What would be the idiomatic approach for that problem? Should I just have all components that an entity might need in it's lifetime there from the start and activate/deactivate them by need?

rustic rain
#

so feel free to add/remove comps

#

alternatively

#

you can come up with a system that does it without structural changes

#

but I bet, it won't be as extendable as components

rotund token
#

if you want a flexible system first question to ask is why is poisoned a special component

#

what about burning

#

or radiation

#

or acid

#

etc

#

are you just going to make 1 component for every effect? at end of day why are they any different

#

do the same thing, maybe slightly different tick rates and damage types but that's just data

narrow scaffold
#

Okay thats reassuring. I watched the interview with the v-rising developers and they said they rarely add or remove components on entities because of performance.
But you are right, for my example it would make much more sense to have a status effect component that can represent different effects if they are not too different

rotund token
#

(Personally my effect/condition system is completely static archetype. in fact my entire game is except for state components)

rustic rain
rotund token
#

(but this is not easy to do without a lot of experience)

rotund token
#

+1 strength is the same as 50 poison damage/second

narrow scaffold
#

Out of curiosity, how do you handle state transitions? Like actions that should only be performed when first entering/leaving a state?

muted star
# rotund token yes

I think I just found the reason for my physics not behaving the way I want.
I just added a system into the FixedStepSimulationSystemGroup of the physics simulation world for debugging purposes and it turns out Time.DeltaTime is always different.
For instance Time.DeltaTime was 0,0128766 even though I called physicsSimulationWorld.SetTime(0, 1000) before calling physicsSimulationWorld.Update()

rotund token
#

yes because FixedStepSimulationSystemGroup has its own fixed update

#

this is what i'm saying

muted star
#

In my ECS bootstrapper I did as you suggested
physicsSimulationWorld.GetExistingSystem<FixedStepSimulationSystemGroup>().RateManager = null;

rotund token
#

my individual actors don't really use any

#

i do have limited states

narrow scaffold
#

Oh thanks that is very helpful. Still trying to wrap my head around thinking in systems so every example is great!

rotund token
#

this basically turns a bitfield into state components

#

without having to know the components

#

supports both only 1 state or multi states

muted star
#

yes because

rustic rain
#

I wonder if there's a way to quickly generate wrapper for bits

#

so you can have struct size of 4 bytes with 32 possible states

rotund token
#

you mean like a bitmask of any size you want?

rustic rain
#

practically

rotund token
#
        private struct Bytes4 : IFixedSize { }```
define a struct of any size you want
#

or if you want some huge size, feel free

        private struct Bytes1337 : IFixedSize { }```
rustic rain
#

nnnah, I just wonder about using bitmasks

#

for sake of keeping size low

#

for multiple boolean fields

rotund token
#

with a lot of functionality

rustic rain
#

for example my vanilla game input most probably won't use over 32 bits

#

so why bother creating huge struct

#

of 16 bools

rotund token
#

i use a lot of bitmasks

#

very important for networking

rustic rain
#

oh

#

keeping size low

#

right xD

viral sonnet
rustic rain
viral sonnet
#

yeah but it still requires a [NativeDisableParallelForRestriction] which you were talking about

rustic rain
#

which is even easier

#

kek

misty wedge
#

What's the fastest way to create a List from an UnsafeList? Is there some way to just set the list's internal array?

rustic rain
#

yeah, there is a way to add through pointer

#

lemme check if I can find it

#
        public static unsafe void AddRangeNative<T>(this List<T> list, void* arrayBuffer, int length)
            where T : struct
        {
            if (length == 0)
            {
                return;
            }

            var index = list.Count;
            var newLength = index + length;

            // Resize our list if we require
            if (list.Capacity < newLength)
            {
                list.Capacity = newLength;
            }

            var items = NoAllocHelpers.ExtractArrayFromListT(list);
            var size = UnsafeUtility.SizeOf<T>();

            // Get the pointer to the end of the list
            var bufferStart = (IntPtr)UnsafeUtility.AddressOf(ref items[0]);
            var buffer = (byte*)(bufferStart + (size * index));

            UnsafeUtility.MemCpy(buffer, arrayBuffer, length * (long)size);

            NoAllocHelpers.ResizeList(list, newLength);
        }
#
        /// <summary> Resize a list.  </summary>
        /// <typeparam name="T"><see cref="List{T}" />.</typeparam>
        /// <param name="list">The <see cref="List{T}" /> to resize.</param>
        /// <param name="size">The new length of the <see cref="List{T}" />.</param>
        public static void ResizeList<T>(List<T> list, int size)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            if (size < 0 || size > list.Capacity)
            {
                throw new ArgumentException("Invalid size to resize.", nameof(list));
            }

            if (size == list.Count)
            {
                return;
            }

            if (_resizeListDelegates == null)
            {
                var ass = Assembly.GetAssembly(typeof(Mesh)); // any class in UnityEngine
                var type = ass.GetType("UnityEngine.NoAllocHelpers");

                var methodInfo = type.GetMethod("Internal_ResizeList", BindingFlags.Static | BindingFlags.NonPublic);

                if (methodInfo == null)
                {
                    throw new Exception("Internal_ResizeList signature changed.");
                }

                _resizeListDelegates = (Action<object, int>)methodInfo.CreateDelegate(typeof(Action<object, int>));
            }

            _resizeListDelegates.Invoke(list, size);
        }
#

_resizeListDelegates
that should be a field in your static class

misty wedge
#

Where are these functions?

#

Or is this not part of e.g. collections

muted star
#

Hey guys, I would like to set the update rate of the FixedStepSimulationSystemGroup to something really fast, like 1 ms for instance.
At the same time I would like the deltaTime used by the systems within that system group to be 33 ms.

This is so I can manually call .Update() on the world every ~33 ms without having to wait up to another 33ms for the system group to be updated with the 'correct' deltaTime.

Is this possible?
If not the only other option I see currently would be to make my own version of the systems within that update group to fit my needs and to put them in my own update group.

#

physicsSimulationWorld.GetExistingSystem<FixedStepSimulationSystemGroup>().RateManager = null didn't work btw.
It would of course be ideal if the rate manager could be ignored completely and all the systems within the group be updated manually (without having to wait for a rate manager at all)

rustic rain
viral sonnet
#

i think the code should answer your questions

muted star
#

okay, thank you!

viral sonnet
#

and yeah i would suggest setting up your own group for this

#

what you can also do is call .Update on the group every frame. basically ticking it yourself. (ah you already do that)

muted star
merry vapor
#

Hey everyone. Started messing with ECS this weekend. Certainly liking the idea of it. But I'm also running into complications and all the usual setup issues. I'm thinking for the project in question I probably dont need URP either.

I really just need a subscene type setup. Thats what I was setting up with ECS for - to be able to break up levels into sections and toggle them on and off as needed.

Given I'm uncertain about URP and aiming for a pretty graphically simple game, do you think better off making a simple custom system to just activate/deactivate sections of the level as needed instead?

viral sonnet
# muted star I didn't know that was a thing. Currently I call Update() on the world

yeah, it's pretty convenient. i was utilising this to implement a timelapse/fast forward for the game. just needed a custom group and called update on it once. the group itself called update on itself then a bunch of times which triggers the update of the systems. just need to handle scheduled jobs because those need to be completed before the next update call

dense storm
#

Both bullet and player have entity representation

viral sonnet
#

on conversion you can use AddComponentObject and your transform. the transform will be then on the entity and can be used to GetComponent a monobehaviour. you either whitelist your manual MB components or make a hashmap/dictionary for faster lookup to not always have to call GetComponent

dense storm
devout prairie
#

So i think i'm failing to see the wood for the trees here.. I'm getting this error:

#

Appears to be coming from BuildPhysicsWorld, complaining that the Projectiles job is reading from collision world

#

This is the projectiles job:

#

Which runs inside fixed step, before build physics world

#

I have another system which also runs before build physics world ( right after this one ) which also passes in 'world' as read only, but it doesn't throw any complaints about that one

viral sonnet
#

have you registered in onStart?

devout prairie
viral sonnet
#

sometimes a dependency problem doesn't occur because it's finished before. at one point i had several when i only tested with 1 entity and no errors with 100k

#

hm, looks fine to me on first glance

devout prairie
#

Only difference with the other system which runs after this is, it's a job schedule rather than an Entities.ForEach that i'm passing world into

#

But yeah no complaints on that other job

viral sonnet
#

oh you sure its coming from world?

devout prairie
#

Seems to be stemming from build physics

viral sonnet
#

hm yeah

devout prairie
#

this is projectile system here:

#

TriggerFX as i say also uses readonly world to do i think an overlap sphere and has no issues

#

i had a similar issue before which arose when i changed ordering of certain jobs that lean on build physics, where i had an error pop up that actually wasn't an error, it was actually masking a different error from another job that was running

#

so it was basically impossible to debug with a lot of f***ery

devout prairie
#

I think it might be related to using ECB during physics step

rotund token
#

Does this only happen during double ticks?

devout prairie
#

and/or setting translations etc ( although the entities themselves are not physics )

devout prairie
#

Simply swapping the order or Projectiles system and TriggerFX exposes this error:

#

I wanted the projectile system inside step physics because although they are not physics ( i'm translating them manually ) i wanted smooth motion and accurate raycasts for hits

#

moving the system out to simulation system fixes the error, but i'm pretty sure last time i had this outside of fixed step it was missing collisions

#

although technically, i think if my fixed step is reigned in and running 1:1 with the frame that shouldn't really happen right

misty wedge
#

Why can I do .WithDisposeOnCompletion on a NativeReference but I can't put it in a job with [DeallocateOnJobCompletion]... thonk

rotund token
#

only native array supports DeallocateOnJobCompletion

#

(honestly they should remove this attribute)

misty wedge
#

What's the correct way to dispose from a job then?

rotund token
#

container.Dispose(Handle)

misty wedge
#

Does that not incur any scheduling cost?

rotund token
#

the same cost .WithDisposeOnCompletion does

misty wedge
#

Ah, I thought they did something trickier, I never checked

#

Thanks!

rotund token
#

if you don't want allocation/dispose costs

#

just don't allocate/dispose it every frame

#

just store in the system as persistent

misty wedge
#

That's what I usually do (now), but this is pretty old code where I wasn't doing that yet

#

I'm trying to add some functionality, I'll refactor it eventually (i.e. never)

#

This is also kind of weird code tbh, I should probably change it, but I'm not sure if that would make it slower. I still have no idea how long scheduling takes.

Basically what the job does is calculate a bunch of stuff so that I can then set tiles on a tilemap at the end. It gets a bunch of world chunks as an input, but instead of scheduling it as an IJobParallelFor I schedule a bunch of IJobs

#

The reason I did it this way originally is that I don't need a lot of the chunks immediately, since the enqueued chunks take up more than the camera's viewport, and chunks currently calculating are only forced to completion if the chunk enters the camera's viewport

#

And you can't complete only some of an IJobParallelFor

rustic rain
#

Rather than temp allocator

rotund token
#

why?

#

also it's not temp allocator if you're allocating it outside of the job - it's going to be TempJob

rustic rain
#

Huh

misty wedge
#

Anything to watch out for when using Nullable<T> in jobs?

rustic rain
rotund token
misty wedge
#

Yes

rustic rain
#

Huh

rotund token
#

main thread difference

rustic rain
#

What's the difference between tempjob and persistent then?

rotund token
#

0.43ms for allocating the 1mill element tempjob every frame

#

vs 0.006ms on the system re-using persistent

misty wedge
#

I thought it was where the memory was taken from

rotund token
rustic rain
#

I see

misty wedge
rotund token
#

allocation speed

#

if i just change persistent to allocate / dispose every frame

viral sonnet
#

so, tertle. your 128 entities test is pretty concerning

#

you should bring that up in the forum

#

how did you do the test to get 128 entities cap? pad the data?

#

or manual job queuing with 128 length?

#

i still have hopes this is opt-in and not a general rule now

rotund token
rotund token
viral sonnet
#

oh you have dat connections ๐Ÿ˜„

#

i see, is padding a fair test?

rotund token
#

i don't really want to put fuel on fire and create speculation on a forum post, I was hesitant to even bring it up before 1.0 released without testing

rotund token
#

this component never queried

#

it wasn't an existing component, just a new one

viral sonnet
#

ah ok, then it's fair

rotund token
#

imo it represents the empty space in the chunk that will exist in 1.0

viral sonnet
#

yep

#

let me know if you get any kind of response ๐Ÿ™‚

rotund token
#

i couldn't say, but i don't expect anything to change

#

at least not near future

#

not expecting them scrap 2 years of work ^_^'

#

just because i'm not excited on enable components i think a lot of people/studio will use them a lot

viral sonnet
#

well, if they hardcoded this i don't know what to say ...

#

archetypes and chunks should support both forms. uncapped and capped with enabled/disabled comps

rotund token
#

i'll probably just do my best to find use for these 50 bytes

#

maybe add support for my effects to do multiple things using a buffer instead of 1:1

#

etc

viral sonnet
#

will it perform better then? ๐Ÿ™‚

rotund token
#

than it currently does? doubtful

#

than it will, probably

#

i could significantly reduce entity count if instead of a piece of gear creating 6 entities for 6 stats

#

just creating 1 entity that can set 6 stats

#

so i should be able to make up a be bit of the loss

viral sonnet
#

good example why development shouldn't be internal for so long. but then again, we voiced our concerns when it was first talked about so. i dunno. bad move (in case there really is no uncapped chunks anymore)

#

maybe the results are better with the new job system. after all, this is where the most overhead comes from

rotund token
#

i understand the reasoning cort posted on forums

#

it's more just sadness for potential

#

in reality i don't think it will change much

viral sonnet
#

yeah and i see the point, it just can't be generalised so much to ignore every possibility

#

like sure, the big gameplay entities have a massive size but what about the others

#

specialized ones more importantly

#

so now we have hardcoded chunk size and hardcoded entities cap. ugh

#

this is clearly not built for the future lmao

rotund token
#

while I would really like small chunks especially with unmanaged shared components coming in 1.0, i wouldn't that far to say it's not designed for the future

viral sonnet
#

you see chunk size of 16k and 128 entities cap in 5-8 years? it's not even appropriate for todays hardware.

rotund token
#

sure why not

#

they're nice numbers

viral sonnet
#

640k memory was also a really nice number ๐Ÿ™‚

rotund token
#

128 is simd register

#

i can see it slowing down if you increase this value

#

and 16kb fits nicely in cache

#

now would it be nice to have dynamic sizes per cpu

#

sure

#

is it needed right now? i hardly think so

#

would also breaks determinism which is something unity seems keen on maintaining

viral sonnet
#

anyway, as i said, they should have made effort to make these numbers tweakable very easily. especially chunk size was one of the first major questions i saw. and as our tests show, more fitting chunk sizes can mean drastic improvements. that goes for any archetype and entities should be able to make every archetype configurable how much data it allocates.

#

the 128 simd register is only relevant with the enabled/disabled feature, right? the 16k was stated that it's not about caches. sure it fits in nicely, cache sizes will be bigger at one point though

#

and to have optimised a feature so aggressively over a complete framework only to be optional is ... not good to put it mildly

#

eh i'll shut up now. maybe it's really optional and not even a problem. i'll wait and see what's what

rotund token
#

i should say that in 1.0, systems are [alwaysupdatesystem] by default, and you have to sign up if you want to require matching queries for update. this is because everybody was always going insane because their systems weren't running and they forgot to say alwaysupdatesystem.
been thinking about this for a couple of days

#

this is such a scary change (for old code)

#

i think this kills any hope of updating our existing project to 1.0

#

though the chance was already little to none

viral sonnet
#

doesn't it just require to flip? [alwaysupdate] -> remove - no attribute add [requirequery] or whatever it will be called

#

but yeah, it is quite the change. probably made because of beginners. i certainly will have to get used to it.

rotund token
#

if you have 2 queries

#

previously either one having entities would make system run

#

you can't just make requirefor for both queries otherwise it would only run now if queries had entities

#

not either

#

you have to do early outs on each query individually on what they use

viral sonnet
#

are you sure that will be the case with the new attribute? i think with the new attribute it will work just like the current behaviour

#

and you have to sign up if you want to require matching queries for update
basically this