#archived-dots

1 messages Β· Page 248 of 1

rotund token
#

i should say, i believe dots is mostly deterministic on windows on modern amd/intel cpus

#

at least we haven't been able to break it in 2 years

#

we relied on client/server to generate their own world and graph for years, i only recently change it so the server sent the graph to clients to ensure cross platform compatibility

#

i'm pretty sure i've seen a burst dev mention that they believe it should be fine on windows but they provide no guarantees because they don't test for it

#

so yeah shouldn't rely on it

#

but it is interesting

devout prairie
#

graph as in nav mesh or?

rotund token
#

nah voronoi

#

world is procedurally generated using a voronoi diagram as the root basis of room generation

devout prairie
#

ah i see

rotund token
#

i should say mono <-> il2cpp is not deterministic at all

#

both produce vastly different results

#

we couldn't play editor to builds for ages because of this

#

made testing a pain

#

from my debugging basically the first sqrt differed between mono/il2cpp

devout prairie
#

do you find il2cpp faster or is it for security or platform requirements?

rotund token
#

it's faster but we use it because we need to use il2cpp for consoles

#

also at some random point mono builds just stopped working for us and we couldn't bebothered debugging why

#

which I find amusing because most of the time people have issues with il2cpp not the other way around

devout prairie
#

yeah last time i tried il2cpp it wouldn't run but that was a while ago

rotund token
#

usually just means something is stripping

devout prairie
#

i'm quite keen on the idea of devs making games moddable, and obviously it's extremely difficult to mod a game when it's built with il2cpp compared to just, opening up the csharp assembly inside dnspy or whatever and editing/recompiling

#

i wonder what the pathways might be for a game built with il2cpp to potentially enable mod support, can it use/load in external dll's etc - i'm assuming that's possible

safe lintel
#

i would kill for the old quake style game folder setup, just modify the raw files for the most part to edit assets

rotund token
#

in theory, burst/entities should make modding extremely easy in the future

#

and once ISystem comes out in 0.50 I'm going to look into it more

#

because burst allows loading external burst dlls at runtime

#

so you should be able to point to burst systems and jobs really easy

devout prairie
rotund token
#

i don't mean modifying the game, i mean adding systems/logic

#

there's actually very little reason to modify existing entities games when modding

#

if you can just insert your own systems

#

if you want your game to be really modded

devout prairie
rotund token
#

you'd apply write groups to your components

#

that allow turning your systems off by modders

#

by simply adding a new component

#

write groups are one of the most powerful entities features that no one really uses/talks about

coarse turtle
devout prairie
#

i think changing existing functionality would be the obvious thing.. but yeah being able to enable/disable existing systems and possible add new ones might go some way to making that possible.. probs out of reach of the majority of casual modders i'd assume tho

rotund token
#

i think changing existing functionality would be the obvious thing..
but with write groups they don't need to know the existing thing to change it!

#

that's the point

#

in theory if you simply provide a dll with all your data (components)

#

they can link that, build jobs/systems in unity however they want

#

and load it into your app without ever seeing your system code

#

it's conceptually beautiful

devout prairie
#

hmm yeah that makes some sense, although to really get it and i guess believe that it'd work i'd need to see it πŸ˜›

#

it gives some hope to that whole idea tho

rotund token
#

well do you understand write groups?

#

unity uses them on the TransformSystem

devout prairie
#

no i don't no i've neglected to use them so far

rotund token
#

