#archived-dots

1 messages · Page 205 of 1

gusty comet
north bay
#

He's mixing the object/component model up with an ECS

stone osprey
#

isnt unitys default architecture called EC ? Entity/Component ? But yeah, ecs is different from that.

north bay
#

No idea to be honest

worthy rampart
#

tis why this channel is called DOTS

rancid geode
# gusty comet

You are mixing up things

Entity-Component architecture is different than Entity-Component-System architecture

Unity has always been Entity-Component (GameObject-MonoBehaviour), but it has nothing to do with their ECS implemention which is still in preview and absolutely not being used "by default"

stone osprey
#

BTW... is there any EC/Entity Component architecture/lib/framework for code only ?

pliant pike
#

Do you guys think it would be better to make a branching System that has two jobs where only one job is executed or for them to just have their own separate Systems?

ionic sierra
worthy rampart
#

yea I know

#

I was saying there's a reason this channel isn't called ECS

#

there's a bunch of things that make up DOTS

ionic sierra
#

Oh my bad.

worthy rampart
#

aside from just the entity component concept

ionic sierra
#

not reading high enough

worthy rampart
#

all good 🙂

#

too many discord channels

#

not enough time

ionic sierra
#

yep

#

Actually had a question. Is ECD conceptually easier to understand than OOP?

#

ECS

pliant pike
#

@ionic sierra it is for me

worthy rampart
#

depends

#

conceptually

#

I'd say yea

pliant pike
#

it kind of has it's ups and downs to be honest, figuring out the right syntax and how exactly to do things can be difficult, especially when ECS is new and theirs a lack of resources to help

#

but when you do understand how to use it a bit, it does simplify problems(its all just manipulating the raw data) make them somewhat easier to solve and the forced structure helps a lot

amber flicker
#

I think something that's often not mentioned much is that DOD/ECS makes it within your control (and often actually difficult/obvious) to care about linear memory access. You combine that with threading/Jobs and you have two huge class of problems you're constantly thinking about that (usually) with an OOP mindset you don't much. Restricted to main thread and not caring about memory layout I'd say there are many things that are conceptually very simple. Mostly getting rid of initialization/nullref issues etc is huge imo.

pliant pike
#

yeah I was thinking the simple fact that things existing is implicit in DOTS and update order is also is so much better than Monobehaviour, what you have to do in Monobehaviour to ensure those things is way more difficult

amber flicker
#

I'd say update order is a little debatable myself.. I find that to be a somewhat more implicit aspect to ECS that requires a lot more mental overhead than is obvious at first.

pliant pike
#

agreed, but I still thinks its better than monobehaviour though, I think I remember you having to find an obscure option in the editor to order monobehaviours and then it still might not work

worthy rampart
#

the largest thing for me that is holding DOTS back right now is easy to find and follow simple tutorials and copy/paste code examples for various common situations

#

not looking for hand holding, but it's super easy to find monobehaviour based "recipes" for when you want to do something you know many others have done

#

they'll come in time obviously

#

just the sideffect of being pre-release software

pliant pike
#

yeah definitely, its because it is so new and everyone is just figuring out things as they go

worthy rampart
#

also I really hope that with a full release we'd be able to really edit the core systems/replace them

stone osprey
#

Hmmm... Should we decouple networking and databade acess from the ecs itself ?

Having a MovementSystem that has a few codelines in it that define how we send the positions to the client vs.

Having a MovementSystem firing/queueing events and a seperate networklayer that receives those and takes care of sending stuff

What would you choose ? The last is probably more flexible and seperates game logic from networking

north bay
#

So many times I had to debug that freaking system order

safe lintel
#

well you can set the order of everything explicitly

#

they do that for megacity and fpssample if my memory serves me

amber flicker
#

Yea I can see why people would prefer it. It's a bit tricky, esp when thinking about e.g. plugins/asset store stuff, reusing code etc. I quite like having high level component system groups and only going lower when required.

half jay
#

i have NativeHashMap after remove one element and then add another new element will be add to place where was removed element?

zenith wyvern
#

The order isn't defined

stone osprey
#

Hmmm... im currently moving away from item as entities to item as datastructure. Just wondering how i apply actions on those items then :p

#

Damn actually each move i do feels wrong. As i implemented entities that act as items inside the players inventory... it felt so wrong.

#

And now, when i undo this change ( Due to the huge amount of relations ), it also feels wrong

undone delta
#

how can i use the new input system with ECS?

ocean tundra
#

@karmic basin of course, but I feel with tools there's less pressure on making them compatible, but I guess if I'm sharing my tools that will change

#

@karmic basin I like the idea of a web interface, I've actually built that before for a different game, but making the UI dynamic and "good" is a real pain

#

@karmic basin the base/modifiers are a good idea, but also something the dev could have

frigid badge
#

not sure of it fits the channel, here it is anyway:
how do I tell a ParallelFor Job that the length and step are defined only for input NativeArrays ? My output array has different length and when I write to it it raises an exception telling that the job is writing to index outside its permitted range

#

individual job instances won't use the same write index, so it should be safe in that regard

zenith wyvern
#

Add [NativeDisableParallelSafetyRestriction] to your output array in your job struct

hollow sorrel
#

so you'd have network layer to just send/receive packets on a separate thread and have ecs be able to consume packets without worrying about thread contention, + more cache friendly

safe lintel
#

I actually dont know if the most recent stuff is bugged though, previous releases worked but I had to remove all the #if/#endif code to make it work again. will require some minor fixes if you also need to do that but regardless it should show in general terms how to get the two to work together

safe lintel
#

anyone else out there using dataflowgraph and not able to forward output ports to other output ports? im assuming im alone in the void here

karmic basin
#

yeah it's faaaaar on the todo list on my side sorry

odd ridge
#

do we have enable/disable component? last time I checked, it was due for 2020 😄 but I haven't looked for a while

safe lintel
#

not yet

#

it will arrive with that blog post 🥲

vivid lotus
#

Hey everyone! Just learning DOTS and going through the HelloCube examples from the example GitHub repo. #5, the SpawnFromEntity one, has you spawning a prefab that itself has a ConvertToEntity component on it.
https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/ECSSamples/Assets/HelloCube/5. SpawnFromEntity
I was wondering if that ConvertToEntity on the prefab has a runtime performance cost for each entity spawned? Or does the fact that we do DeclareReferencedPrefabs ahead of time (or something like that) precompute that conversion?

#

Mostly just trying to wrap my head around converting GOs to entities and what costs, if any, are involved at spawn/runtime.

zenith wyvern
vivid lotus
#

I'm having trouble figuring out the best way to go about just setting up a system that spawns entities from a prefab on demand (like projectiles, etc.) -- Is that still the best way to go about it, or is there something better?

#

SubScenes look like they're more for like, putting a bunch of things in the right place and laying them out, in a fixed number etc.

zenith wyvern
#

Oh sorry I didn't realize this was on a prefab. There is no extra cost if you're instantiating from an entity prefab

vivid lotus
#

Ah okay. So if the prefab is never in the world, but has ConvertToEntity on it as a prefab, that happens before the spawn occurs?

#
zenith wyvern
#

Basically as you suspected above when you do IDeclareReferencedPrefabs it will create a canonical version of your entity that's already gone through the conversion process

#

When you instantiate from that entity there's no conversion happening at that point

vivid lotus
#

🙌

#

Awesome okay, thanks.

plush meadow
#

I'm not sure if this issue is limited to DOTS, but i tried searching and came to nowhere
Basically i built the project for android and am experiencing major fps drop (<20fps). Strange thing is i used an fps counter asset and it's still showing 60fps...
In the editor same asset shows a consistent 200+fps

#

PC build doesn't have that problem either

hollow sorrel
#

build in dev mode and autoconnect profiler

plush meadow
#

will do

olive kite
#

Is there a quaternion helper class that anyone has made that contains some of the functions from Quaternion like Angle and FromToRotation?

plush meadow
#

hmm

#

"gpu profiling is currently not supported when using vulkan"

hollow sorrel
#

ah weird

#

well if it was gpu it'd still show up in cpu profiler as waiting for gpu

#

seems like your actual framerate is fine, how are you experiencing the drops?

#

maybe your camera/physics movement are updating at a lower rate?

plush meadow
#

i switched to opengles to see what's going on

#

and obviously there's something going on

plush meadow
hollow sorrel
#

oh damn seems i was wrong about gpu showing up in cpu

#

what does it say when you click the gpu usage view

plush meadow
#

when i was using vulkan?

hollow sorrel
#

no in your screenshot

#

with opengles

#

oh wait i can't read you already pressed it

plush meadow
#

yes

#

clear is hogging up everything

hollow sorrel
#

huh weird

plush meadow
olive kite
#

Thanks, yeah I use AxisAngle and other methods from that Unity.Mathematics, just curious if there was one with the methods found in Quaternion like Angle and FromToRotation to make conversion a bit easier when converting code to dots

stone osprey
#

@hollow sorrel Glad to hear that ^^ Then im gonna implement a seperate network layer. This should be much cleaner

#

Meanwhile im still struggling with item as entities vs item as oop.

#

