#archived-dots
1 messages Β· Page 248 of 1
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
graph as in nav mesh or?
nah voronoi
world is procedurally generated using a voronoi diagram as the root basis of room generation
ah i see
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
do you find il2cpp faster or is it for security or platform requirements?
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
yeah last time i tried il2cpp it wouldn't run but that was a while ago
usually just means something is stripping
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
i would kill for the old quake style game folder setup, just modify the raw files for the most part to edit assets
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
how so? i looked at my built dll and the systems stuff is just a mess and impossible to edit/recompile
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
that's a good point yeah
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
im trying to do this kind of thing with miniaudio + unity and make it work with dots π¦
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
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
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
no i don't no i've neglected to use them so far
by default unity updates LocalToWorld for you
[WriteGroup(typeof(LocalToWorld))]
[WriteGroup(typeof(LocalToParent))]
public struct Translation : IComponentData```
but it's setup as a writegroup
right
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
so how does it prioritise which write group to use?
@coarse turtle are you also working on nimgui?
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
haha yeah i did try, and thought 'ill come back to this'
but it is the ideal tool for writing extendable code/libaries
interesting yeah, will def have that in mind
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
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
i'm surprised out how well some people modded our game with il2cpp
without any support
had half a dozen up within a week
so many games where mods have literally kept the games relevant, where otherwise they might not have
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
yeah i mean it's possible.. replacing content is fairly easy.. changing values is often doable.. functionality changes are extremely hard tho but i think there are tools becoming available that try and help with that
the thing is, even with mono nearly all your game logic is in burst
it's pretty hard to mod
that's true, for burst enabled games yeah π
well we are talking about modding in the dots channel
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
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
yea
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
looking forward to when it gets released π
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
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
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 π€
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/ π
yea I definitely get it lol. I might just leave the subpass thing as is and wrap up the release haha. Something I want to tackle next is a custom command buffer so you can record info on a job and then render it out to a pane
Can anyone recommend a DOTS tutorial for someone who can just about tread water with standard Unity?
@proud lotus
I recommend this as a first,
https://www.youtube.com/c/WilmerLinGASchool
for a bit more advanced.
https://www.youtube.com/c/TurboMakesGames
talks to better organize data:
https://www.youtube.com/watch?v=WDIkqP4JbkE
https://www.youtube.com/watch?v=rX0ItVEVjHc
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
all right, I'm done with entities for now xD
Will limit myself to Jobs as for now
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
entities groups data for you conveniently π
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...
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
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
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);
}
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;
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
that's false you can use jobs outside of UECS
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?
yes
only delegates can be burst compiled?
yes
[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
you only benefit from burst if your code is "SIMD-able".
from what I see, that's going to be completely scalar, I believe.
here's a vid from unity on how to develop a smell test.
https://www.youtube.com/watch?v=BpwvXkoFcp8
One Loan Coder dives deep into SIMD.
https://www.youtube.com/watch?v=x9Scb5Mku1g
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 π
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 π€
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
yeah some kind of Gantt chart including relationship constraints (like start-to-start, finish-to-start, and so on) would be helpful for complex architectures. π
even more helpful because immediately actionable, thanks for sharing π
I don't suppose anyone knows why we cant get DynamicBuffers in EntityQuerys? π
Works for me
really I use tocomponentdataarray and I just get an error π
Oh I use a chunk job
yeah I need to get one in a query outside a job
With a ForEach you could
You mean then pass them into a native array, because I've done that before
Just wish there was an easier way
yeah, could also toentityarray and loop + getbuffer from there, but that's a lot of non-linear lookups
Yeah not efficient, I might not use buffers at all π€
are there even any options besides buffers tho?
I might try another component with a unique id to identify the parent
If youre not planning on storing a lot maybe a fixed struct/fixed list?
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
Not a lot, but wouldn't I still have to get that in an inefficient way?
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
It should be fine I've done it before, that's why they have the persistent allocator after all
Probably, I didn't read the full context so I thought you wanted to keep in ctx of ToComponentDataArray
how do you handle the size change?
do you not resize it? and just reuse indices?
I think I use a combination of clearing the list and reusing indices
or did I remove empty indices that were at the endπ€
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
};
}
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
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
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?
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
just to be sure, there's no 2D DOTS phsyics yet right?
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
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
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#?
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β).
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?
it's a unity only thing
in itself, no. The group will effectively become a sync point if one of these systems do a structural change.
other than that a group is just a convenient way to ... group systems together
any idea on how to launch unity samples?
I donwloaded exact version of editor
it required
yeah make sure yo uuse same version as them
started sample
ah
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
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 ^^
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
Unity provides some default conversion for legacy components
I would need to check, didn't have the chance to before π€
I mean, yeah it converts
but how does it get different collision filters
if it's not defined anywhere
I assume they at least init with CollisionFilter.Default maybe
aaah found it with a quick search π
??
so, how does it get it?
from the gameobject layers
nah i asume the helper method checks layer matrix from settings
so its cehcked 1 on 1
hence the loop I assume
but, collideswith on my 2 entities is different
don't take anything I say for granted, I'm just discovering it right here right now with you :p
well it's a bitmask right ? So would need to be built upon the exact same combination of layers to be exactly the same
nah according to my screenshot it loops over every layer from the legacy collision matrix (https://docs.unity3d.com/Manual/LayerBasedCollision.html). And if they can collide, it adds the layer to the bitmask
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"
yes, that's the layer collision matrix
in project settings
ok my bad assumed you knew that
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
you assume everything but depends on the collision filter. Did you check what it ?
THis looks like player specific yeah, so I assume there's another code for other collisions
here missile hit system
But not sure I understand what you're looking for
it only checks whether it collides or not
not checking if it's collides with smth it wants
It probably has a bit operation inside the OverlapCollider method.
to filter out the hits
oh yeah so some kind of Asteroids game. Yeah in this kind of games any hit is instant death usually π
yeah, based on filter of collider
which is not defined at all
it seems
It retrieves it from the Collider blob itself
yeah, and I read those values through debug
so we're back to where we were with conversion for legacy components, or from the new Physics components if exist
ok so still confused why values would differ ?
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
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
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
yea downgrade to the version of collections that is supported by entities
1.1.0 release isn't compatible yet
collections must 0.15
thank you ^_^
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
Whatβs going on here?
are you using blob builder to build your blob struct?
would recommend looking at the BlobificationTests in the Unity.Entities package for reference
i feel like installation order is such a puzzle box for these packages 
so i'm not having the collections issue anymore but now i have this
nvm disregard. had to reboot after reinstalling burst
Which layers are involved in the CollisionFilter ? Filter = collider.Collider.Value.Filter
it's fine, I figured how to assign layers
but it can be done only through Unity project settings
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
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
yeah that's the way for now. Can also cache physics shapes and swap them at runtime if you prefer
:p
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 π
actually the reason I decided to bail on 3d is because hybrid workflow is painful
yeah sure more than we would like π
does anyone have a good holistic intro to dots tutorial they generally recommend?
i cannot find moetsi on youtube
it's text guide
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
Skyrbunny does not understand Blobs
Is it a specific package that makes building normally (through File menu) impossible? Anyone knows?
subsystems subscenes don't build if you use the regular file/build menu
all right, that's fine for now
I don't use them at this point at all xD
maybe I should
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
Do you have any idea about how unity manages resources with subscenes?
I'm thinking of using subscene to quick reset level
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
subscenes are just a giant chunk of binary data, it's very fast to load/unload
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
from memory, every entity from a subscene has a component that links it to the specific subscene
since they create LTW components
cant remember the name, cooking dinner otherwise i'd look it up
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
you can control exactly what gets converted
also there's a top conversion component
that will stop any child from this point on converting
I want vice versa, convert children
not parent
kind of like this
I don't want Ground to be entity
only Ground Close
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?
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
are you changing the 'ground' or just the 'ground close', 'ground close (1)' etc?
what GroupIndex stands for in collision filters?
so what's the problem then?
if you only change the children and never the parent it works as is, like it doesn't have a parent
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
i'd argue you should always rely on ltw for world space
does LTW exist on everything tho?
should be on anything that has a translation, rotation or scale as unity adds it
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
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
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)
unity doubled down on a hybrid approach for 0.50 and 1.0 release. they might be considering pure dots in the future, but not in the foreseeable future
to a certain degree you cant escape "hybrid" but what that means for each 3rd party tutorial probably varies
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
then you should prob wait for unity to release their sample projects. which they will after 1.0 released
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
there's 2d physics package
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
well i'm not waiting lol. i meant the most standard as of now
getting started on a project that's going to rely on ECS
@rustic rain oh, project tiny?
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
Entities2D?
so it's kind of easy to use if you have experience with 3d physics package
no
physics
I use normal 3d entities
oh
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
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
alternatively, go the tinker around route (but this takes a lot of time)
Reusing this answer from before
I recommend this as a first,
https://www.youtube.com/c/WilmerLinGASchool
for a bit more advanced.
https://www.youtube.com/c/TurboMakesGames
talks to better organize data:
https://www.youtube.com/watch?v=WDIkqP4JbkE
https://www.youtube.com/watch?v=rX0ItVEVjHc
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
no
using (NativeArray<Entity> bullets = new NativeArray<Entity>(totalAmount, Allocator.Temp))
{
// bullet logic here
}
oh rip, that'd be handy
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
oh i didn't realize that
also it's actually something you wouldn't want to use in DOTS anyway because dots is performance oriented
and using is pretty much just fancy for putting try finally around your code
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
why don't you just use a plane and render your sprite on that quad with 3d
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
i just store them in managed component data
and then?
for sprite sheet animation, SpriteRenderer2D regenerates the vertices iirc
make a flipbook shader and apply it to the quad
flipboard shader?
if your sprite is all the same size per tile, then you can just generate a regular quad and shift the uvs
which is what MindStyler is pretty much saying with the flipbook shader
and picks correct sprite from texture?
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
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
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
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
yea i have something similar
so you do all your work in shader?
index of current sprite to use?
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
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
@river meteor if you use the Temp allocation inside a job you dont need to dispose it, its done automatically
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?
Should be equitable with itself
<AnimatedSpriteSheet>
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
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?
i think two possibilities:
1 - You don't have Hybrid renderer installed
2 - The object uses skinned mesh renderer or some other component which doesn't convert easily
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
jobcomponentsystem is looooooooong deprecated
fudge
oh ok
so systembase is the correct implementation? and i just don't bother returning the handle?
yes. system base is the ONLY correct class.
in a newer version you can also use ISystem then
oh, makes sense. so you can create your own system heirarchy with base implementations, and systems only require OnUpdate to be defined anyway
no. ISystem will let you burst the system code itself
ohhhhhhh
do you need [AlwaysSynchronizeSystem] for any system that is going to operate on player input?
or any main thread dependency
no. i never use alwayssynchronizesystem
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
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"
schedule using Dependency not default
oh ok. that's just whatever the current dependency is for the system itself?
or in your code Schedule(myJob);
you want the job to schedule itself as a dependency?
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
oh i didn't realize
i thought i had a red line
i will leave it blank then unless it actually has a depenency
do not put anything inside Schedule() when using SystemBase
thank you =3
also you don't need to save Entities.Foreach() into a jobhandle
yeah i omitted that already
you definitely need to touch upon using Dependency in systembase at times
BUT. if i were running like sequential jobs in a system, i would pass them ass dependencies to the scheduler in that instance right?
then how would i ensure that jobs run sequentially?
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
should be. i don't know the whole documentation by heart though
if you need to run a WHOLE system after another though, you need to add the [UpdateAfter()] attribute or [UpdateBefore()]
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
that is correct. but we were never talking about ECB's
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
I'm not quite getting your question
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
IF i wanted to allow them to run at fastest speed even in competition with one another what do you mean by this?
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
i mean of course you would use 2 different systems for that. because these 2 jobs stand in no correlation to one another
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
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
What's the status of DOTS at the moment? I haven't been keeping up with Unity for the past 2 years.
0.50 will be released in the next few weeks and 1.0 at the end of this year
Okay. I wonder if it's ready for real projects yet, or if they expect a lot of breaking changes.
right now its the same as it was when you left it @woven arch
there will be a few but not all that many
Alright, thanks.
@river meteor for your question you dont need two systems, this is where you can just use dependencies explicitly
i'm extra confused now
i would use dependencies explicitly to say they AREN'T dependent?
basically you want to parallelize two jobs for your scenario right?
i would still highly encourage 2 systems
because logic wise that makes much more sense
not necessarily
yeah that does make sense
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
could just do 2 jobs, don't really see a need for another system π€· (but I guess ymmv with scale)
little hard to tell but the arrows show the job scheduling
i see
so offset and rotate are two jobs in one system?
with no explicit dependencies?
if you have a another job that requires the output of both prior jobs, it can make sense to do this
why
no you'd use another system and [UpdateAfter]
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
best practice that unity recommends is definitely multiple systems
for the most part if its unrelated id use different systems, but there are times when you dont want to
yes there are times, but not that often. and he's just now learning dots.
what are the use cases for creating explicit authoring components vs just using the attribute?
e.g. if you have to do some conversions or calculations. [GenerateAuthoringComponent] pretty much just slaps the struct as is on the entity.
oh gotcha
watching another tutorial now, trying to learn about instantiating prefabs, is "ComponentSystem" another one of those types i shouldn't utilize?
is this in the entity debugger btw? i don't see that interface
component system is also loooong deprecated
no that's in the profiler
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
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
is there good boilerplate out there for say, spawning X prefabs at a button press?
assuming you figured out the code above, not much more to it
oh ok perfect
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
i don't see this interface in the profiler o.o
you have to zoom in
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
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
this is 1.5k. anything more than this tends to start showing problems
It's approach of handling those capsules that matters
In other words with dots power you should expect about hundreds of thousands of objects without problems, depending on what they do
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:
-
Get time of travel of projectile towards current position.
-
Extrapolate your target's travel over that time.
-
Optional recalculate time of flight of projectile and repeat 2 a few steps, but no...
leading the target? you mean shooting at crosshair?
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
thats just how IJobEntityBatch works by default
it gives you each chunk
it's up to you to iterate each entity
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?
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
wdym? if the job and OnUpdate() have the same thread id then the job runs on the main thread
is LocalToWorld component a matrix4x4 that is ready to get drawn (Besides potentially wrong scaling)?
yeah, but I can't acess any material property
and it errors me saying I'm not on main thread
and since index is 1
not 0
I assume that's true
ooor
hmmm. i'll look into that
that just means material was created on another thread
it is a matrix4x4 you can use
which was the case for me some time ago
i see. well i'm not too sure what is and isn't happening here unfortunately.
i do know however that you can simplyfy the job initialization and VS also tells you to XD
ugh, I need to process each shared component separately
as those are different materials and I only need to draw them once
also, you'll probably get stuck at some point if you pass the entity manager around. rather use ecb's
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
if you're okay with getting a pointer to the normal array you can feed the data from there to the native array
I just need arrays for Graphics API
NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <- the API to do it
doubt it knows how to work with native enumerables
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
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
this is the system and component I have set up for my spawning system. If I go over 1500 the frames start to get sub 60. could someone help me figure out what i might be doing wrong?
https://paste.myst.rs/a5cwsw0b
so what prefab looks like?
just a capsule with these components
didn't even notice that tbh. remove
I wonder if you had 2 colliders on every entitiy xD
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?
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
????
What?
Last i check convert to entity is able to convert Mono colliders to Physics shape
he's talking about adding a capsule collider and a physics shape
he had both
which i did on accident
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
which is confirmed and fixed how? o.o
it's just checkboxes to check
SPR batcher
and that you are using V2
hybrid renderer
i am using v2
btw, just try to remove renderer component
and see if unrendered entities eat as much
.__.
as far as I remember
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
is leak detection turn on fully? π€
how do i check to see if i turned leak detection on fully
just go and look what is eating your perfomance
jobs tab on top of unity window
just set to on
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?
yea just convert it to a native array
I tried to create nativelist
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
you can alias an array to a native array - like this
these are what the jobs look like during that frame. but idk if that's bad or what
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
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
i don't know what i'm looking for.
if you don't, how can we know?
???
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
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
well i have 10fps
when spawning 10k entities
i was told i should be able to spawn hundreds of thousands
what do you mean not just like that?
https://youtu.be/t1f8ZreCuuQ?list=PLzDRvYVwl53s40yP5RQXitbT--IRcHqba
You can take a look how code monkey does it
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 ...
it's not just, go and spawn and expect everything to be perfomant
i mean, that's why i posted my code
it takes special techniques which dots makes possible
right
so my original question was
i was curious how to modify my code to have performant spawning
are you fucking with me
then it's not spawning that is to blame, but keeping those entities
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
to be clear
take a look at vid I sent
i want to spawn a lot of shit, and have my games frames not drop to 5
thank you for the link
by itself renderer in dots is meh
i'll watch it
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
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
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
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
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
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?
hrmmm I wonder if I can use ECS for the structure rather than the speed boost
yyyep
would I still need 2020 LTS for that?
I work with 2021
really
and use most packages kek
I'll test it out
tertle also uses 2021 no prob
do I still need to convert my GOs into Entities?
or can I do some finagling to expose the GOs to SystemBase?
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
hrmmm
oh well
you can do that just
you won't have GameObjects.ForEach kek
will have to keep your own lists of game objects
I'm sure I can probably make own filterer
and does it run?
I switched between different scenes even
gotcha gotcha
aka main menu <-> sample scene
@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
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
or you could just use a crazy way where I sync gameobjects with entity's using the gameobjects GUID 
@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
I do can use EntityManager kek, idk why but it's required parameter of GetSharedComponentData
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>
I can't remember hows those work
but afaik, that would still destroy the GOs from the heirarchy right?
@rustic rain oh I see cant have managed arrays inside of nativearrays
you don't have to destroy them, if you use component convert to entity, instead of putting them in subscene
same thing for NativeArrays
can't have native containers inside of native container
yep so gotta do something else π
hell, I'll be ready to run this job without burst on main thread
just to make it work
@deft stump ConvertAndInject doesnt destroy gameobjects
but so far I don't see any other way to get individual batches per ISharedComponent unique component
do I still need Hybrid renderer?
no
you get to choose whatever you want to render stuff
like keeping original game objects
and render through them
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
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?
- is really meh