by default unity updates LocalToWorld for you

    [WriteGroup(typeof(LocalToWorld))]
    [WriteGroup(typeof(LocalToParent))]
    public struct Translation : IComponentData```
#

but it's setup as a writegroup

devout prairie
#

right

rotund token
#

if you say wanted to come in and change how LocalToWorld worked

#

you can add a new component called

#

public struct CustomLocalToWorld : IComponentData

#

add the write group tag

#

and bam, unitys translation systems won't work on it anymore

#

for any entity you add to it

#

you've made that systems querying stop returning results even though it matches all components

devout prairie
#

so how does it prioritise which write group to use?

safe lintel
#

@coarse turtle are you also working on nimgui?

rotund token
#

have a read, explain it better than i would

#

but yeah write groups been in forever

#

and no one uses them or talks about it

devout prairie
#

haha yeah i did try, and thought 'ill come back to this'

rotund token
#

but it is the ideal tool for writing extendable code/libaries

devout prairie
#

interesting yeah, will def have that in mind

rotund token
#

like imagine you have a game with a dealdamagesystem
and you made the components writegroups

but a modder wants to come along and change how damage is dealt on certain creatures, all they need to do is create a new component for that write group and then write a system to deal the damage themselves

devout prairie
#

i think for some games it really makes sense to 'allow' modding, whether you explicitly build api support or simply just don't use il2cpp

rotund token
#

i'm surprised out how well some people modded our game with il2cpp

#

without any support

#

had half a dozen up within a week

devout prairie
#

so many games where mods have literally kept the games relevant, where otherwise they might not have

rotund token
#

in our no-advertised early access so there were very few players

#

i was impressed

#

but yeah definitely going to research/experiment with 0.50 to see what i can do

#

because i'd like to build the concept of modding into the base game of any new project

devout prairie
rotund token
#

the thing is, even with mono nearly all your game logic is in burst

#

it's pretty hard to mod

devout prairie
#

that's true, for burst enabled games yeah πŸ˜›

rotund token
#

well we are talking about modding in the dots channel

devout prairie
#

yeah of course just making a general comment, as it applies to how modding has been done with unity games for a number of years

#

but yeah write groups sounds like a great way to potentially do that.. build custom dll's with some custom components/systems and find a way to get them injected into the game

rotund token
#

yep! that's what i'm hoping is possible anyway

#

it does require developer support not something you can just hack into any dots game

#

but i really like the idea of making a game highly moddable

coarse turtle
#

i've been a bit busy these past few weeks with work I didn't really have time to push the final update 😦

#

before releasing it

safe lintel
#

looking forward to when it gets released πŸ™‚

coarse turtle
#

there's also like one thing that irks with nimgui and integrating it with like SRP i wanna figure out because I don't want post processing oversaturating/washing out the UI lool

safe lintel
#

need an alternative for uitoolkit/elements while we wait for 0.50 or whatever on the unity side

#

funny, i recall looking into ways to make the srp postprocessing affect uielements a while ago

coarse turtle
#

the thing with like Unity UGUI and and UI Toolkit (I think for UI Toolkit) is that, it renders as a separate subpass and where im stuck with is - how do I add a subpass to URP and such... I would prefer post processing not affect the UI cause it really makes things hard to read sometimes - which defeats the whole point of a debugging tool in a way πŸ€”

safe lintel
#

yeah I can totally understand not wanting visual effects to mess with debug ui, but from some previous experiments I totally wanted some of those things to affect the text in certain cases. anyway for anyone else who may not have seen it(itsjustblank's ui asset in development) - https://forum.unity.com/threads/in-development-nimgui-a-1-draw-call-immediate-mode-gui-for-unity.1171601/ πŸ™‚

coarse turtle
proud lotus
#

Can anyone recommend a DOTS tutorial for someone who can just about tread water with standard Unity?

deft stump
rustic rain
#

oh man

#

is it worth to add physics package to 2D?

#

and apply joints for Z axis

#

feels bad it adds way too much stuff

rustic rain
#

all right, I'm done with entities for now xD
Will limit myself to Jobs as for now

rustic rain
#

Soooo, any tips on how to gather data for job?
Let's say for simple transform changes

#
    public struct BackgroundMovementData
    {
        public float3 position;
        public float speed;
        public float offset;
    }
    public struct MoveBackgroundJob : IJobParallelFor
    {
        NativeList<BackgroundMovementData> data;
        public float delta;
        public void Execute(int index)
        {
            BackgroundMovementData curData = data[index];
            curData.position.x -= curData.speed * delta;
            if (curData.offset * -1.5f > curData.position.x)
            {
                curData.position += curData.offset * 3f;
            }
            data[index] = curData;
        }
    }

I need some tip for concept on how to organize data for this approach

rotund token
rustic rain
#

yyyep

#

now I need to figure out how to create input for my job

#

either create some management head that will store all references

#

or...

rotund token
#

the truth is, unless you have a really heavy job the cost of gathering then writing backresults will probably be greater than your performance savings in a job

rustic rain
#

eeeh

#

I just want to keep things in ECS mindset

#

even without entities

#

or at least

#

Data oriented design

#

OOP makes want to puke sometimes

rustic rain
#

hmm

#

When you add smth to NativeList

#

is there a consistent way to get index of newly added smth?

#

I'm thinking of creating self registering monos like that

#
private static NativeList<BackgroundMovementData> dataArray;
    private void Awake()
    {
        if (dataArray.IsEmpty) dataArray = new NativeList<BackgroundMovementData>(Allocator.Persistent);

        dataArray.Add(backgroundMovement);
    }
devout prairie
#

i think NativeList should act like a list ( whereas dict or hashmap i think no guarentee of order )

#

so if you add something to it just assume the index is like:
int index = dataArray.Length-1;

rustic rain
#

yeah, it seems like this

#

in source as well

#

but how to interact with it, when mono is destroyed

#

welp

#

it does mem cpy

#

kek

#

sucks

#

so hard

#

can't even use Jobs without entities

deft stump
rustic rain
#

I mean yes, but it's so inconvinient

#

you either have to recreate your own entities

#

or use it in certain niche situations

#

and everything would require some "Head" object to process all children

#

Can you use burst outside of jobs tho?

deft stump
#

yes

rustic rain
#

Like, define certain helper math functions as burst compile

#

and that would work?

deft stump
#

yes

#

read the docs there's a way to do it using function pointers

rustic rain
deft stump
#

yes

rustic rain
#
[BurstCompile]
public class BackgroundMovement : MonoBehaviour
{
    [BurstCompile]
    private static float3 NewPos(float3 curPos, float speed, float offset, float delta)
    {
        curPos.x -= speed * delta;
        if (offset * -1.5f > curPos.x)
        {
            curPos += offset * 3f;
        }
        return curPos;
    }
    private delegate float3 ProccessFloat3With3Floats(float3 x, float a, float b, float c);
    static FunctionPointer<ProccessFloat3With3Floats> mulFunctionPointer;
    static BackgroundMovement()
    {
        mulFunctionPointer = BurstCompiler.CompileFunctionPointer<ProccessFloat3With3Floats>(NewPos);
    }
#

Sooo, I guess that would work?

#

I wonder if it's even worth it

#

to compile such methods

#

so later to Invoke them with pointers

#

wellp, it's not kek

#

simple operations don't profit at all

deft stump
#

you only benefit from burst if your code is "SIMD-able".
from what I see, that's going to be completely scalar, I believe.

rustic rain
#

yeah, I watched it

#

fully

#

just curious to test things out

candid epoch
#

thanks for looking into it. My assumption was that with those UpdateBefore and UpdateAfter conditions my system should run between the TansformSystemGroup and the Command buffer. Did that to make sure that i can "completely" process certain entities i created this frame.
Took your advice and deleted it but couldn't let it go, so i did some additional digging and debugging. It led me to another system with UpdateBefore and UpdateAfter conditions that forced my command buffer to run before the TransformSystemGroup. After deleting one of the attributes the error is gone and it works. Should i try to set this up in an example project and report it as a bug? my setup was obviously wrong but i think having an error that indicates what the problem is would be better than getting an index exception πŸ™ˆ

karmic basin
#

I don't know if that's worth a bug report. As like you said it's a user confusion during setup. Due to the stacktrace and looking at the source you can quickly pinpoint the index-out-of-bounds in List error to the updatebefore attribute while the bootstrapper of your world tries to order systems exception so I'd say it's clear enough for an experimental package :p
Though I agree that some error message mentioning ordering conflict could help, because people are expected to explicitly declare them so required to stay organised and/or keep track and that can become a nightmare with hundreds of systems. But you don't need to be explicit everywhere only when dependencies are involved, and at least for now you can use system groups, and so on...

#

This even calls for some dependency-chain debugger asset tool, until Unity eventually provides one maybe in the far far future πŸ€”

candid epoch
#

yeah, i'll probably introduce some additional groups to make it less error prone.
been thinking about writing something that generates me a proper diagram of the current system ordering. maybe the issue that i had is a good reason to start implementing this.

#

just in case anyone runs into the same issue:
all i did was set a break point in ComponentSystemSorte at line 229 and evaluated this expression to find all the systems that couldn't be ordered properly:

Array.FindAll(elements,(ele) => ele.nAfter != -1).Select((ele) => ele.Type.FullName).ToArray()

and then i went through all of them to figure out what breaks my system order

karmic basin
karmic basin
pliant pike
#

I don't suppose anyone knows why we cant get DynamicBuffers in EntityQuerys? πŸ˜•

karmic basin
#

Works for me

pliant pike
#

really I use tocomponentdataarray and I just get an error πŸ˜•

karmic basin
#

Oh I use a chunk job

pliant pike
#

yeah I need to get one in a query outside a job

karmic basin
#

With a ForEach you could

pliant pike
#

You mean then pass them into a native array, because I've done that before

#

Just wish there was an easier way

karmic basin
#

yeah, could also toentityarray and loop + getbuffer from there, but that's a lot of non-linear lookups

pliant pike
#

Yeah not efficient, I might not use buffers at all πŸ€”

rustic rain
#

are there even any options besides buffers tho?

pliant pike
#

I might try another component with a unique id to identify the parent

coarse turtle
rustic rain
#

Guys, any idea what is better?
Make GO hybrid, where GO have colliders and solve them (because I have very few colliders with about 1 rigid body total)?
Oooor, use entity physics?

#

I'm gonna have about 10 simultenious colliders in scene

#

and 1 rigid body for player

pliant pike
deft stump
#

Is keeping a NativeList in Persistent throughout the lifetime of the game a good idea?

#

and also making it so that it never decreases in size?
I'll just reuse indeces

pliant pike
coarse turtle
deft stump
pliant pike
#

or did I remove empty indices that were at the endπŸ€”

white island
#

alright, how does error MayOnlyLiveInBlobStorageViolation: You may only access .tokens by (non-readonly) ref, as it may only live in blob storage. try ref BlobArray<FixedString32> yourVariable = ref yourPropertiesData.tokens
apply to this:

public static BlobbableRawStruct ConvertStruct(ref RawReader.ParsedRawData data)
    {
        return new BlobbableRawStruct
        {
            general_id = data.General.id,
            general_name = FlattenDict<string, string>(data.General.name),
            general_desc = FlattenDict<string, string>(data.General.desc),
            general_texture = data.General.texture,
            general_type = data.General.type,

            property_tokens = data.Properties.tokens,
            property_hardness = data.Properties.hardness,
            property_species_stats = FlattenDict<string, int>(data.Properties.species_stats),
            property_lifecycle = FlattenDict<string, int>(data.Properties.lifecycle),
            property_stats = FlattenDict<string, int>(data.Properties.stats),
            property_custom_props = data.Properties.custom_props,

            behaviours = FlattenBehaviors(data.Behaviors.behaviors),

            anatomy = data.Anatomy
        };
    }


rustic rain
#

I'm assuming dots actually likes that, but
if I make my own collision detection algorithm

#

is detecting collision per every tick between all colliders

#

is the way to go

#

or?

#

like:

foreach (collider in colliders){
   foreach(otherCollider in colliders){
        checkcollision(collider, otherCollider);

}
#

maybe there's any other smart ways about it?

#

since threading first loop is possible

#

but second is not

worn valley
#

That is a brute force way and physics systems will do a lot more to make it more efficient

#

Like checking bounding boxes first. Look up broad sweep and narrow sweep

rustic rain
#

well yeah, optimisations and etc

#

aabb

#

but besides that?

#

I guess the other way to do it smart is make

#

region groups

#

so, collisions only checked inside

#

any other solutions tho?

worn valley
#

There is lots of articles on physics best practices out there. DOTS is a bit better cause you just have more processing power but the core principles are all the same

deft stump
#

just to be sure, there's no 2D DOTS phsyics yet right?

rustic rain
#

there's

#

it's super old

#

I'm not even sure if it's capable to detect collisions itself

#

but

#

it's capable of doing casts

#

kek

#

here manual

cunning perch
#

Is Burst a Unity only thing? It seems like such a crazy good feature for all game engines not just Unity. Are there no other libraries that take bytecode to highly optimized native code

rustic rain
#

it's C# so

#

I doubt there's much to stop you from using it outside unity

cunning perch
#

oh that's nice. I thought it was a Unity only thing

#

can't seem to find it anyone online without it mentioning Unity. I guess Unity owns the source code then even though it's just c#?

rustic rain
#

source is right there

#

in packages folder

cunning perch
#

well, the license would stop me from using it outside of unity... Exercise of the license granted herein is permitted as long as it is in connection with the authoring and/or distribution of applications, software, or other content under a valid Unity content authoring and rendering engine software license (β€œEngine License”).

rustic rain
#

oh well

#

I guess my words only apply to "underground modding world"

#

kek

#

hmm, if I implement a system group and put a bunch of systems in it

#

does it mean that it'll work as sync point?

karmic basin
#

other than that a group is just a convenient way to ... group systems together

rustic rain
#

any idea on how to launch unity samples?

#

I donwloaded exact version of editor

#

it required

karmic basin
#

yeah make sure yo uuse same version as them

rustic rain
#

started sample

karmic basin
#

ah

rustic rain
#

loaded scene

#

it has 2 subscenes, both enclosed

#

I try to run in editor

#

I get red errors on update

#

hm

#

I think when they created it

#

they used older entities version yet

#

they didn't mention version in packages manifest

#

because they installed them all by dependency

karmic basin
#

Tiny has its own manual on a google drive, I would check it for any special requirements

#

But can't help you more, I didnt read it ^^

rustic rain
#

there's nothing

#

doubt they want me to build game every time to run it

#

omegalul

rustic rain
#

missile and player
I am really missing a point, how collision filters are determined for entity when you don't use authoring component

#

but rely on conversion system to convert GO component

#

I'm guessing it uses transform layer from GO

#

from here

#

But then how it determines what it collides with

#

I checked player and missile queries for filter values on their colliders

#

and they are different

#

here whole missile prefab

#

here Player

#

their authoring components have nothing to do with colliders

karmic basin
#

Unity provides some default conversion for legacy components

#

I would need to check, didn't have the chance to before πŸ€”

rustic rain
#

I mean, yeah it converts

#

but how does it get different collision filters

#

if it's not defined anywhere

karmic basin
#

I assume they at least init with CollisionFilter.Default maybe

#

aaah found it with a quick search πŸ˜›

rustic rain
#

??

karmic basin
rustic rain
#

so, how does it get it?

karmic basin
#

from the gameobject layers

rustic rain
#

collideswith

#

I mean

#

oh wait

#

gameobject layers have collides with?

karmic basin
#

nah i asume the helper method checks layer matrix from settings

#

so its cehcked 1 on 1

#

hence the loop I assume

rustic rain
#

but, collideswith on my 2 entities is different

karmic basin
#

don't take anything I say for granted, I'm just discovering it right here right now with you :p

karmic basin
rustic rain
#

I am so lost

#

how it's determined by default?

#

collides with everything?

karmic basin
#

Again, disclaimer, all I say are guesses from the high-level methods names, I didnt dig into it. But that's how I would naively start with

#

it loops over every layer
More like "checks current layer with every other one"

rustic rain
#

that link you said

#

pointed me to this

karmic basin
#

yes, that's the layer collision matrix

rustic rain
#

in project settings

karmic basin
#

ok my bad assumed you knew that

rustic rain
#

weird, if that's not assigned

#

thing is

#

this sample from unity

#

performs collisions like this:

                    if (physicsWorld.OverlapCollider(col
,
                        out OverlapColliderHit hit))
                    {
                        wasPlayerHit = true;

                        // stop everything
                        EntityManager.SetComponentData(gameStateEntity, new GameState
                        {
                            Value = GameStates.Start
                        });
                    }
#

for all queries

#

so, if Player collides with just everything

#

that is game over

#

yet, when player shoots smth

#

he is not colliding

karmic basin
karmic basin
rustic rain
#

here missile hit system

karmic basin
#

But not sure I understand what you're looking for

rustic rain
#

it only checks whether it collides or not

#

not checking if it's collides with smth it wants

deft stump
#

It probably has a bit operation inside the OverlapCollider method.
to filter out the hits

karmic basin
#

oh yeah so some kind of Asteroids game. Yeah in this kind of games any hit is instant death usually πŸ˜›

rustic rain
#

which is not defined at all

#

it seems

karmic basin
#

It retrieves it from the Collider blob itself

rustic rain
#

yeah, and I read those values through debug

karmic basin
#

so we're back to where we were with conversion for legacy components, or from the new Physics components if exist

karmic basin
rustic rain
#

not really

#

I'm confused if they have any value at all

#

why even belong to layer

#

if everything collides with everything

#

most annoying part is that I'm unable to play game in editor lol

#

to test things out with my changes

karmic basin
#

IIRC on DOTS physics, everything has to want to collide with everything for a collision to happen

#

it's a consent-based relationship, like people in real life (lol)

#

everything has to want to collide with everything
I meant every entity involved in the pair

#

damn I'm tired

river meteor
#

anyone have a problem with installing the packages and getting compilation errors based on collections?

#

I'm thinking one of my packages is too far current or something idk

coarse turtle
#

yea downgrade to the version of collections that is supported by entities

#

1.1.0 release isn't compatible yet

river meteor
#

thank you ^_^

rustic rain
#

yep yep yep

#

that thing I was afraid of

#

my entitiy collides with itself

#
        Entities
            .WithAll<PlayerTag>()
            .ForEach((Entity playerEntity, ref PhysicsColliderBlob collider, in Translation translation, in Rotation rotation) =>
            {
                var col = new OverlapColliderInput
                {
                    Collider = collider.Collider,
                    Transform = new PhysicsTransform(translation.Value, rotation.Value),
                    Filter = collider.Collider.Value.Filter
                };
                if (physicsWorld.OverlapCollider(col, out OverlapColliderHit hit))
                {

                    UnityEngine.Debug.Log("Collides" + playerEntity.Index);
                    UnityEngine.Debug.Log("With" + hit.Entity.Index);
                }
            }).Run();
#

Debug shows same entities

coarse turtle
#

would recommend looking at the BlobificationTests in the Unity.Entities package for reference

white island
#

Hmm okay I’ll deal with that after work

#

Then I can show my whole code

river meteor
#

i feel like installation order is such a puzzle box for these packages cryhands

#

so i'm not having the collections issue anymore but now i have this

#

nvm disregard. had to reboot after reinstalling burst

karmic basin
rustic rain
#

it's fine, I figured how to assign layers

#

but it can be done only through Unity project settings

karmic basin
#

ok nice

#

layer collsiion matrix would be for legacy physics components

#

can't build CollisionFilter at runtime and feed that ?

#

works for 3d but can't tell for 2d, never tried

rustic rain
#

can, but that's like unsafe

#

since you have to change collider through pointer

#

and

#

you it's way harder to find out whether you need new collider

#

or you can use same as others

karmic basin
#

yeah that's the way for now. Can also cache physics shapes and swap them at runtime if you prefer

rustic rain
#

it's super simple for me

#

it's just that broken sample tilted me hard

karmic basin
#

:p

rustic rain
#

and I couldn't see through simple stuff

#

2d is way way easier than 3d ngl

karmic basin
#

oh great. I still feel like it's a hassle to use and haven't enough time to do everything I want with 3d sooooo... not gonna touch 2d for a looong time πŸ™‚

rustic rain
#

actually the reason I decided to bail on 3d is because hybrid workflow is painful

karmic basin
#

yeah sure more than we would like πŸ˜“

river meteor
#

does anyone have a good holistic intro to dots tutorial they generally recommend?

rustic rain
#

moetsi has great tutorial

#

got me hooked very quickly

river meteor
#

i cannot find moetsi on youtube

rustic rain
#

it's text guide

river meteor
#

oh ok i'll check it out

#

i'm very much a visual learner so i'll check out unity's pong tutorial and go from there

white island
#

Skyrbunny does not understand Blobs

rustic rain
#

Is it a specific package that makes building normally (through File menu) impossible? Anyone knows?

rotund token
rustic rain
#

subscenes

#

?

rotund token
#

yep

#

subscenes

rustic rain
#

all right, that's fine for now

#

I don't use them at this point at all xD

#

maybe I should

rotund token
#

if you happen to have subscenes already built you can actually still use the file/build menu and just past them into the streamingassets folder

#

and it runs fine

rustic rain
#

Do you have any idea about how unity manages resources with subscenes?

#

I'm thinking of using subscene to quick reset level

rotund token
#

you can just unload/reload the subscene

#

and it would be a clean reset

rustic rain
#

yeah

#

so, it's not touching any loaded in subscene resources I assume?

#

if let's say I'll have a lot of heavy unique to this subscene resources

rotund token
#

subscenes are just a giant chunk of binary data, it's very fast to load/unload

rustic rain
#

Is there any sort of marker btw

#

to destroy certain object in subscene without conversion?

#

for sake of keeping designing sane

#

(having dummy empty go for folders)

#

yet, in runtime I don't want them at all

rotund token
#

from memory, every entity from a subscene has a component that links it to the specific subscene

rustic rain
#

since they create LTW components

rotund token
#

cant remember the name, cooking dinner otherwise i'd look it up

rustic rain
#

well what I want is to destroy entity completely

#

during conversion

#

so all child entities

#

will be independant

#

upon conversion

#

basically, don't even create entity

#

just destroy GO

#

releasing all children

#

to root

rotund token
#

you can control exactly what gets converted

#

also there's a top conversion component

#

that will stop any child from this point on converting

rustic rain
#

I want vice versa, convert children

#

not parent

#

kind of like this

#

I don't want Ground to be entity

#

only Ground Close

rotund token
#

no reason you can't have a conversion system that de-parents them before conversion

#

never really considered the need to try this though so no idea what pitfalls you might run into

#

any particular reason you can't have ground as an entity?

rustic rain
#

it messes with translation component

#

creates a need in sync point

#

since entitiy is considered child

#

and is now binded to it through several systems

#

that adjust local to world position

rotund token
rustic rain
#

ground close

#

they need to be changed as individuals

rustic rain
#

what GroupIndex stands for in collision filters?

rotund token
#

if you only change the children and never the parent it works as is, like it doesn't have a parent

rustic rain
#

still creates unwanted effects

#

with niche interactions, like spawning new outside of that parent

#

and creates relying on LTW component

#

instead of Translation/Rotation

#

if that parent is not 0,0,0

rotund token
#

i'd argue you should always rely on ltw for world space

rustic rain
#

does LTW exist on everything tho?

rotund token
#

should be on anything that has a translation, rotation or scale as unity adds it

rustic rain
#

Hmm
Weird thing

#

I have 2 different colliders

#

when my player collides with any of them

#

I run that code

#
            var interactableData = GetComponentDataFromEntity<InteractableEnvironmentComponent>(true);
            InteractableEnvironmentComponent data = interactableData[hit.Entity];
EntityManager.RemoveComponent<PhysicsColliderBlob>(hit.Entity);
#

OverlapColliderHit hit

#

so

#

Intended and expected result: that entity no more collides as it has no collider

#

but existing result is that none of those 2 entities collide anymore

#

not just one that collided

#

ok it's actually entity that doesn't spawn with collider at all for some reason

#

but why, they are identical. Yet no collider on tree2

safe lintel
#

Does unity physics even support 2d colliders officially?

#

just tested, tbh dont think 2d conversion is even supported, and what you get might just be coincidental for the one collider

river meteor
#

question: i've seen a couple tutorials at different time points, and it seems like most tutorials use some kind of hybrid ECS system. Is there any means to just fully develop in ECS and build a scene of entities, or is some hybridization required? like creating a scene with gameobjects and adding icomponentdata components and entity converters

#

(if anyone has a really good most-modern tutorial for dots that'd be great)

haughty rampart
safe lintel
#

to a certain degree you cant escape "hybrid" but what that means for each 3rd party tutorial probably varies

river meteor
#

oh ok

#

i imagine you can do hybrid if you're doing a purely procedural game? but as long as the hybrid approach is the standard that's what i care about

#

i just wanna make sure i'm learning it the correct way

#

just looking for the truest-to-intention instruction

haughty rampart
safe lintel
#

just keep an open mind as there are many different approaches and at this point unity might not even know what that best approach is

rustic rain
vagrant lotus
#

the wut

#

huh

rustic rain
#

working with it rn

#

it's bare bones

#

the only thing I use are collision detection

#

lul

#

there's built in gravity, but that's it

river meteor
#

getting started on a project that's going to rely on ECS

safe lintel
#

@rustic rain oh, project tiny?

rustic rain
#

not really

#

I just installed 2d package

#

works fine with the rest of dots

#

as standalone

#

it's basically same 3d physics

#

but way less developped

#

all same fields and etc

coarse turtle
#

Entities2D?

rustic rain
#

so it's kind of easy to use if you have experience with 3d physics package

#

no

#

physics

#

I use normal 3d entities

coarse turtle
#

oh

river meteor
#

but yeah do any of yall have recommendations for video resources?

#

i was poking around the unity pong tutorial lastnight. that's why i was surprised to see the hybrid approach. but makes sense now that you guys clarified that

haughty rampart
#

idk. maybe code monkey a bit and turbo makes games. but all are rather :7 outdated or not following good conventions

#

but that's true for pretty much all dots videos

vagrant lotus
#

alternatively, go the tinker around route (but this takes a lot of time)

river meteor
#

thank you much ^_^

#

question!

#

so this portion of the gdc 19 talk. I watched this a while ago but looking now, is it possible to use the disposable closure type syntax for this

haughty rampart
#

no

river meteor
#
using (NativeArray<Entity> bullets = new NativeArray<Entity>(totalAmount, Allocator.Temp))
{
  // bullet logic here
}
#

oh rip, that'd be handy

haughty rampart
#

you can try but it's gonna throw errors because in a using block you are not allowed to change the contents of the 'captured' variable

#

so that's something that will never be available

river meteor
#

oh i didn't realize that

haughty rampart
#

and using is pretty much just fancy for putting try finally around your code

rustic rain
#

is sprite renderer the only thing for drawing simple 2D?

#

I'm wondering how to make animation

#

without any structural changes

#

my bet is I need shared component for sprite sheet
but then, how to draw it

#

Actually

#

more like

haughty rampart
#

why don't you just use a plane and render your sprite on that quad with 3d

rustic rain
#

how to collect that data

#

I'm more confused about how to actually draw a sprite

#

without using material per frame

#

I want to use simple sprite default material for all sprites

#

as example for now

coarse turtle
#

i just store them in managed component data

rustic rain
#

and then?

coarse turtle
#

for sprite sheet animation, SpriteRenderer2D regenerates the vertices iirc

haughty rampart
rustic rain
#

flipboard shader?

coarse turtle
#

if your sprite is all the same size per tile, then you can just generate a regular quad and shift the uvs

rustic rain
#

ok, that's the start

#

so fliipbook is just going through array of UVs

#

??

coarse turtle
#

which is what MindStyler is pretty much saying with the flipbook shader

rustic rain
#

and picks correct sprite from texture?

coarse turtle
#

yea

#

you can also just do math to offset it instead of

#

reading an array of uvs

#

if you're generating a quad, and don't want to regenerate the mesh, then doing math to offset the uvs can be better

rustic rain
#

I'm in 2d space here, so using quad is best practice I think

#

thing is

#

I kind of want to make at least some what universal system

#

not the one that only applies to spritesheets

#

that are exact way I hardcode in shader

coarse turtle
#

whatever way works

#

I just do math 🀷

#

figure out your needs/use cases first before you roll out a generic system that works for anything imo

rustic rain
#

my need is that I want to pass either an array of sprites

#

to my shared component

#

or smth very similiar to it

#

and expect system to just switch them through time

coarse turtle
#

yea i have something similar

rustic rain
#

so you do all your work in shader?

coarse turtle
#

it's a mix

#

shader does most of the heavy lifting, dots side just passes the index

rustic rain
#

index of current sprite to use?

coarse turtle
#

yea

#

i don't keep an array of sprites

#

just a single spritesheet

#

for sprites with varying sizes (cause of packing), I have a different method of handling it

#

which is typically just generating all of the unique meshes and then submeshing them. I switch the index of which submesh I want to render because it has the correct uvs I need to render the correct sprite in the animation

#

it does mean that i upload like a few hundred vertices to the gpu since all the uvs are packed together

#

instead of uploading 4 vertices

rustic rain
#

ok I think I got an idea

#

I'll keep array of UVs on component

#

along with shared component for spritesheet itself

#

and then just collect them all to draw as single batch

#

assuming jobs has a built in job per sharedcomponent

safe lintel
#

@river meteor if you use the Temp allocation inside a job you dont need to dispose it, its done automatically

rustic rain
#

How to create an ISharedComponentData with Materail as field?

#
public struct AnimatedSpritesheet : ISharedComponentData, IEquatable<Material>
{
    public Material material;
    public float2 wh;

    public bool Equals(Material other)
    {
        return other == material;
    }
}

Editor yelled on me for not using Iquatable

#

so I kind of tried this with blind eyes

#

is that correct what I did here?

rotund token
#

<AnimatedSpriteSheet>

rustic rain
#

yeah, I see

#
public struct AnimatedSpritesheet : ISharedComponentData, IEquatable<AnimatedSpritesheet>
{
    public Material material;
    public float2 wh;

    public bool Equals(AnimatedSpritesheet other)
    {
        return other.material.Equals(material) && other.wh.Equals(wh);
    }
}
#

I guess that would work

#

you must also override GetHashCode()

#

lul

#

ok, so how do I do that? any tips?

#

I mean, how to implement hashcode method

#

all right

#

looks like VS got me covered

#

with it's auto generator

river meteor
#

hey question. adding convert to entity script with create and destroy just destroys the gameobject but i don't see the object in the scene anymore

#

is there like an ECS specific rendering component?

devout prairie
river meteor
#

i figured it out, thank you!

#

i'm using URP so had to enable hybrid renderer v2

river meteor
#

another question: what is the distinction between creating a system that inherist systembase and jobcomponentsystem

#

because when i go to the context menu i can see ECS->System and it creates a template with systembase

#

oh nvm just saw one returns a jobhandle and systembase returns void

haughty rampart
river meteor
#

fudge

#

oh ok

#

so systembase is the correct implementation? and i just don't bother returning the handle?

haughty rampart
#

yes. system base is the ONLY correct class.

river meteor
#

ok glad i asked

#

unity's 2019 tutorial PepeHands

haughty rampart
#

in a newer version you can also use ISystem then

river meteor
#

oh, makes sense. so you can create your own system heirarchy with base implementations, and systems only require OnUpdate to be defined anyway

haughty rampart
#

no. ISystem will let you burst the system code itself

river meteor
#

ohhhhhhh

#

do you need [AlwaysSynchronizeSystem] for any system that is going to operate on player input?

#

or any main thread dependency

haughty rampart
#

no. i never use alwayssynchronizesystem

river meteor
#

oh ok

#

.Run is sufficient?

haughty rampart
#

i never use run. then it's just like calling a method. gets executed instantly. then what's the point of the job?

#

well......there are a few tiny systems that use .run() in my projects. but literally only systems that update meshes

#

and only the setting of the new data is using .run()

#

but i mean i don't know your exact code / use case

river meteor
#

i'm watching the unity dots pong tutorial and they have a system that's taking the player input and modifying component data that gets passed to other jobs

#
Entities.ForEach((ref PaddleMovementData moveData, in PaddleInputData inputData) =>
{
    moveData.direction = 0;
    moveData.direction += Input.GetKey(inputData.upKey) ? 1 : 0;
    moveData.direction -= Input.GetKey(inputData.downKey) ? 1 : 0;
}).Run();
#

i assume it's just for demonstration purposes. like you could have a regular script do this well enough i assume? but how would you add it to an entity

#

i do have a question about this though. since this tutorial is obv out of date, it was having me schedule this job with the inputDeps of OnUpdate as the passed in job handle. in this case is it correct to just put default instead?

#
protected override void OnUpdate()
{
    float deltaTime = Time.DeltaTime;
    float yBound = 3;

    JobHandle myJob = Entities.ForEach((ref Translation trans, in PaddleMovementData data) =>
    {
        trans.Value.y = math.clamp(trans.Value.y + (data.speed * data.direction * deltaTime), -yBound, yBound);

    }).Schedule(default);
}
#

i assume the dependencies are just a way to chain a sequence of jobs to avoid race conditions, so default would just be a way of saying "i don't care"

safe lintel
#

schedule using Dependency not default

river meteor
#

oh ok. that's just whatever the current dependency is for the system itself?

safe lintel
#

or in your code Schedule(myJob);

river meteor
#

you want the job to schedule itself as a dependency?

safe lintel
#

actually good point, generally I always go by Dependency = job.Schedule(Dependency)

#

but I dont think using default is correct, you can omit putting a jobhandle in the schedule but I think under the hood it just uses the system's Dependency handle

river meteor
#

oh i didn't realize

#

i thought i had a red line

#

i will leave it blank then unless it actually has a depenency

haughty rampart
river meteor
#

thank you =3

haughty rampart
#

also you don't need to save Entities.Foreach() into a jobhandle

river meteor
#

yeah i omitted that already

safe lintel
#

you definitely need to touch upon using Dependency in systembase at times

river meteor
#

BUT. if i were running like sequential jobs in a system, i would pass them ass dependencies to the scheduler in that instance right?

haughty rampart
#

no

#

just leave it blank

river meteor
#

then how would i ensure that jobs run sequentially?

haughty rampart
#

entities.foreach that come after a previous entities.foreach get passed the Dependency property automatically so that already ensures they run sequentially. you don't need to explicitly pass it

river meteor
#

is that in the documentation somewhere?

#

that's super cool if that's the case

haughty rampart
#

if you need to run a WHOLE system after another though, you need to add the [UpdateAfter()] attribute or [UpdateBefore()]

safe lintel
#

anyway i totally disagree with Mindstyler, you will definitely need to use it for any time you use EntityCommandBuffer's for example, need to pass in the jobhandle in AddJobHandleForProducer

haughty rampart
river meteor
#

so how would i allow jobs on entities to run non-concurrently?

#

if it's enforced by default

#

would i just need separate systems

#

non-concurrently per-entity i mean

haughty rampart
#

I'm not quite getting your question

river meteor
#

you're saying if i schedule two jobs in one system, they automatically set the dependency variable which means there's no possibility of race conditions

#

IF i wanted to allow them to run at fastest speed even in competition with one another, how would i do that

safe lintel
#

IF i wanted to allow them to run at fastest speed even in competition with one another what do you mean by this?

river meteor
#

so say i have one entity, it has two jobs to do. and i want them to finish as fast as possible. i want to schedule them both and say i have two threads available, I want both of those jobs to be able to run on those threads concurrently

#

would that require two systems, since it seems like scheduling them in one system automatically lists the previously scheduled job as a dependency

haughty rampart
#

some OOP principles still apply even with ecs. like the speration of concern. don't write monoliths in OOP and don't write monolithic systems in ECS that do more than one thing

river meteor
#

oh yeah i think that clicks. like if you had one struct that two jobs modified different aspects of, it probably makes more sense that that single struct should be two structs

woven arch
#

What's the status of DOTS at the moment? I haven't been keeping up with Unity for the past 2 years.

haughty rampart
woven arch
#

Okay. I wonder if it's ready for real projects yet, or if they expect a lot of breaking changes.

safe lintel
#

right now its the same as it was when you left it @woven arch

haughty rampart
#

there will be a few but not all that many

woven arch
#

Alright, thanks.

safe lintel
#

@river meteor for your question you dont need two systems, this is where you can just use dependencies explicitly

river meteor
#

i'm extra confused now

#

i would use dependencies explicitly to say they AREN'T dependent?

safe lintel
#

basically you want to parallelize two jobs for your scenario right?

haughty rampart
#

i would still highly encourage 2 systems

#

because logic wise that makes much more sense

safe lintel
#

not necessarily

river meteor
#

yeah that does make sense

safe lintel
#
    public class TestScheduleSystem : SystemBase
    {
        protected override void OnUpdate()
        {
            var up = new float3(0, 1, 0);
            var time = (float)Time.ElapsedTime;
            var deltaTime = Time.DeltaTime;
            Entities.WithName("RotateJob").ForEach((Entity entity, ref Rotation data) =>
            {
                data.Value = quaternion.EulerXYZ(data.Value.value.y, data.Value.value.x, data.Value.value.z);
            }).Schedule();
            
            Entities.WithName("TranslateJob").ForEach((Entity entity, ref Translation data) =>
            {
                data.Value += up * deltaTime * time;
            }).Schedule();
            
            
            var handle = Entities.WithName("RotateJob2").ForEach((Entity entity, ref Rotation data) =>
            {
                data.Value = quaternion.EulerXYZ(data.Value.value.y, data.Value.value.x, data.Value.value.z);
            }).Schedule(Dependency);
            
            var handleB = Entities.WithName("TranslateJob2").ForEach((Entity entity, ref Translation data) =>
            {
                data.Value += up * deltaTime * time;
            }).Schedule(Dependency);
            
            Dependency = JobHandle.CombineDependencies(handle, handleB);
        }
    }

first two will be scheduled one after another, but the second two wont be

coarse turtle
#

could just do 2 jobs, don't really see a need for another system 🀷 (but I guess ymmv with scale)

safe lintel
#

little hard to tell but the arrows show the job scheduling

river meteor
#

i see

#

so offset and rotate are two jobs in one system?

#

with no explicit dependencies?

safe lintel
#

if you have a another job that requires the output of both prior jobs, it can make sense to do this

river meteor
#

why

haughty rampart
#

no you'd use another system and [UpdateAfter]

river meteor
#

if the system sequentializes them

#

yeah that seems more clear

#

i do appreciate both explanations though because it shows the capabilities as well as best practice

haughty rampart
#

best practice that unity recommends is definitely multiple systems

safe lintel
#

for the most part if its unrelated id use different systems, but there are times when you dont want to

haughty rampart
#

yes there are times, but not that often. and he's just now learning dots.

river meteor
#

what are the use cases for creating explicit authoring components vs just using the attribute?

haughty rampart
#

e.g. if you have to do some conversions or calculations. [GenerateAuthoringComponent] pretty much just slaps the struct as is on the entity.

river meteor
#

oh gotcha

river meteor
#

watching another tutorial now, trying to learn about instantiating prefabs, is "ComponentSystem" another one of those types i shouldn't utilize?

river meteor
haughty rampart
haughty rampart
river meteor
#

oh ok

#

so when i use this code and try to use it to spawn a prefab that i have in a PrefabEntityComponent I created, i get an error:

protected override void OnUpdate()
{
    _spawnTimer -= Time.DeltaTime;
    if (_spawnTimer <= 0f)
    {
        _spawnTimer = 0.01f;
        Entities.ForEach((ref PrefabEntityComponent prefabEntityComponent) =>
        {
            Entity spawnedEntity = EntityManager.Instantiate(prefabEntityComponent.prefabEntity);
            EntityManager.SetComponentData(spawnedEntity,
                new Translation() { Value = new float3(_random.NextFloat(-5f, 5f), 10, _random.NextFloat(-5f, 5f)) });
        }).Schedule();
    }
}
#
EntitySpawnerSystem.cs(19,9): error DC0002: Entities.ForEach Lambda expression invokes 'get_EntityManager' on a EntitySpawnerSystem which is a reference type. This is only allowed with .WithoutBurst() and .Run().```
#