My items should also listen for certain events. Like when the player attacks to apply unique logic. Or they should do something while they are in the inventory. Like showing the player where mobs are. This all speaks for item as entities, because we actually need to loop over them. Could also be implemented using OOP. But i mean... when its also possible in the ecs, with quite the same effort. Why should we use OOP then ?

#

Damn those decisions break my neck. On the otherside its very important, because such stuff cant be changed easily. Especially not if we persist items.

karmic basin
#

Can't you achieve a from to rotation just by multiplying the quaternions ? (My quaternion-fu is weak, sorry if that's dumb)

#

and quaternion.Angle gives degrees IIRC, yeah I guess you have to write your own helper to convert

#

Also looks like there is implicit operators from that doc

hollow sorrel
#

@stone osprey nothing wrong with having stuff outside the ecs, you can still call that data from systems even when it lives elsewhere
i prob wouldn't have items listen to events, but instead have a system ask for items (even if they live outside ecs, can ask an OOP class to look up items that do player attack logic or whatever)
alternatively you could parse the items and create entity copies that hold the data you wanna loop over

olive kite
#

@karmic basin yeah, I actually have them but was hoping for something by unity so that they would match exactly to how they do with the Quaternion methods, since quaternion calculations can differ sometimes

karmic basin
#

Yeah I see, like XYZ vs ZXY

#

Did you dig the official samples ? sometimes they write some helpers for themselves

#

low chance though :p

#

maybe you'll find a blog post or a gist from random people :p

#

🤞

stone osprey
#

@hollow sorrel That makes sense ^^ with listening for events i mean the following example : Player attacks -> Item in hand gets marked as OnHit -> SomeSystem can execute special logic for that item. For example spawn a lightning or create a shockwave ^^ that was the plan. Of course this is also possible in OOP, but its not that flexible...

Entity{ Item, OnHit, OnHitSpawn } for example.

plush meadow
#

i'm so confused

plush meadow
#

does this mean that .shader files aren't supported?

stone osprey
#

So i think i found a good rating schema for entities vs oop. When it should be kinda flexible and "future" proof it should be implemented as an entity. And if its mainly data or not that flexible at all, then it should be implemented via OOP. In my case inventory-items are flexible, Some are equipable, other not, some can act as weapons, others not. And some of them should do something every tick, while others only should do something when the player attacks or gets hit. Thats actually a great use case for an entity, because we can decorate the item. However, if we have items that have a predefined set of actions or a defined structure... then it would make sense to implement those with OOP. Another great example are messages. I would never, ever implement messages as entities. Because they just arent flexible. Does anyone here agree with that entity vs oop statement ?

pliant pike
#

you can use Blob assets for fixed data too though

#

and strings don't really work well in ECS anyway

stone osprey
#

@pliant pike Thats right ^^ I just meant as a general guideline on when to implement a feature using entities or some OOP class.

#

Because i lately stumbled upon many people recommending to implement items for example via OOP. Many others love using entities instead

pliant pike
#

I don't know I don't see much point in rules like that, just do whatever you can in whatever that works for you

#

like I'm doing items with scriptable objects converted to entities, its just what works for that project

stone osprey
#

Because of the golden hammer antipattern. Which basically says that you shouldnt enforce a certain architecture ^^ And thats exactly what i did in my case. I actually only used entities. I even used entities to calculate loot drops, i had a Loot Drop Entity with one component :p Thats just to atomic. But of course, you can go hybrid, pure ecs and both work

pliant pike
#

I would have thought entities would be perfect for that leahWTF

stone osprey
#

I also implemented items as entities because i love marking stuff : Entity{ Item, OnPlayerAttack, OnAttackSpawnCow } just so much flexibility. But then people recommended to do that in oop ^^

#

Uhm... yes... totally great 😄 Entity{ CalculateLootDrop(LootTable), OnLootCalculatedSpawnItems }

#

We shouldnt forget random number generators like Entity{ GenerateRandomNumber, OnRandomNumberGeneratedPrint }

#

I always generate my numbers like that

fluid kiln
#

Hey guys, I've been rethinking my floating health bars and I don't like the fact that's it's a 3D element (quad) because it's not rendered on the UI and can be covered by 3D objets. Is there another way in DOTS to have a UI element "following" a 3D object? 🤔

pliant pike
#

I dont think there is in DOTS, you can just get the entity data in a monobehaviour easy enough to use normal GUI stuff

fluid kiln
#

Oh, or (that might not be DOTS related) is there a way to render some objects on top of the world? Maybe another camera?

pliant pike
#

that's like z buffer stuff, I don't know if you have access to that sort of thing with hybrid renderer

fluid kiln
#

I'm thinking to do a second camera that renders only the 3D UI on top of the main camera

pliant pike
#

that's basically how UI stuff mostly works anyway

fluid kiln
#

Exactly :p but no chocie to have another camera because it's 3d elements

amber flicker
#

which rp are you using?

fluid kiln
#

Hybrid

amber flicker
#

I mean builtin, urp or hdrp

fluid kiln
#

oh sorry, urp

amber flicker
#

cool - urp has something called render features - in the pipeline asset you can define that e.g. objects on a certain layer draw at the end and even write over the depth buffer

#

not 100% on how this works in conjunction with hybrid renderer

#

but may be worth looking into

fluid kiln
#

Interesting. I'll look into it, thanks!

#

Could it be as simple as this? We'll see

amber flicker
#

you maybe want to remove it from your opaque filtering in the top dropdown too

fluid kiln
#

Good catch

#

Awesome 😄

fluid kiln
#

How can I go about doing something like this without the error? :/

        Entities.WithAll<Restore, Stat>().ForEach((Entity ent, ref Current current, in Maximum maximum) =>
        {
            //Can't GetComponent a component already in the lambda
            current.Value = GetComponent<Current>(maximum.entity).Value;

            ecb.RemoveComponent<Restore>(ent);
        }).Schedule();
pliant pike
#

yeah, you can't do that

fluid kiln
#

It sucks tho cause I have a lot of nested entities

pliant pike
#

you have to either get Current with a separate EntityQuery

#

or some other way

fluid kiln
#

Yeah I guess I'll do an EntityQuery

#

Still hoping for a multi-depth foreach at some point so i can query component in unique children, not sure how that would be implemented but I have to create so many container components just to reference the child entity then GetComponent

pliant pike
#

yeah I think that's the only way if you want to compare different entities within the same component 🤔

fluid kiln
#

Something like this would be a godsend

        Entities.ForEach((Entity ent) =>
        {
            ent.ForEach(...)
        }).Schedule();
pliant pike
#

I dont think that will ever happen to be honest

fluid kiln
#

Am I approaching the problem wrong then? I feel like there should be an easy way to query a child 🤔 I feel like everyone at some point will need entities within entities and compare the values between different levels

pliant pike
#

there's a whole thing about flattening lists, I havent delved to much into that personally though

#

DOTS is all about single arrays and churning, through them, you convert whatever data you have into a single arrays and let it do its work

fluid kiln
#

What about a sublambda then like (pseudocode)

        Entities.ForEach((Entity ent, Current current, Maximum.entity.Current maxCurrent) =>
        {
        }).Schedule();
#

idk it's just like the 5th time I stumble on this issue and I'm sure it won't be the last

#

I feel like my data structure is rock solid, but it makes querying harder...

amber flicker
fluid kiln
#

Can't write with GetComponent :/

#

I need to write into one's Current with another's Current

#

I could SetComponent(ent, new Current(GetComponenet))

#

But I feel like that's ugly?

amber flicker
#

Yup that basically but you just need to call WithDisableNativeParallelRestriction (or whatever it’s called) as Unity can’t guess it’s safe as you could write to any entity

#

It makes more sense if you’ve used IJobChunks

fluid kiln
#

So something like this?

        Entities.WithNativeDisableParallelForRestriction(typeof(Current)).WithAll<Restore, Current, Stat>().ForEach((Entity ent, in Maximum maximum) =>
        {
            ecb.SetComponent(ent, new Current() { Value = GetComponent<Current>(maximum.entity).Value });

            ecb.RemoveComponent<Restore>(ent);
        }).Schedule();
amber flicker
#

Basically yea I think so

gritty bane
#

are there any ECS examples I should look at for Unity? Ive been using Bevy (the open source engine) to get familiar with the paradigm and was hoping to move over to unity

glacial bolt
#

Resources and forum threads are pinned in this channel top right.

gritty bane
#

also I tried the example project on Github and it wouldnt compile due to a missing function within the Collections class... is this due to my engine version or was it something different

#

Also thank you for the quick response

fluid kiln
#

Make sure you have a recent version of Unity installed

gritty bane
#

LTS 2020 or

#

I was using 2019 with it

fluid kiln
#

I'm not sure that's the problem but I'd recommend using 2020

gritty bane
#

aight cool cool yeah it kept saying that theres an issue with the Collections script and wouldnt run the example, but ill try it out with LTS 2020 and see if that fixed it

#

everytime i code in another language besides Rust, i start missing Cargo... it does such a great job managing dependencies

sturdy rune
#

I have unity physics in my project, but getting error when trying to reference typeof(EndFramePhysicsSystem)

#