should i only be instantiating entities on the main thread?

#

oh thank god. found a recent tutorial that mentions entity creation has to happen on the main thread and that's what you were talking about before with entity command buffers?

#

thank you guys for all the help btw! I really appreciate the instantaneous feedback

safe lintel
#

yeah ecb's defer all commands until the system you create them from plays them back, the entities docs is pretty good at explaining their usage

river meteor
#

is there good boilerplate out there for say, spawning X prefabs at a button press?

safe lintel
#

assuming you figured out the code above, not much more to it

river meteor
#

oh ok perfect

frail hare
#

Hello, I'm using Entity Component System (if wrong channel I can relocate this, DOTS seemed closest to ECS) and setting up a character with a HitCollision component added to it, but I'm getting this error still. Something isn't recognizing the component I'm adding to the character, but I'm not sure where the disconnect is as it matches the other pre-made character with the same components. I have the error attached if anyone knows where to look or any advice for it

river meteor
haughty rampart
#

you have to zoom in

frail hare
# frail hare Hello, I'm using Entity Component System (if wrong channel I can relocate this, ...

It looks like a simple fix to just add the component it refers to, but it's already there. The HitCollision component is there as well as the collision data prefab that it references. The model has different versions of itself, one of which is dedicated as the HitCollision version where each limb has its own capsule collider then it's plugged into the main character; this is the prefab that is being called that is not being recognized where this error comes from. Because it's setup and applied though, i'm not sure where the disconnect is

river meteor
#

say i want to just be spawning a bunch of capsules consecutively with ECS, what's a reasonable number?

#

I thought it was going to be like tens of thousands before i got sub 60 fps but it's like 1.5k-2k

#

they're just capsules with physics bodies on them

rustic rain
remote crater
#

Turns out leading the target is challenging in DOTS/ECS: https://youtu.be/Zjy9tTX8AVc

So it turns out it is challenging to aim at where you're going and not where you're at with Quaternions and DOTS/ECS but I managed.

Algorithm:

  1. Get time of travel of projectile towards current position.

  2. Extrapolate your target's travel over that time.

  3. Optional recalculate time of flight of projectile and repeat 2 a few steps, but no...

β–Ά Play video
rustic rain
#

leading the target? you mean shooting at crosshair?

rustic rain
#

Is there a job type to go through all instances of SharedComponentData?

#

So instead of going through entities

#

that have this type of component

#

I go through each chunk of that component data

#

for each unique instance that have entities let's say

rotund token
#

thats just how IJobEntityBatch works by default

#

it gives you each chunk

#

it's up to you to iterate each entity

rustic rain
#

I'm just trying to figure out here how to do instanced drawing

#

so far each material aka ISharedComponent

#

requires different DrawInstanced call

#

thus different batch