and all of a sudden VSCode can't find physics, entities, etc

#

packages are all in project though...

#
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using Unity.Jobs;
using Unity.Physics;
using Unity.Transforms;

[UpdateAfter(typeof(EndFramePhysicsSystem))]
public class BulletCollisionEventSystem : JobComponentSystem
{
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        return inputDeps;
    }
}
#

what was working 15 minutes ago, now that I added this new collisionsytem file is red all the way through. If I remove it, my old project works but no access to collissions and VSCode still broken

#

fixed the editor at least - added using Unity.Physics.Systems

#

but VSCode still trashed. So odd

zenith wyvern
ocean tundra
#

Hi all, I'm looking for any existing DOTS samples that would make good network tests/samples/documentation for my networking package
Its mainly for RTS/Strategy/Management type games but I'm not yet up for building a whole game to test the Networking
If anyone has any suggestions please let me know
I'm planning on starting with the official ecs samples ( https://github.com/Unity-Technologies/EntityComponentSystemSamples ) but im hoping theres something more complex out there that would make a good test

plush meadow
#

turns out i was basing my whole gameloop on audio.dspTime and that thing for whatever reason doesn't update like i expect to on android

gritty bane
#

whats the git to import unity Physics preview

gritty bane
#

Im currently on the latest hybrid compiler and its saying that GetEntityQuery is deprecated... whats the new method for this

karmic basin
#

@ocean tundra there is the asteroids sample, could be a nice and simple 2 players testbed

karmic basin
karmic basin
#

anyway Physics package is kept up-to-date with Entities, should resolve dependency to latest version

gritty bane
#

Hmm that might be the issue... cause I may have switched it to the new Havoc Physics system and not the new Unity Physics system

#

Though they have the same methods, no?

karmic basin
#

API should be 99%-ish the same yes

#

at least that's Unity's promise

#

I didn't mess with Havoks because its licensed stuff

gritty bane
#

Hmm... yeah Rider is highlighting GetEntityQuery as wrong so it might be the fact that I switched everything to the latest version of preview

karmic basin
#

for havok it's com.havok.physics

#

You're using a SystemBase ?

gritty bane
#

( I really wish that there’s a feature to see where the deprecated methods and functions are from even if you can use them, like in rust)

#

That’s a preview package right

#

Lemme check

karmic basin
#

The changelog can somehow help with that

#

But be ready to dig yourself in the code to check where things are

#

DOTS is not ready for everyone

#

It's for the ones who like to learn from themselves

#

So yeah it lacks a lot on these topics

gritty bane
#

System Base isn’t in the registry when I search... do you happen to know the git for it

karmic basin
#

SystemBase is the new class to inherit from to write your systems

gritty bane
#

I’ve worked with the Bevy and Amethyst ECS engines in the past so I’m familiar with ECS as a concept

karmic basin
#

deprecated one is JobComponentSystem or whatever it was called

gritty bane
#

Yeah it’s inherited from systembase

karmic basin
karmic basin
#

what's the error ? a namespace one ?

gritty bane
#

the functions in red are the ones that are wrong apparently

karmic basin
#

yeah need to solve class declaration one first, others will resolve tehn

#

What error Rider gives you for the class declaration ? missing namespace ?

gritty bane
#

that it doesnt contain a parameterless constructor

#

which I dont think is a major issue

#

it might be a package that im missing but idk

karmic basin
#

That's not a package issue

gritty bane
#

oh is it an import issue?

#

has to be right

karmic basin
#

you don't have Entities package ? 👀

gritty bane
#

wth do I not

karmic basin
#

you can double-check with the package.json file to make sure

#

but yeah you def need ENtities package to go further 🙂

#

We don't see the top in your screenshot but probably be interested in the Collections package too.

#

Anyway,one issue at a time I guess:p

gritty bane
#

yeah its listed as a dependency