#

hmmm

#

how do I declare what chunks to process tho?

#

oh I see

#

query

#

wait a second, that's not it

#

it's going through batches of component

#

but how do I know those batches are for separate materials?

#

oh well

#

getting sharedcomponent data require entity manager

#

does it mean, no burst/parallel?

rustic rain
#

ok, weird stuff

#

I'm not certain, why this job is called not in main thread?

#

well

#

I added System.Threading.Thread.CurrentThread.ManagedThreadId

#

in Debug log

#

and they are same

#

in both job and OnUpdate()

#

looks like main thread is long gone in systems xD

#

that's sad ngl

haughty rampart
rustic rain
#

is LocalToWorld component a matrix4x4 that is ready to get drawn (Besides potentially wrong scaling)?

rustic rain
#

and it errors me saying I'm not on main thread

#

and since index is 1

#

not 0

#

I assume that's true

#

ooor

haughty rampart
#

hmmm. i'll look into that

rustic rain
#

that just means material was created on another thread

haughty rampart
rustic rain
#

which was the case for me some time ago

haughty rampart
#

i see. well i'm not too sure what is and isn't happening here unfortunately.

rustic rain
#

it's fine

#

not that it's very important

#

just helpful to know

haughty rampart
#

i do know however that you can simplyfy the job initialization and VS also tells you to XD

rustic rain
#

ugh, I need to process each shared component separately

#

as those are different materials and I only need to draw them once

haughty rampart
#

also, you'll probably get stuck at some point if you pass the entity manager around. rather use ecb's

rustic rain
#

as for now I'm simply trying to make proof of concept

#

as in make it work one way or another

#

then I will get to making it run nicer

#

is there an easy conversion between native array and normal array?

#

oh yeah, there is

coarse turtle
#

if you're okay with getting a pointer to the normal array you can feed the data from there to the native array

rustic rain
#

I just need arrays for Graphics API

coarse turtle
#

NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <- the API to do it

rustic rain
#

doubt it knows how to work with native enumerables

coarse turtle
#
fixed (void* ptr = managed_array)
{
  m_Native = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>(ptr, managed_array.Length, Allocator.None);
}
#

something like this

#

might need to set up some atomic safety handles i forget if unity will complain if the native array doesn't have it in the editor

rustic rain
#

Is there a way to let job structs contain reference types?

#
    public struct SpritesheetAnimationJob : IJobEntityBatch
    {
        [ReadOnly] public ComponentTypeHandle<LocalToWorld> matrixHandle;
        [ReadOnly] public ComponentTypeHandle<AnimatorSpritesheetComponent> animatorHandle;
        [ReadOnly] public SharedComponentTypeHandle<AnimatedSpritesheet> spriteSheetHandle;
        public EntityManager entityManager;
        public Mesh mesh;
        public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
        {
            var matrices = batchInChunk.GetNativeArray(matrixHandle);
            var animators = batchInChunk.GetNativeArray(animatorHandle);
            var spriteSheet = batchInChunk.GetSharedComponentData(spriteSheetHandle, entityManager);

            MaterialPropertyBlock mtb = new MaterialPropertyBlock();
            float[] indexes = new float[matrices.Length];
            Matrix4x4[] matrixArray = new Matrix4x4[matrices.Length];
            for (int i = 0; i < matrices.Length; i++)
            {
                indexes[i] = animators[i].currentIndex;
                matrixArray[i] = matrices[i].Value;
            }
            mtb.SetFloatArray("_CutData", indexes);
            Graphics.DrawMeshInstanced(mesh, 0, spriteSheet.material, matrixArray, matrices.Length, mtb);
        }
    }