#
  "dependencies": {
    "com.havok.physics": {
      "version": "0.6.0-preview.3",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.burst": "1.4.1",
        "com.unity.collections": "0.15.0-preview.21",
        "com.unity.entities": "0.17.0-preview.41",
        "com.unity.jobs": "0.8.0-preview.23",
        "com.unity.mathematics": "1.2.1",
        "com.unity.physics": "0.6.0-preview.3",
        "com.unity.test-framework": "1.1.11"
      },
      "url": "https://packages.unity.com"
    },
    "com.unity.burst": {
      "version": "1.4.6",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.mathematics": "1.2.1"
      },
      "url": "https://packages.unity.com"
    },```
karmic basin
gritty bane
#

if its a dependency for one package, it becomes a dependency right

karmic basin
#

well this Rider dependency manager looks like a JS one 🙂

#

my package.json is flat and explicit

#

manifest.json file

#

jeez I'm tired

#

sorry about that

gritty bane
#

oh i was looking at the packages-lock.json for my project

karmic basin
#

yeah my bad 100%

gritty bane
#

shoot yeah its not listed

karmic basin
#

yeah but the package lock has it with last version, should be good 🤔

#

I don't know, yeah try with explicit declaration in the manifest

gritty bane
#

Oh shoot I’ll have to look up how to type into the manifest file

#

I thought I’ll just be fine using git and the package manager

#

Lol

#

What does it look like in your manifest file

karmic basin
#

Wait can you really constrain an inherited class in c# ? 🤔

gritty bane
#

Ur talking about the “where T” right

#

I am also very tired

karmic basin
#

yeah, I've never saw this use case, so don't know if that actually make sense for the compiler

#

Try to remove the constraints on the class and see if Rider still complains

gritty bane
#

I think it’s limiting the Type parameter

#

I use it in Rust all the time so I thought it was something normally part of C#

karmic basin
#

I'm not sure you can do that on a class that does not constrain type in the first place, but maybe I'm wrong 🤷‍♂️ just never tried myself

#

IMO that would explain the parameterless error, but again, can't tell much

#

Well... my IDE doesn't complain when I try so looks like it's okay

gritty bane
#

so GetEntityQuery shows up for you

#

hmm

#

what package does it say its a part of

#

or like the reference

karmic basin
#

It's in SystemBase

#

which inherits it from ComponentSystemBase

gritty bane
#

hmmm really weird

#

yeah i have the same thing

#

I just wanted to double check

#

you're also on 0.17 right

karmic basin
#

yup

gritty bane
#

im going to repull the ECS examples again and see if i can find a fix for my project

karmic basin
#

Sorry I couldn't help

gritty bane
#

Its fine lol just normal Unity jank i bet

pliant pike
#

I don't know if anyone knows but I presume int entityInQueryIndex I can use that to correlate the index with an external entityquery?

pliant pike
#

to answer my question myself, it does seem to work the external nativearray componentdata on the same entity does correlate or the lists are just kept in the same order either way it works and hopefully nothing changes to break it

zenith wyvern
#

Yes if the query in the foreach matches the EntityQuery they are guaranteed to align afaik

pliant pike
#

I mean they don't exactly match they are different componentdatas just on the same entity

low tangle
#

I'd highly suggest finding a more stable indexer if you can, or pulling the entity array async into a native array

#

I dont trust unity's auto gen stuff too much as the apis change

pliant pike
#

yeah that's what I was wondering

#

but surely the separate components on the same entities must stay in the same orders 🤔

#

I do like to see all the green anyway

low tangle
#

7ms seems a bit high for burst

#

doing some thicc calc in there?

pliant pike
#

its 1million entity's

low tangle
#

ah, big n

#

carry on smile

pliant pike
#

just a really difficult test, managed to make a 30ms single thread into a multithread 6.5ms job

low tangle
#

good job!

pliant pike
#

it's fun, I do enjoy messing with DOTs

dark cypress
#

Where can I read a breakdown on how entities are stored in memory?

crude mountain
#

I was trying to hook up Input.touches to a system in ecs but it isn't supported by the burst compiler. Is there an example of a mobile control system in ecs?

#

also trying to buffer a entity deletion in a foreach, but .ToCurrent() isn't working

dark cypress
#

It's AsParallelWriter now

crude mountain
#

thx

ocean tundra
#

Thanks for the suggestion tho, maybe ill try making it a mini RTS at some point

crude mountain
#

I was looking at the wrong version of the ecs manual this entire time lol

#

im dumb

pliant pike
#

is there some way of doing this CellBDLayerToCalc LayertoCalc = HasSingleton<CellBDLayerToCalc>() ? GetSingleton<CellBDLayerToCalc>() : null;

ocean tundra
#

@pliant pike replace null with default??

#

or change CellBDLayerToCalc to CellBDLayerToCalc?

#

making it nullable

pliant pike
#

default works, nice thanks

ocean tundra
#

anytime you go to use it you will need to check HasSingleton again

#

as default assigns it a 'default' value, so you may go to use it and have values you dont expect

pliant pike
#

default might work anyway, if it sets the values to zero then that's what I want

small arch
#

In a singleplayer game... would it make sense to use DOTS to create the player?

#

Or should i say... would it make sense to use DOTS to create a single entity or should i just use a gameobject?

pliant pike
#

depends on how much work your willing to do

#

DOTS is very much a preview and work in progress

ocean tundra
#

@small arch yea it depends tons on the game type and how much work you want todo 😛
DOTS is best for games with LOTS of the same stuff, eg RTS (basically everything is a unit or buildings)
but you can get some awesome wins for things like huge open world rps too

#

if your whole DOTS use is just a single entity,,, then that makes no sense, all the wins with DOTs come from having as much as possible in DOTs world

small arch
#

buildings?

#

so placing buildings with code instead of putting them down in your map with the editor?

#

and that would increase performance?

ocean tundra
#

oh I was meaning that in RTS you can break pretty much everything down to 2 things, units (movable) buildings(not moveable, also trees and stuff)

#

thats really great for DOTS

#

can process all moveable things at onces

#

then all unmoveable things

#

but if everything was very uniuque then you lose out on that

#

(also this is a high level example 😛 , even units and buildings would have common things, eg health that you can process all at once

crude mountain
#
entityManager.SetComponentData(myEntity, new FallingData
{
    fallSpeed = entityManager.GetComponentData(myEntity),
    lifetime = 10,
    falling = true
});

how do I get use component data introduced by a prefab while only setting falling to true.

ocean tundra
#

can you rephrase the question, not sure i understand

crude mountain
#

when I setcomponentdata to new fallingdata, it sets the old fallspeed and lifetime to 0 if I don't do anything to them. I want them to keep their previous values while only changing the value of falling inside the falling data of the entity

#

it seems to overwrite the old fallingdata in the entity

pliant pike
#

it's because your creating a new FallingData

crude mountain
#

yah how do I just update the old one?

pliant pike
#

you could just get the old data, change the values you want then set them in the componentdata

crude mountain
#

how tho....

pliant pike
#

EntityManager.GetComponentData

ocean tundra
#

@crude mountain I think you should be using entities for each, is this already in one for something else?

pliant pike
#

yeah you can use just SetComponent or GetComponent

crude mountain
#

this is in a entity spawner monobehavior

olive kite
#

Does anyone know how the DisableRendering component tag works frame by frame? I call it and it takes 3 frames for an entity to disable the renderer. Is there a more precise way to disable the renderer on an entity?

ocean tundra
#

@olive kite Are you using a command buffer, that may be 1 frame of delay

#

i imagine another frame where some internal system state is updated somewhere

olive kite
#

Yes I am. I'll try to complete the job and add the tag right then, see if it has any impact.

#

I think I did something stupid, hold on

ocean tundra
#

but also does a 3 frame delay matter?

#

3 frames at like 60 fps is tiny

olive kite
#

yeah because it's a laser projectile with emission

#

and you can totally tell it goes way through

#

but as I should always assume from the start, I did something stupid. It had a child object

ocean tundra
#

oh yea

#

that was my next guess

#

takes a bit to propergate down to children

#

really annoying

crude mountain
#

why doesn't this work

ocean tundra
#

umm get componentdata is a method

#

returning a fallingData struct

crude mountain
#

isn't that the same as new FallingData?

ocean tundra
#

yea but you cant use a initilizer

#

save the response to a var

olive kite
#

yeah just do the same thing right before

ocean tundra
#

and then do var.Falling = false

#

then set...

olive kite
#

thanks roycon for the help

crude mountain
ocean tundra
#

fvar .... beofre set component data

crude mountain
#

?

#
FallingData fvar = entityManager.GetComponentData<FallingData>(myEntity);
        entityManager.SetComponentData(myEntity, fvar
        {
            //fallSpeed = 1,
            //lifetime = 10,
            fvar.falling = true
        });
ocean tundra
#

fvar.falling before you call setcomponent data

#

remove the {} bits

crude mountain
olive kite
#

i usually just do setcomponentdata(myEntity, new FallingData { stuff = fvar values or new values }

ocean tundra
#

sorry @crude mountain i recommend you find a C# tutorial before touching DOTS
entityManager.SetComponentData(myEntity, fvar); that was right

crude mountain
#

@ocean tundra lol XD you might be right. I do know how to program, I am just not used to unity's c#.

#

@ocean tundra you mean like this right?

#

I am having trouble with terminology, but I do know how to program XD

#

I swear

ocean tundra
#

its a learning for everyone :p

#

but look into structs vs classes (objects vs value types)

#

ummm the ref and in keywords

#

maybe generics if youve never used them before

crude mountain
#

I have so many tabs in my browser. XD

ocean tundra
#

oh and lamdas for when you use entities.foreach

gritty bane
#

yeah idk whats missing in my project, but for some reason the method GetEntityQuery is not showing up

#

its a protected method within the CompnentSystemBase class but thats inherited by SystemBase, which should allow it to be a public method

#

or to be called like that

#

oh wait it fixed itself

#

idk what up

karmic basin
#

😅

gritty bane
#

it should be public right?

ocean tundra
#

No

#

It should just be GetEntityQuery

#

Cause your class inherits off syatembase

gritty bane
#

yayy now it works

#

I guess i showed the IDE where the method was by doing it that way

#

and then switching it to the actual method

olive kite
#

How can I set the TransformSystemGroup systems as a dependency to a custom system that follows it?

ocean tundra
#

so in system thats AFTER transform group

#

in OnCreate GetExistingSystem Transform....

#

oh

#

i see

#

Dependancy isnt public

olive kite
#

it is a ComponentSystemBase and not SystemBase

#

yeah

ocean tundra
#

it really should be...

olive kite
#

agreed lol

errant hollow
#

Is anyone here experienced with shaders and hdrp

olive kite
#

I think it's causing some issues with my ik stuff

ocean tundra
#

so the automatic dependancy stuff should work if your using components and entity querys

errant hollow
#

I messed up real bad

olive kite
#

Yeah I am using those

ocean tundra
#

but you said its a componentsystembase...

errant hollow
ocean tundra
#

im not sure if that has a same dependancy stuff

olive kite
#

I will double check, it was just a hunch and wanted to see if setting it as dependency would fix it

ocean tundra
#

in the systems window it shows system dependancies

olive kite
#

yeah it may use its own buffer

#

ok ill check that, thanks again

ocean tundra
#

hmmm but you must be using some of the same components?

#

either reading from them or writing too them

#

that combined with [UpdateAfter] should let the auto dependancy stuff work

olive kite
#

i am reading from localtoworld and read/write to position and rotation

#

yeah i have update after as well

ocean tundra
#

so next frame LocalToWorld will be updated to have that position/rotation

#

hybrid renderer stuff reads from localtoworld i belive

olive kite
#

right, that's why I wanted to do everything after transform update, so i can do my IK calculations and save the position/rotation, then next frame it updates the LTW before I pull again

#

yeah i think that's correct

ocean tundra
#

have you read all of this

olive kite
#

I wouldn't expect to have issues, but I have the exact same system in a system as a normal GameObject and seeing inconsistencies

#

yep

ocean tundra
#

i think you may actually want a write group to prevent localToWorld being updated by the auto systems

#

and instead you write to it

olive kite
#

i don't modify the LTW directly, just rot and pos

ocean tundra
#

yea but maybe you should

olive kite
#

yeah I've thought of that, was hoping I could get the engine to do those calcs for me 🙂

#

maybe , yeah

ocean tundra
#

rot and pos are easy for gameplay stuff, but gameplay writing and then ik writing to it could get all confused

olive kite
#

hmm yeah. Maybe I can try in lateupdate

#

i've done that in the past with IK and seemed to work well

#

but not in dots

ocean tundra
#

maybe it should be a presentation group thing

#

and dont write back to rot/pos

olive kite
#

ok yeah let me try that

#

works great now in late update for a few seconds then goes wacko

ocean tundra
#

are you still writing to traslate/rot?

#

my guess is you are, and the caculations are componding and building on each previous frame

olive kite
#

Yes, but I am reading from the LocalToWorld each frame, shouldn't that not happen?

#

if i run the same calculations based on the LTW

ocean tundra
#

no cause the localtoworld is written to each frame as well

olive kite
#

right,

#

oh sorry,

#

for this system, there is nothing else influencing the pos or rotation

ocean tundra
#

i think you need to break the write to locatToWorld using a write group

olive kite
#

no physics or anything, jsut a proof of concept

ocean tundra
#

and then custom write to LocalToWorld

#

yea but its a loop causing crazyness 😛

olive kite
#

You may be right considering how it's acting

#

I'll try that tomorrow

ocean tundra
#

Translation/Rotation ===> LocalToWorld === YOUR IK ===> Translation/Rotation

olive kite
#

I guess I don't comprehend how it could become out of sync in late update. when I update the rot and pos, doesn't it recalculate the LTW prior to running and setting those the next frame?

#

since they both run each frame

#

i mean, obviously i don't comprehend haha, i think your right about what is happening

ocean tundra
#

so your writing to pos/rot then next frame it starts with those values

#

you never reset back to startpos

olive kite
#

but the calculations are done by the current position to the target, not the original position

#

and start from the LTW rotation and position

ocean tundra
#

but your current pos is always changing

olive kite
#

right

#

I query the LTW for the system and basically run:

ocean tundra
#

😛 my brain....

olive kite
#

it is a bit more complex as a whole, considering iterations and saving those values, but at a high level, just running this each frame i don't get why it wouldn't

#

why it would rather, cause de-sync in the loops

#

i know, i feel the same with this problem haha.

ocean tundra
#

😛 i could be wrong

#

and i dont understand your maths for IK

olive kite
#

i think that the behavior would make sense if it was doing what you are saying

#

just trying to understand a little better how it could happen

#

forgot to include this line under it quaternion fromToRotation = FromToRotation(toLastBone, toTarget);

#

then i multiply the rotation by that

#

but i know it's not explained so wouldn't expect it to be too readable

ocean tundra
#

but my gut feel is changing pos/rot in your IK means next time it runs you will be caculating from a different pos

olive kite
#

precisely, intended to do such. I'll focus on that area tomorrow after some sleep, I appreciate your time, thinking it through helps

ocean tundra
#

all good

#

happy to try to help

gritty bane
#

will there be a speedup for Burst on an M1 with an apple Silicon version of Unity or is it just going to be x86 intel for the planned future

ocean tundra
#

I would expect there to eventually be burst apple silicon support

minor sapphire
#

@ocean tundra couple weeks back we were talking about custom bootstrap

#

If you ever have a problem with it...

#

the solution for me was to disable managed code stripping

ocean tundra
#

Oooo nice catch

#

yea that makes sense

minor sapphire
#

in the custom config:

ocean tundra
#

theres some magic reflection finding all bootstraps

minor sapphire
#

yeah

#

I think I will just leave that off haha

#

it causes more than one problem

#

I had it set to medium

#

I could try low but why risk future weird bugs

ocean tundra
#

umm look at link.xml

#

i think that lets you specify files to never be stripped

minor sapphire
#

oh interesting

#

maybe at the end of my project life span I can look into it haha

#

but during early dev I doubt it's worth the potential pain

ocean tundra
#

depends on the size difference i guess

frosty siren
#

Guys, how you do object pooling with hybrid entities?

ocean tundra
#

@frosty siren Honestly dont think the built in hybrid does pooling

#

i would do it myself

#

its a bit of work tho

#
  1. Create a IComponent mirroring the gameobject data you want
  2. Entities.Foreach it WIthNone<SystemState of your component>
  3. that foreach creates and attaches the components (this is also using the pool)

and cleanup is just the reverse

frosty siren
#

I'm asking how u do it meaning how you implement your pooling solutions with hybrid entities case

ocean tundra
#

so your already using hybrid?

frosty siren
#

yes

ocean tundra
#

subscenes?

frosty siren
#

not yet

ocean tundra
#

yea i cant think of a way to use hybrid to do it

#

wait

#

well

#

if your hybird components are not directly attached to your entities

#

instead you have a intermediate entity

#

that may work

#

super hard to explain

#

so think of a fire sword

#

sword entity has the rendering components and other data

#

and youve attached a hybrid particl emitter to it

frosty siren
#

yeap

ocean tundra
#

i dont think you can pool that

#

instead detach the particl emitter

#

so now its 2 entities

frosty siren
#

as i do it for now)

ocean tundra
#

now you can use the Disable tag on that entity and use a ISystemState component to track its 'attached' status

frosty siren
#

yes, i do exactly this

ocean tundra
#

😛 great minds

frosty siren
#

but

#

I really doubt about it approach

ocean tundra
#

why?

frosty siren
#

i use disable tag as you suggest, and to track "pooled" entities i use ISharedComponent which refer my prefab entity. So when i what to instantiate my prefab (hybrid) entity i firstly ask "are there any free same entities?"

#

to ask it i create query that track those entities

#

but all this stuff is only for avoiding gameobject allocations

#

and it looks a bit unperformant

ocean tundra
#

IShared is probably the wrong one, its use case is more like Many entitys => 1 effect

frosty siren
#

ok, so how to find pooled entities?

ocean tundra
#

and when every you change the IShared you will change your entities Chunk

frosty siren
#

it never changes it's shared component

ocean tundra
#

so you will need a ICOmponent Tag? on all your entities

frosty siren
#

it just CreatedFrom { public Entity }

ocean tundra
#

Then you can use a entitiy query to find ALL your effect entities

#

then next you need to know free VS not free

#

so you could use the built in Child/Parent components for that

#

that will also get you free position following

frosty siren
#

i think use some FreeTag or something is better, cause you already got entities that free and have no need to ask

ocean tundra
#

yea a tag is another option

#

basicly you just need to boil it down to raw entity queyrs

frosty siren
#

But using Tag producing new Archetype and using Shared component producing just extra chunk

ocean tundra
#

then in some system you can do FreePooledEntities.IsEmpty (or count == 0) to spawn a few more

#

yea so tags have some optmizations comming

#

but not here yet

#

you can either dev trusting they will come and be released one day

frosty siren
#

yeah, basically i do exactly the same

ocean tundra
#

or change to using a bool inside your component

frosty siren
#

and other basic stuff

ocean tundra
#

haha exactly

frosty siren
#

so i completely lost my hope

ocean tundra
#

and theres other 'core' optmizations discussed that also have no sign of releasing

#

yea sooo slow latly

frosty siren
#

all my need to use hybrid in world is because no DOTS sprites

ocean tundra
#

theres someones 'pure' implemntation on the fourms

#

pretty sure its open source

frosty siren
#

yeah, but i'm love to use shader graph and other modern tools, so i'm afraid to go deep and use not built-in solutions

ocean tundra
#

Yea makes sense

#

I guess that's just the cost of DOTS atm

frosty siren
#

yes and maybe one day there will be DOTS sprites and i just run my game and it will no more hybrid entities automatically 😄

#

hope in this decade

ocean tundra
#

Yea can't wait

#

I just want them to get faster on releases again

#

And maybe more communication

frosty siren
#

many people think dots is dead

ocean tundra
#

yea exactly

#

it better not

#

i love it

#

and im planning many tools

#

would like to actually release them sometime 😛

fluid kiln
#

I stg if they kill dots lmao

frosty siren
#

I persuaded my former colleague from work to switch from his own ECS solution to DOTS. So it better not be dead, yeah 🤔

ocean tundra
#

i honestly dont think dots will be killed

#

its just slowed down a bit as focus has been on stability

fluid kiln
#

Also, covid maybe?

ocean tundra
#

yea i forget about covid

hollow sorrel
#

im guessing they realized it's way too early to be hyping up dots so they went to 0 communication so they can make proper marketing push later

#

same with games that get announced too early

ocean tundra
#

They were just too excited about it :p

#

Which I completely get

hollow sorrel
#

huh weird

#

i remember reading about burst being deterministic across same architecture (but not cross-platform)

ocean tundra
#

😛 i just saw that post too

hollow sorrel
#

but now there's burst dev saying there's basically 0 determinism

ocean tundra
#

yea

#

i've just always been planning that its not determistic

#

hence my networking tech is server client 😛

hollow sorrel
#

yea but there's people planning on it being deterministic across same architecture, due to whats been said on the forums by unity

ocean tundra
#

yea

hollow sorrel
#

@dusky wind did you ever continue with that ecs rollback game

ocean tundra
#

not great communication there

safe lintel
#

its kinda strange how slow dots is without burst

#

i guess i dont understand the subject enough and am guessing you can have determinism without burst but just running stuff without burst feels worse than regular gameobject-land

ocean tundra
#

i'm pretty sure its faster then just game objects

#

but yea feels soooo bad

#

especially physics

safe lintel
#

just thought maybe because a large part of gameobjects is the native c++ stuff behind the scenes?

#

im positive in some cases its worse because just like 5-10 pure dots characters without burst is a slideshow 🥲

ocean tundra
#

honestly i havnt tested enough

dusky wind
#

Still working on it

#

Just don't have time for it currently

gritty bane
#

can I load dylibs with the Burst compiler

#

or is that coming in a future update

ocean tundra
#

@gritty bane i think thats been released

vivid lotus
#

There's no DOTS/ECS-friendly way to do a SpriteRenderer yet, right? If I want 2D am I best off doing it with planes for the moment? From what I've gathered the SpriteRenderer isn't supported without a companion GameObject.

hollow sorrel
#

no built-in way no but there's plenty of ways to roll your own (or use someone elses that rolled their own)

coarse turtle
vivid lotus
#

(SpriteRenderer + companion GameObject) or (Plane), that is.

coarse turtle
#

one or the other, sorry it's not very clear. For things that are have different animations I mainly use SpriteRenderer w/ Companion gameobject. But for something like a projectile - I just use a plane + instancing

vivid lotus
#

Gotcha yeah, I guess I'll use a plane for now then, won't be so bad.

#

Thank you both.

coarse turtle
#

yea if you need to grab like the UV's so textures fit nicely to the plane, I just use Sprite.DataUtility to grab the UVs from a sprite object so I can set up the plane uvs properly

vivid lotus
#

Ah yeah, I need to think about that. Okay, so take a spritesheet and then, what, set the UVs as a PropertyBlock or something?

coarse turtle
#

well I actually just make my meshes procedurally

vivid lotus
#

Ah, okay, so do you like feed in a spritesheet and metadata and it pregenerates all the meshes you feed into the MeshFilters?

#

Trying to maximize reuse.

coarse turtle
#

yea something like that

vivid lotus
#

Sounds good, I'll try that out. Thanks!

ocean tundra
#

also i intend to release a proper ECS modding library,
Current focus is Data modifications (eg marking a prefab as moddable and changing values like Attack/Health ect)
Next is visual changes, Models/Materials (Unity Assets)
Finally is code based mods, New ECS Components + Systems and some sort of 'simpler' API

safe lintel
#

wow wasnt expecting any real acknowledgement for mods tbh

gritty bane
#

So if I want to use Rust Lang ( and make Dylibs from rust) along with the Burst compiler, would I have to use 2021 Unity or can I stick with 2020

ocean tundra
#

lots of people ask for mods in normal unity

#

but its def not a huge area

#

@gritty bane Oh dam, I didn't know you were talking about rust Dlls

#

i don't believe that combo would work

#

Burst works on C# dlls

#

you 'might' be able to use old dll imports to run code in the dll

gritty bane
#

Oof time for a rewrite of code into c#

#

Oh so your saying that it might be possible to run a dll that’s running code from a rust dll

#

Interesting

ocean tundra
#

um no the other way

#

unity C# could dll import into rust code

#

it def can into C++ code

#

Looks like you can

#

but that transition from managed c# into c++ (or rust) is slow, thats one of the issues with normal Unity (lots of underlying unity is C++)

gritty bane
#

Oh that’s a new guide.. all the guides I’ve found were at least 3 years or older

ocean tundra
#

was just a quick google

#

no clue how revelant it is

#

or if its even worth having a mix of C#, C++ and rust

gritty bane
#

I had my eyes on this one and I have no idea if it’ll work with burst

ocean tundra
#

im basically 100% sure burst wont work with anything other then c#

gritty bane
#

It’s probably not ( besides very niche things) but it sure is cool to get languages to talk to each other

ocean tundra
#

like the first line of burst "Burst is a compiler that translates from IL/.NET bytecode to highly optimized native code using LLVM."

#

and as far as i know rust is not a .net language

gritty bane
#

What if you already have highly optimized llvm code from rust 🤔

ocean tundra
#

no burst takes the .net bytecode

#

and makes something better

#

the rust compiler would be doing the same thing and not outputting into .net bytecode

gritty bane
#

Yeah I know ik I was joking lol

#

But oof I have to rewrite some of my rust files into C#

#

Good thing there’s Structs and type generic constraints in both languages

#

Only thing I’m missing is data typed enums

ocean tundra
#

?? c# has enums

#

also generics arnt great to use with ECS

vivid lotus
#

This may be a silly question, but when does the Burst compiler actually run? Is it at startup (like C#, JIT) or is it part of the build packaging process?

ocean tundra
#

So in editor it runs when you call a burst method

robust scaffold
ocean tundra
#

in a actual build i think it runs during the build process

vivid lotus
#

Hm. There's no way to defer it in builds I'm guessing? I'm thinking about for maintaining accessibility to injectors like Harmony.

ocean tundra
#

yea so in editor its 'jit' and in builds its AOT

vivid lotus
#

Since we're on the topic of modding.

ocean tundra
#

@vivid lotus I think no, as it needs a ton of platform dlls /tools

gritty bane
# ocean tundra ?? c# has enums

C# has enums, but not the same way Rust and Swift have enums... they allow you to store things in the enums like thisrust pub enum Cell{ Text(String), Number(f64), Formula(FormulaCell), Empty }
C# doesnt have this right (unless they changed it)

vivid lotus
#

Ah, shame.

zenith wyvern
#

No it doesn't

vivid lotus
#

I guess if you wanted your burst stuff to be moddable you could make it all as a plugin and release the source for that, but that's a lot of source to release, and there would be no compatibility between mods.

zenith wyvern
#

I was pretty blown away by the enums when I learned rust, it's awesome

ocean tundra
#

@gritty bane oh yea that would be nice, C# is just numbers/chars, Ive seen attributes used to give extra data on a enum, but that means reflection

#

or a dictionary could work

robust scaffold
vivid lotus
#

You can do it with unsafe C#. Those enums are just discriminated union types.

zenith wyvern
#

It's still not the same thing. Enums in rust can have their own functions

vivid lotus
#

Extension methods?

robust scaffold
#

Unsafe and burst, hrm. Might be a bit tricky.

ocean tundra
#

@vivid lotus yea moddable code with burst is going to be tough, my plan is making the mod makers install unity and all the tools and provide some sort of package to compile it

ocean tundra
#

im sure mod compatibility can be done, but need to figure out a good mod API

vivid lotus
#

That's what we were discussing. 😅

gritty bane
# vivid lotus Extension methods?

you can implement traits for a enum like this in Rust, which makes it inherit methods:rust impl CellADT for Cell{ fn cell_text(&self) -> String { match self { Cell::Text(string) =>{cell_text_spaces(string.to_string().borrow())}, Cell::Number(number) =>{cell_text_spaces(number.to_string().borrow())}, Cell::Formula(_form) => {cell_text_spaces(&self.get_value().unwrap_or(0.0).to_string())}, Cell::Empty => " ".repeat(10).to_string(), } }

ocean tundra
#

yup i posted it earlier 😛

vivid lotus
#

Oh yeah, it isn't going to be at the same level (or with the same compiler optimizations) as rust enums, but you can get part of the way there with unsafe C# and explicit struct layout stuff to create discriminated union types (which is what rust enums are under the hood).

ocean tundra
#

@robust scaffold Im planning a modding package for unity, so def read all that 😛

robust scaffold
#

Honestly, my current very tentative plans for modding is making the players (if any) put in PRs to the github. Adding third party dlls and making sure it's all safe and no arbitrary code execution is such a pain.

ocean tundra
#

I feel PRs to Github are a bit tough for mods

#

if its a open source game thats different

robust scaffold
#

True true, Im always running on the assumption my game will be open source and on github. Never in my plans to go private and commercial.

ocean tundra
#

My plan is a mini package system, like unity packages
Full with dependencies and advanced features but with 'simple' use
a basic mod is a mod definition file and then just plain JSON edits of your moddable entities

#

more advanced will include a unity package (maybe with addressables?) containing models/material/sounds (unity Assets) that are linked via more complex json files (http://jsonpatch.com/)

#

finally im still figureing out code based mods, full on new ECS components and Systems actually dosnt seem too hard, but also overkill for mods

rugged lark
#

I'm going to ask a dumb question. Is the Hybrid renderer required when using ECS, or is it a byproduct of the Hybrid-ECS conversion process? If I'm dynamically creating my assets and won't rely on conversion from gameobject to entity at runtime, can I ignore the Hybrid renderer? Should I?

safe lintel
#

you can use ecs without hybrid renderer and: create your own renderer or just create the rendermesh yourself, or use gameobjects to render things and keep ecs as a hidden layer

#

but the latest hybrid renderer docs show how to create a render entity from code which might be what youre looking for

rugged lark
#

Is the Hybrid renderer basically a system which automatically renders any entity with the prerequisite components? Whereas by eschewing the

#

Hybrid renderer I'll need to manually render each entity? Is that an accurate statement?

ocean tundra
#

yea that sounds right

#

you use the Graphics.Draw** to render if your not using hybrid renderer

rugged lark
#

Okay. Thank you. I'm clawing my way towards a modicum of understanding.

ocean tundra
#

dispite the issues with Hybrid Renderer i would still try to use it

#

unity will keep working on it and eventually it will be ok

rugged lark
#

I'll look at the Hybrid Renderer documentation for creating an entity from code, as suggested by thelabaron and see if that gets me close to where I want to be.

#

Thanks all.

ocean tundra
#

if your creating via code theres new helper methods

#

as hybrid renderer requires a few different components

sturdy rune
#

so - I am a new Unity dev but I have experience coding. I love ECS/DOTS but almost every time I ask questions about it - people are unsure of the future of it. Is there something obvious I don't know from the handful of courses and tutorials I am going through?

ocean tundra
#

@sturdy rune theres just been no real progress/communication for a bit

#

some of the devs are vocal on the fourms with issues

#

and questions

#

but actual long term plans/goals/timelines there not been much

sturdy rune
#

Interesting. Technically I love the concept

#

Am computer engg and it really feels good to write in ecs

ocean tundra
#

Yea ecs is great to use

#

but missing SOOO much 😦

sturdy rune
#

I noticed it doesn't have animations

#

But just in the course I am using

#

Perhaps as a beginner it doesn't matter - as I learn I will grow into it

#

With it actually

ocean tundra
#

it has animations but they are super hard to get working atm

sturdy rune
#

Ah. I am using 0.10 I believe. Bit older but concepts are great. Do collisions get better in newer versions?

ocean tundra
#

not sure

#

thats physics and i dont use it much

#

mainly as a querying system atm

#

but you can plug in havoc now

#

that might be better

safe lintel
#

just realised that statemachines in animation still only exist as test cases and not necessarily anything concrete enough for a working example(as they dont have any). hopefully the next slew of updates brings more of that out. spent a lot of time just spinning my wheels with this package so far 🥲

sturdy rune
#

Haha. Well the last update I saw was jan24 so really not that long between.

plush meadow
#

i want to enable/disable chunks of entities instead of individual ones, and it seems like adding Disabled as a chunk component doesn't work

#

am i missing anything? is there any workaround?

sturdy rune
#

are you sure you added the Disabled component?

#

to the chunk

plush meadow
#

yes, it shows up in the entity debugger

gusty comet
#

Hey guys, should I ask about Unity Physics here? Or directly in the physics channel?
I'm searching for a GetCategoryBitset (or at least number) functionality. Too not hardcode the layer used for my raycasts.

gusty comet
#

I'm searching around PhysicShape, because the editor know about the layer names, but I can't find the asset loading :/

safe lintel
#

do you mean the collisionfilters?

gusty comet
#

Yeah and to find the right category value, like if I was using LayerMask.NameToLayer.

safe lintel
#

I dont know if there is anything like that but theres the PhysicsCategoryTags for constructing a collision filter

#
            var filter = CollisionFilter.Default;
            filter.CollidesWith = collidesWith.Value;
            filter.BelongsTo = belongsTo.Value;
            return filter;
gusty comet
#

well I can simply add the asset into my settings, but I don't get how unity load it from anywhere 🤷

#

So just to be clear for other people, I'm wondering if there is an "utility" to get the category tag of Ground in this example. This asset can be anywhere but Unity will find it so I don't know how. But for now I'll just add it to my settings and query the category tag from it.

safe lintel
#

i dont think there is? you should ask on the dots physics sub forum because im almost positive they will answer this(and there should be a way)

ocean tundra
#

@gusty comet so if you can get the asset there's helper methods/properties on it

#

But getting the assest is the annoying part

#

But also it's only meant to be a editor helper I think

#

Might get strippedm from builds

gusty comet
ocean tundra
#

maybe

#

check where the code is

#

if its in a Editor folder or has #If Editors it will get stripped

gusty comet
#

I don't think there is a need to have several of these assets, but you know, to get a clean structure

ocean tundra
#

I read the rest of the chanel, i havnt really got a good answer for not hardcoding your layers

gusty comet
ocean tundra
#

all mine ended up as consts in a file somewherre

gusty comet
#

I'll tell you if I got an answer then ^^

ocean tundra
#

I've started with lots of code gen recently and that might be a good answer, just code gen out a file

#

i must have been thinking about something else physics layer related sorry, no methods or anything usefull on it

zenith wyvern
#

I would say just stick the CategoryNames asset in a Resources folder. Then you can access it with var names = Resources.Load<PhysicsCategoryNames>(nameOfAsset) and build your own NativeHashMap of names->values that you can stick in a system for easy access.

ocean tundra
#

ew Resources.Load 😛

safe lintel
#

wow, build caching with the current alpha saves a hell of a lot of time

ocean tundra
#

@safe lintel build caching?

#

like incremental builds?

ocean tundra
#

yay

#

that looks great

#

i need to update again

#

i use asmdefs wayyy too much

pulsar jay
#

Is anybody using tests with ECS? I am trying to setup tests but I cannot get ECSTestFixture to work as there seems to be a problem with referencing this asdmf

hollow sorrel
#

@pulsar jay haven't tried recently but i remember that working, what's the issue?

pulsar jay
#

easiest solution is to just copy the files

#

as the assembly reference deos not work correctly

hollow sorrel
#

ahh i see

#

good to know

frosty siren
#

I figured out that when i convert gameobject with sprite renderer component, conversion produces entity with all this nice components like companion link, hide flags and SpriteRenderer itself. But if gameobject has some extra mono components like Sorting group, or Light2D, or my own custom mono, then final entity wont have any of this components, even campanion gameobject wont have it.
Can i somehow make it automatically added like sprite renderer? Maybe write some special ConversionSystem?

bright sentinel
#

@frosty siren You can write a MonoBehaviour with IConvertGameObjectToEntity, which will add the managed components for you.

frosty siren
#

yes, but this leads to every time i want my mono be added to entity i must write special authoring that will attach it

karmic basin
#

@frosty siren try "ConvertAndInject" mode instead of AndDestroy ?

frosty siren
#

already tried

plush meadow
#

i'm getting really random lag spike caused by rendering

#

no clue where i went wrong

#

does anyone have any clue what might be the cause of htis

coarse turtle
#

it says GC.Collect is running for 57.91 ms

#

so something is producing garbage in RenderMeshSystemV2 and is causing the garbage collector to free up used memory

plush meadow
#

i dont know what's causing that though

#

hmm

coarse turtle
#

Well it looks like the sorting function used in that system is the cause

#

might want to look there?

plush meadow
#

where exactly? sorry i'm not very knowledgable about this

coarse turtle
#

RenderMeshSystemV2, find something called Sort Shared Renderers

plush meadow
#

gonna try profiling in a build later i guess

#

thanks for pointing out the gc.collect though

eager jungle
#

Hey guys, hope all is well, I need your expertise with blob assets.
We're trying to do "nested" blob assets. Basically we're converting scriptable objects to blobs, but they can reference other scriptables (and thus other blobs). What would be the best strategy? We used to use, for example, BlobArray<BlobAssetReference<Foo>> and it worked fine, but this raises errors in the latest versions of entities.

ocean tundra
#

@eager jungle can you have a seprate 'dictonary' blob

#

only make 1 of them and all your blob assests 'add' themselfs to that blob, and use some sort of ID system to reference them

#

either that or you could copy all the referenced data into the blob that has the reference somehow

#

Has anyone tried storing a burst FunctionPointer<T> in a IComponent or IBufferElement?

eager jungle
#

@ocean tundra thanks for the suggestions! Copying the data is probably what I'll end up doing... but it sounds a bit counter intuitive... About having a dictionary, yea we have one already... that's not ideal 😢 Since the data in blob is immutable I was hoping for a way to reference blob assets inside blob assets...

ocean tundra
#

yea but again since data is immutable copying the data isnt a huge risk

#

will probably get you faster reads too

eager jungle
#

yes certainly, hopefully my blobs are not too big. But what if they were??? and referenced many time

#

Unity.Physics.CompoundCollider are hacking their way it seems. Because compound collider has an array of blobs in it...

ocean tundra
#

yea physics is doing tons of little hacks

safe lintel
#

🥳 PSA the master branch of the graphics repo now has deferred universal, and hybrid v2 works with it! 🔥 shadows and point lights for urp dots at long last

ocean tundra
#

@safe lintel yesss deferred means unlimited lights right?

safe lintel
#

pretty much 😀

ocean tundra
#

awesome

#

how easy is it to use?

#

just make a deferred urp asset and ready to go?

safe lintel
#

just select deferred from the drop down in the renderer asset and done

ocean tundra
#

Sweet

safe lintel
ocean tundra
#

im guessing its not due in a package till the next one, version 11?

safe lintel
#

didnt have to do anything for hybrid either, though I was already running it with v2 enabled

#

well i just upgraded my project to 2020.2alpha, and it auto updated the renderpipeline to v12.0. i grabbed the cloned master from the repo and it still shows as 12.0 so not sure what the eventual version will be

ocean tundra
#

nice

#

hopfully that will be soon

#

but I guess i could just add the repo directly if i need it

safe lintel
#

i did notice that it didnt build with il2cpp, had to switch to mono, so not sure what the issue there is, need to test it a bit more

ocean tundra
#

I always seem to have issues with il2cpp

#

like i love the idea of it

#

but so much pain

fluid kiln
#

Does any of you use Unity.Animation? Do you think it's in any condition to be used or should I wait before digging into it?

ocean tundra
#

Depends on your game and timelines 😛

fluid kiln
#

Personal, no timelines :p

ocean tundra
#

personally im going to wait for another version or 2

fluid kiln
#

Without it I assume there's no way to handle animations without hybrid entities?

ocean tundra
#

i can survive with T poses for now 😛

fluid kiln
#

That's what I'm thinking lol

ocean tundra
#

i think there are 'ways' to get animations going but the effort is kinda high

fluid kiln
#

Would you know why in runtime, my meshes lose their rotation?

#

In editor my character looks fine, right scale and rotation, when I press play and it's converted it rotates 90 degrees and scales up, it's weird

ocean tundra
#

Lets rule out the simple stuff 😛
Any Custom Conversion Systems?
OR IConvert...s on your gameobject?

#

using subscenes or Convert and Inject?

#

can you pause on frame 1 and see if your charactor has changed?

fluid kiln
#

No custom conversion, subscenes (although my understanding of it is limited), I'll try pausing 1 frame that's a good idea ;p

frosty siren
#

@bright sentinel @karmic basin I find an answer for my question in https://gametorrahod.com/game-object-conversion-and-subscene/ (greate author). I can write my own GameObjectConversionSystem in which i will use AddHybridComponent(myMono). As a result i will have "hybrid" entity with component object and also gameobject won't lose it's component.

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.

fluid kiln
#

It had an animator that gets deleted during runtime, stoopid me ^^

vivid lotus
#

Is there any downside to making entities entirely in code (EntityManager.CreateEntity, I believe?) other than making it more complicated to configure?

fluid kiln
#

I'd assume it's faster but it's a pain in the ass to configure

#

Have anyone had success with importing models directly from .blend files? I seem to lose my rotation & scale during conversion

safe lintel
#

ive been using animation(mostly tests)

#

currently statemachines only seem to exist as tests, so you are kinda limited in functionality to using the graph setup to achieve things. its fairly hard to even get something as simple as if condition play animation (performantly).

#

the next release may(or may not) have visual scripting with it, the current one integrated the ui (but its missing nodes) so im hoping the next release adds a ton more functionality.

ocean tundra
#

@vivid lotus @fluid kiln Actually i think it would be slower making via code

#

depending 😛

fluid kiln
ocean tundra
#

if its a nomalish entity your making then your stuck using objects (eg meshs) meaning can only make via main thread

#

but if your making 10000s then you can use the batch APIs and that would be faster

safe lintel
#

also @fluid kiln im assuming this is the problem

ocean tundra
#

finally subscene conversion is in editor instead of runtime, so you dont have the same performance cost of creating those entities

safe lintel
#

axis chart

fluid kiln
#

Well Unity handles the blender axis using GOs, I'm assuming it doesn't in entities

#

Hmmm

ocean tundra
#

lol unreal off on its own 😛

fluid kiln
#

yikes

#

:p

safe lintel
#

i keep things to fbx personally

fluid kiln
#

Might've to do that, one more step in the workflow :p

ocean tundra
#

yea same, keeping to a common export format can be annoying but worth it

#

for me its for automated build/play servers, they can build the unity project, but if theres any .blend files you need bleander setup on it as well

fluid kiln
#

Haa I see

ocean tundra
#

also means new team members dont need to also setup blender 😛

fluid kiln
#

Y'all working in teams with DOTS? Do you have an employer or is it just group projects?

ocean tundra
#

na its more of me planning ahead 😛

#

its all personal projects atm

fluid kiln
#

ha planning ahead :p

ocean tundra
#

daydreams and wishs 😛

#

im hopfull in a month or so will have some packages released tho

fluid kiln
#

Just gotta do something decent enough for a kickstarter and then you can hire artists ha ha ha am i right

ocean tundra
#

😛 im hoping to get the asset store to fund me for a bit

#

but i expect the DOTS community is still too small and weirdly too expert

fluid kiln
#

😂

#

idk there's a few features I could see myself buy in dots xD

ocean tundra
#

😛 thats what i want to hear

#

im hoping to do a basic 'free' tier of good quality and then a 'pro' version with a few extra features

fluid kiln
#

like editor support for entity buffers 🙂

ocean tundra
#

what thats all ready in?

#

tho i hate the UI control for them

#

all that paging is super annoying for me (my buffers get HUGGGE)

vivid lotus
ocean tundra
#

oh but they are 😛

vivid lotus
#

How so?

ocean tundra
#

so I too am aiming for a rts

#

i have a 'prefabs' scene

#

all my unit/building prefabs in it

#

I make a custom IConvert... which adds the Prefab tag to the entity

#

i also have a sepreate ID system so i can find those entities again

#

(which is probably the worst part)

vivid lotus
#

So you make entities once from the scene and clone them essentially?

ocean tundra
#

yea

zenith wyvern
ocean tundra
#

all a prefab is in DOTS is a entity with the prefab tag

#
  • a linked entity group if there are children
#

so you can take any entity and make it a prefab

vivid lotus
zenith wyvern
#

The point is to build a robust and easily modifiable editor representation of your entity via prefabs

ocean tundra
#

😛 @vivid lotus we should talk
I'm building a modding package and would love your ideas

zenith wyvern
#

If you're not doing that you're giving up on the whole "editor" part of the unity editor for no reason

vivid lotus
#

Well, there's a reason in this case.

zenith wyvern
#

Ahh I see

ocean tundra
#

yea my first attempt at RTS + Modding was much like your describing, i would load the files and do my 'own' entity creation

vivid lotus
#

The Unity Editor is great for the first party making the game, but not so great for third parties editing the game.

ocean tundra
#

i even went so far to make my own subscenes 😛

#

at runtime

#

was full on crazy 😛

vivid lotus
#

Yeah I'm just starting down this path so I'm trying to figure out best practices.

ocean tundra
#

Do you mind if i PM you?

vivid lotus
#

Sure, though fair warning I'm a total DOTS novice.

ocean tundra
#

sounds like your exploring the same stuff as me and would be happy to share

vivid lotus
#

Is there a way to swap out an entity's material inside an ECB's SetSharedComponent (in this case, on the RenderMesh) while spawning the entity?

#

Essentially, I'm trying to set rendering information on an entity as I spawn it from a job (through an ECB), but having trouble figuring out how to get the material in there to use it:

protected override void OnUpdate()
{
    var commandBuffer = bufferSystem.CreateCommandBuffer().AsParallelWriter();

    Entities
        .WithName("SpawnSystem")
        .WithBurst(FloatMode.Default, FloatPrecision.Standard, true)
        .ForEach((Entity entity, int entityInQueryIndex, in SpawnComponent spawnerFromEntity, in LocalToWorld location) =>
        {
            var instance = commandBuffer.Instantiate(entityInQueryIndex, spawnerFromEntity.Prefab);
            commandBuffer.SetComponent(entityInQueryIndex, instance, new Translation { Value = new float3(0.0f, 0.0f, 0.0f) });

            "vvvv PROBLEM HERE: vvvv"
            commandBuffer.SetSharedComponent(entityInQueryIndex, instance, new RenderMesh { mesh = spawnerFromEntity.Mesh, material = spawnerFromEntity.Material });
            "^^^^^^^^^^^^^^^^^^^^^^^"

            commandBuffer.DestroyEntity(entityInQueryIndex, entity);
        }).ScheduleParallel();

    bufferSystem.AddJobHandleForProducer(Dependency);
}
#

Where SpawnComponent looks like this:

public struct SpawnComponent : IComponentData
{
    public Entity Prefab;
    public Material Material;
    public Mesh Mesh;
}
#

But Material isn't blittable, so I can't store it in there, right?

#

Any idea how I'd accomplish this? I'm trying to swap out the mesh and material during creation using an ECB if I can, or at least partially using an ECB where possible.

zenith wyvern
#

Shared components can't be used in burst

zenith wyvern
#

Then call your spawn job WithoutBurst

#

You can still use an ECB but shared components don't work with jobs/burst yet, so anything that uses them needs to be main thread and not bursted

void girder
#

I remember in the forums that someone said there would be non-managed shared components

zenith wyvern
#

Yeah in the source code it says they intend for them to be unmanaged eventually. But it's said that for like two years now

#

I wouldn't expect it any time soon

void girder
#

Wonder why. It seems pretty useful

vivid lotus
#

RenderMesh is managed then, I take it?

zenith wyvern
#

I would guess because hybrid renderer still relies heavily on managed components (materials and meshes) and SCD is tied heavily into the hybrid renderer

zenith wyvern
#

As mentioned it stores meshes and materials so it has to be

vivid lotus
#

Gotcha.

#

If you clone an entity with a RenderMesh, can that be done with burst?

#

That is, Instantiate with the other entity as a basis.

zenith wyvern
#

Yeah, as far as I know instantiating an entity with managed components works fine and can be done in burst

void girder
#

Doesn't setting shared component data force jobs to complete?

zenith wyvern
#

As long as you're not directly referencing anything managed in the code

zenith wyvern
void girder
#

Shame there isn't an ECB for SCD with entity queries

vivid lotus
#

So in that vein of cloning existing entities to get around not being able to set shared components, is there a good way to make a lookup table of entities that I can access in a parallel/burst context?

#

Let's say I pregenerate entities for each "type" of thing I want to make, and then just want to clone them going forward by some index.

zenith wyvern
vivid lotus
#

Yeah basically I'm turning sprite sheets into pregenerated entities, but I'd like them to live in a list somewhere so I can quickly clone them as I add things to the game that use those sprites.

zenith wyvern
#

When I needed to do that before I made a normal component version of my shared component. I would write to that in a bursted job. Then I'd have another system with something like

Entities.WithChangedVersion<NormalComponent().WithoutBurst().
ForEach((SharedComponent shared, in NormalComponent normal)=>
shared=normal;).Run()
vivid lotus
#

(The sprite sheets are loaded at runtime so I can't make them prefabs or subscenes, AFAIK.)

#

Is there no way, within a burst job like what I posted here: #archived-dots message to access just some read-only global lookup table that goes from int -> Entity?

zenith wyvern
#

Sure there is, you could make a blob asset for it, or just use a NativeHashMap<int,Entity> in a system

#

Or even attach an Unsafe hashmap to a component

vivid lotus
#

Ah perfect, I'll look into those, thanks.

#

I'm a DOTS novice so if I'm asking obvious questions I apologize in advance, haha.

zenith wyvern
#

No worries

vivid lotus
#

Related to that, is cloning existing entities as prefabs generally cheap compared to spawning from a GameObject prefab or subscene?

#

Or at least competitive with those methods?

zenith wyvern
#

It's expensive in the sense that it causes a structural change and forces all your jobs to complete

#

But you can use batch methods to instantiate massive amounts of entities at once, which you can't do with a gameobject

#

So I guess I would say you can't really compare them