Here the job I'm trying to run

river meteor
rustic rain
#

so what prefab looks like?

river meteor
#

just a capsule with these components

rustic rain
#

why shape and collider together?

#

use one or another

river meteor
#

didn't even notice that tbh. remove

rustic rain
#

I wonder if you had 2 colliders on every entitiy xD

river meteor
#

but even that would reduce the efficiency by half, not by a factor of 100 or 1000

#

i should be able to spawn hundreds of thousands no?

rustic rain
#

why do you think by half

#

what if having 2 colliders

#

creates a huge loop of collision events

#

that all other systems have to go through

river meteor
#

oh true

#

and if they're all close oct tree optimization won't matter

rustic rain
#

I still wonder

#

if it actually does it

river meteor
#

2500 works

#

lets try 25k

deft stump
river meteor
#

he's talking about adding a capsule collider and a physics shape

rustic rain
#

he had both

river meteor
#

which i did on accident

rustic rain
#

I really have no idea how it'll behave

#

kek

river meteor
#

so it's better

#

but nowhere near dots-tier

rustic rain
#

what is your bottleneck?

#

renderer or cpu?

river meteor
rustic rain
#

sorry I have no idea how profiler works in unity

#

I just mean

#

if it's renderer

#

that might mean your batcher is not working

river meteor
#

which is confirmed and fixed how? o.o

rustic rain
#

it's just checkboxes to check

#

SPR batcher

#

and that you are using V2

#

hybrid renderer

river meteor
#

i am using v2

rustic rain
#

btw, just try to remove renderer component

river meteor
rustic rain
#

and see if unrendered entities eat as much

river meteor
#

where is the spr batcher checkpoint

#

its checked off

rustic rain
#

supposed to be checked on

#

for hybrid renderer

river meteor
#

.__.

rustic rain
#

as far as I remember

river meteor
#

it contains a check mark inside the box that is used for check marks

#

yeah i'm not sure

#

is there anything in my actual logic that would incorrectly set up the spawning?

#

i don't think my project is configured poorly

coarse turtle
#

is leak detection turn on fully? πŸ€”

river meteor
#

how do i check to see if i turned leak detection on fully

rustic rain
rustic rain
river meteor
#

just set to on

rustic rain
#

ArgumentException: DrawSpritesheetsSystem+SpritesheetAnimationJob+JobResult used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer

        public struct JobResult
        {
            public Matrix4x4[] matrices;
            public float[] indices;
            public AnimatedSpritesheet spritesheet;
        }

hmmm

#

I can't do that?

coarse turtle
#

yea just convert it to a native array

rustic rain
#

I tried to create nativelist

river meteor
#

okay so i "just went and did that"but i don't really have any kind of illumination as to what's eating my performance

coarse turtle
river meteor
#

these are what the jobs look like during that frame. but idk if that's bad or what

rustic rain
#

When I convert from native array to normal array

#

can I dispose native array

#

?

#

and expect normal array to work ofc

#
        public struct JobResult
        {
            public NativeArray<Matrix4x4> matrices;
            public NativeArray<float> indices;
            //public AnimatedSpritesheet spritesheet;
        }

still same error

#
        NativeList<SpritesheetAnimationJob.JobResult> jobResults = new NativeList<SpritesheetAnimationJob.JobResult>(Allocator.Temp);
#

stacktrace points to this line

#

obResult used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer

#

oh

#

well

#

I can't have native containers inside of other native containers

#

bruh

river meteor
#

does anyone have any idea?

#

i can't see any problems or how to correct them with the profile data

#

i don't know what i'm looking for. i'm new to dots. i don't even know if i set up my scripts properly

rustic rain
#

i don't know what i'm looking for.
if you don't, how can we know?

river meteor
#

???

#

i mean you told me to look where it's running hot. i am looking right at it. posted ap ic

#

and i don't have any leads to how to fix it

#

my project is very simple. i posted the entirety of the code

#

i would think people in the dots channel would have insight as to why spawning items in dots wouldn't be performant. i don't see how that's unreasonable lol

rustic rain
#

Well, do you know what perfomance you are supposed to see tho?

#

besides, you probably test it with debugging and all other overhead of editor

#

which on my end usually eats about 250% of whole perfomance xD

#

basically, 150 fps in editor, 500 in build

river meteor
#

well i have 10fps

#

when spawning 10k entities

#

i was told i should be able to spawn hundreds of thousands

rustic rain
#

not just like that

#

kek

river meteor
#

what do you mean not just like that?

rustic rain
#

Let's spawn 100,000 Animated Sprites in Unity ECS!
βœ… Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=t1f8ZreCuuQ

We're using Graphics.DrawMeshInstanced(); in order to draw all of our Units.
Doing it this way we can massively benefit from the Job System to create various jobs to prepare the data before doing just ...

β–Ά Play video
#

it's not just, go and spawn and expect everything to be perfomant

river meteor
#

i mean, that's why i posted my code

rustic rain
#

it takes special techniques which dots makes possible

river meteor
#

right

#

so my original question was

#

i was curious how to modify my code to have performant spawning

rustic rain
#

spawning?

#

you shouldn't care about that imo

river meteor
#

are you fucking with me

rustic rain
#

you do that only during certain events

#

not every frame

river meteor
#

the frames suffer after the spawning too

#

i'm using common language

rustic rain
#

then it's not spawning that is to blame, but keeping those entities

river meteor
#

i didn't think i'd have to elaborate "i want performant spawning and continual performance while those spawned objects live"

#

you're being needlessly pedantic

#

we both know what i'm saying and you're being difficult in a way that doesn't help me

rustic rain
#

Sorry, not my intent

#

but regarding your question

river meteor
#

to be clear

rustic rain
#

take a look at vid I sent

river meteor
#

i want to spawn a lot of shit, and have my games frames not drop to 5

rustic rain
#

just as example

#

of how it was done

#

to make it possible

river meteor
#

thank you for the link

rustic rain
#

by itself renderer in dots is meh

river meteor
#

i'll watch it

rustic rain
#

since it keeps actual GO

#

to draw stuff lol

#

you can either make your own (which is AAA kind of stuff for 3D)

#

or just make a compromises

river meteor
#

if it's more reasonable to do it as a 2d game that's fine by me. i was only going to enable planar movement anyway

rustic rain
#

just a reminder, dots is pre alpha or smth

#

you can't expect it to have stuff ready to work

#

you have to make most of them yourself

#

I got burnt out by how complex it is to work with 3d

#

so I switched to 2D for now xD

river meteor
#

makes sense

#

i'm gonna look at that unity GDC talk where they did the demo of the spray fire thing

#

see if i can find code for it, or see enough to copy

rustic rain
#

What are my options if I want to get List of arrays from job?
In my case I need to get arrays per batch

#

I don't know total size of each array

#

so I can't make it all big array

#

But I do know total size of that big array

#

hmm

pliant pike
#

I don't suppose anyone knows if FixedLists work to store entity's I saw some conflicting info on the forum saying the references can change?

bitter imp
#

hello

#

how are you

deft stump
#

hrmmm I wonder if I can use ECS for the structure rather than the speed boost

rustic rain
#

yyyep

deft stump
rustic rain
#

I work with 2021

deft stump
#

really

rustic rain
#

and use most packages kek

deft stump
#

I'll test it out

rustic rain
#

tertle also uses 2021 no prob

deft stump
#

do I still need to convert my GOs into Entities?

#

or can I do some finagling to expose the GOs to SystemBase?

rustic rain
#

if you want to use ecs only for entities as data structure

#

why do you need go at all?

#

well, you can, but you'll have to do your own bookkeeping

#

and it won't be as perfomant

deft stump
#

hrmmm

rustic rain
#

whole point is that all entities are nicely aliagned as arrays in memory

#

GO aren't

deft stump
#

I know about that.

#

I just like the structure of the code

rustic rain
#

oh well

#

you can do that just

#

you won't have GameObjects.ForEach kek

#

will have to keep your own lists of game objects

deft stump
#

I'm sure I can probably make own filterer

deft stump
#

does it build?

rustic rain
#

last time I tried

#

it did

#

all was good

deft stump
#

and does it run?

rustic rain
#

I switched between different scenes even

deft stump
#

gotcha gotcha

rustic rain
#

aka main menu <-> sample scene

safe lintel
#

@deft stump you can either use companion gameobjects or explicitly use AddComponentObject(gameObject/transform/yourClassType) for using gameobjects in systems in foreach on the mainthread

rustic rain
#

All right, soooo...
IS there any way to make this legal?

public struct SpritesheetAnimationJob : IJobEntityBatch
    {
        public struct JobResult
        {
            public Matrix4x4[] matrices;
            public float[] indices;
            public AnimatedSpritesheet spritesheet;
        }
        [ReadOnly] public ComponentTypeHandle<LocalToWorld> matrixHandle;
        [ReadOnly] public ComponentTypeHandle<AnimatorSpritesheetComponent> animatorHandle;
        [ReadOnly] public SharedComponentTypeHandle<AnimatedSpritesheet> spriteSheetHandle;
        public EntityManager entityManager;
 
        public NativeList<JobResult> results;
        public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
        {
            var matrices = batchInChunk.GetNativeArray(matrixHandle);
            var animators = batchInChunk.GetNativeArray(animatorHandle);
            var spriteSheet = batchInChunk.GetSharedComponentData(spriteSheetHandle, entityManager);
 
            float[] indexes = new float[matrices.Length];
            Matrix4x4[] matrixArray = new Matrix4x4[matrices.Length];
            for (int i = 0; i < matrices.Length; i++)
            {
                indexes[i] = animators[i].currentIndex;
                matrixArray[i] = matrices[i].Value;
            }
            results.Add(new JobResult
            {
                matrices = matrixArray,
                indices = indexes,
                spritesheet = spriteSheet,
            });
        }
    }
#

AnimatedSpritesheet contains only one field with reference type Material

pliant pike
#

or you could just use a crazy way where I sync gameobjects with entity's using the gameobjects GUID leahS

safe lintel
#

@rustic rain you cant use the EntityManager or SharedComponentData inside of jobs, and tbh not really sure how unity likes running the job from .Run with those things. probably easier just to do it on the mainthread

rustic rain
#

that's not the question

#

the biggest question is that every field in JobResult is illegal

#

and throws error

#

upon trying to allocate NativeList<JobResult>

deft stump
safe lintel
#

@rustic rain oh I see cant have managed arrays inside of nativearrays

rustic rain
rustic rain
#

can't have native containers inside of native container

safe lintel
#

yep so gotta do something else πŸ™‚

rustic rain
#

hell, I'll be ready to run this job without burst on main thread

#

just to make it work

safe lintel
#

@deft stump ConvertAndInject doesnt destroy gameobjects

rustic rain
#

but so far I don't see any other way to get individual batches per ISharedComponent unique component

deft stump
#

do I still need Hybrid renderer?

rustic rain
#

no

#

you get to choose whatever you want to render stuff

#

like keeping original game objects

#

and render through them

safe lintel
#

if you use entities with rendermeshes you need the hybridrenderer

#

tbh ConvertAndInject isnt necessarily guarenteed to exist in 0.50 or 1.0 so I wouldnt really plan on making anything super integral based on that workflow. no idea what unity plans for its replacement but its been brought up before that they dont view it as a long term workflow

rustic rain
#

I would hate if they remove it

#

without putting a better alternative

#

keeping hybrid workflow is impossible without them

#

ok I got response I know nothing about

1) FixedLists
2) NativeStream
3) Unsafe containers
4) An int2 representing a range of array values for a particular batch
5) Dynamic buffers on batch entities
#

xD

#

So FixedLists is kind of reasonable

#

but Unsafe containers?

#

NativeStream?

#
  1. is really meh