#archived-dots
1 messages ยท Page 244 of 1
yes, i've implemented few before i've realised that NativeArray.Sort in single job is best, But when you have nested sprites all algorithms can't handle your new rules, because when element is a child, then we can't compare it with other elements, only with other children. This is because child should goes with parent and be sorted only with other children.
oh right I didn't think about children entities
yea probably limiting your sort space might be a good idea? It also sounds like your order value could be a key for radix sort, but I'm not really sure about the children entities rule ๐ค
i'm thinking about
0. sort by nesting level
- find where in array nesting level changes (depth groups)
- sort slice with 0 depth group
- starting from last depth group to 1 depth group -> sort by parent + position -> find all parents in previous depth group -> insert
2 and 3 can go in parallel until depth group 1 wants to be inserted to 0 group
but this algorithm sounds wild and still has all of this SORTINGS, still looks better then O(n^2) though
yes, culling helps, of course, but with my current approach even 500 sprites on screen is a hard work for CPU
are those same sprites?
no they can be any sprites with same material or not
I just wonder whether you actually need that sorting at all, what is the end goal you are trying to accomplish with it? So whatever entity is appears closer to camera?
in my system i have "RenderArchetype" with is Shader + Textures. I'm using GPU Instancing and after sorting find batch groups of spirtes which can be rendered together
Sprites are 2D entities, they have no depth like 3D objects, i need to manually sort them depending on theirs XY positions and other properties like (sort order + layer). The closest sprite to the camera is sprite with lower Y and greater X in my case.
greater X?
Is that 2D or?
yes, it is 2D
when we talking about 3D we have depth and can enable ZWrite On, then pixels with tested depth will be overdrawed afaik, so you just render your 3D objects in batches and that's all. But there is no depth in 2D, so we faced that kind of problems. If i'm totally wrong about those things, pls point me, because i'm new to all this stuff ๐
I worked with 2D, but it was actually in 3D, where X and Z were used for position, and Y to render queue
I accomplished rendering a lot of textures (about 40k) with indirect gpu instancing
but those textures were transparent, so I never really had problem with render order
they just kind of multiplied with each other
So you write render queue to Y depending on your X and Z value and then use it like depth?
Not really.
it was smth like this:
0 - terrain
0.01 - buildings
0.02 - items
0.03 - pawns
0.04 - gas
0.05 - weather
And etc...
layers were predetermined, everything else is figured by engine draw calls
ok, how you handle 100 items on screen, what item being rendered first?
that's actually impossible mechanically in that game xD
It can only happen for transparent objects basically
ok, imagine 100 characters which are moving up down left right on screen, how would you sort them?
depending on context, tbh
Is rendering has any gameplay value?
or you just want things to look good?
what you mean gameplay value?
well, is it relevant for gameplay? Or it's as important as background?
it is important for gameplay i guess
for gameplay I mean, if it's smth you must shoot, then it does have value
what happens rn tho? Without sorting, how does it look?
oh, ok, my game is something like tycoon games, so all player see have gameplay value
without sorting it is just mess, some sprites goes first, you can see that one character's feet is on face of another character
combination, that is why i need sorting groups
look and this example i've found in google, here is zombies with proper order rendering + they consist of parts of body
and here we see issues
are your character entities are groupped in any way?
if you can assign them to one Y altitude
all entities of character
it will stop mess
at least
mmm, yes
- they form hierarchy, like child-parent with Unity.Transforms
- each sprite entity has
public struct SortingGroup : IComponentData
{
public Entity parentID;
public int depth;
}
ooooh, if your body parts have any sort of "Parent" entity component
You can pretty much just use EntityID as Y axis
and it'll be cut down to just one query through all body parts
there is corner case when you have N (N > 1) characters staying on the same Y altitude
i'm sorry, can't figure out an idea
so, if you use GameObject prefab
then every child entity knows it's parent entity
they have this component
so you just query through all objects with that entity
and adjust their Y axis (or whatever render order you use) by for example:
EntityID*0.001;
ok, imagine two characters stays on same position float3.zero
each character has body, legs, arms and head
we want make legs/arms/head to be children of a body
then we adjust it's Y values to some small value
now they a little bit greater then parent, yes. But how they can be sorted between each other?
also there are legs/arms/head of the second character and they have the same Y adjusted values.
now we will have this picture: bodies of both characters being rendered first, then all other body parts of both characters. It is like with zombies case.
you adjust all children by same value of parentid
if you want to also adjust children between each other
you can create more queries
so it then goes through all legs
all bodies
all hands and etc
parentID is Entity.Index of parent it is random value in rendering context
yes, but randomness leads to mess, there will no proper order
and by what order you want them to be sorted?
we want body1 -> legs1 -> arms1 -> head1 -> body2 -> legs2 -> arms2 -> head2
if you want order between children - it's simple and precise
depending on bodies positions between each other
order between characters is not
that is i'm talking about ๐
by position on a screen
??? whoever closer to left side of screen is rendered first?
like on that screen
ah, well
then when you query through children
you need to know their parent's position
not sure if you can make such query in dots tho
it seems like it beats the idea
if you try to access parent's position
while working with children's position
maybe someone else knows a way tho
accessing to parent's position gives us nothing because we still need to sort them all together. we even can calculate parent's positions without access to his LTW, because we can just extract local position from world position
sorting is simple tho
if you know parent's position while accessing child
you once again, add some value based of X axis of position
in this case you don't even need entitiyID
it's just was ez way to access some unique per character data
I see some Burst changes in 2022.1.0b3
Burst: Added: Added support for DOTS Runtime running / loading .Net Core assemblies.
Burst: Added: Added support for System.Span and System.ReadOnlySpan within Bursted code. These types are not allowed as entry-point arguments.
Burst: Added: BurstAuthorizedExternalMethodAttribute is now used to mark external functions that are safe to call potentially multiple times from static constructors (pure functions, with no side effects).
but how to solve problem with characters with stays on same positions? all children will get the same parent's postition
you can keep a bit of randomness from entityID then
Ooooh so DOTS 1.0 is really on the horizon.
URP: Added: Added minimal picking support for DOTS 1.0 (on parity with Hybrid Renderer V2).
like shift parent and children a little bit by parent's Entity.index ?
like, biggest value of Y axis comes from X and Z math
while also adding some super small value from entityID
so in case
X and Z of other entity are exact same, your draw order is secured by entityID
yeap, but how to calculate this small value
just keep it very small
i mean 0.00001 * Entity.Index will grow with index
it's not really relevant
you can add additional math of keeping it always small
smth like
if (Index > 10000) index / 1000;
my brain gets heated. It is still requires sorting children between each other, so i need pack theirs local positions to that small adjustments
no it doesn't
just query through additional tags
which also will have some weight
eg:
leg 1
body 2
head 4
hands 3
it's basically a matter of keeping values intact
as you need to have this offset below 0.01
or maybe 0.05
to avoid any visible changes
for camera
what you mean by additional tags?
Component without values
oh, ok. So one tag for one kind of child?
it will stretch rendering system code to infinity
because different cases assumes different children set
1 query for tags (actually each query for each tag)
1 query for position based offset
characters wants body parts, dress, etc. Building wants parts
1 query for entityID query
question is how deep can you go without the rendering system go to infinity
well, you'll have tags for all your entities you want to draw
it's not like those tags can't be used for anything else
you can later use them for some kind of game logic
yeap, i'm more and more think that there is no perfect solution
1 tag for each child
you can have infinity body parts
it doesn't scale
so you'll be making infinity tag for infinity body parts
i mean for my own project, yes, i can predefine all kinds of children, but for other project ๐
that is assigned whenever you initialise this entity
idk why I didn't think of just offset comp in the first place
over engineering lmao
can't help myself being less close minded kek
basically idea of calculation universal sort value depending on position/parent position/parent id is good, but i still try to figure out how to avoid all issues
eventually some things are eyes opening anyway
hm
biggest work here would be figuring out numbers
imo
will require tests I guess
while the only issue I can see
is when both entities in same position
and their IDs overlap
smth like ID 1000 and ID 10000
but how often that would happen?
small adjustment leads to different entities on same world positions is not same more, and adjustment values is deterministic because of entity.index
children can calculate parent's positions and make own additional adjustment to goes after parent, but how to figure out proper adjustment to child be sorted with other children
and also be before next parent
offset tag
component with offset value?
but they can move
let's say, it's float from 0 to 1
any idea is there a way to duplicate what ConvertAndInjectGameObject does, but inside a custom IConvertGameObjectToEntity class?
all your body parts already know their "priority" for drawing
before game starts
you can always add more
and etc
mix them in any way between
in the end it'll be just 1 query that makes a small adjustment to Y axis
ie default IConvertGameObjectToEntity behavior is to destroy the game object without the option to inject etc
if you mean add mono components to entity, then you can use ConversionSystem.AddHybridComponent()
basically as i've added above, to actually Inject the game object rather than destroy
ok that will work, but there is no room for movable nested sprites. Like magic orbs floating behind character
why not?
just change this value from 0 to 1
like sine
foreach entity.WithAll<floatingOrbTag>(ref ChildDrawOffsetComponent offset).Run()
smth like this
I guess
i'm not sure what you mean, because injecting or destroying is controled by convert components, and IConvertGameObjectToEntity is activated by conversion system in any case
actually, you aren't even limited to 0 or 1
it's up to you what values to use
idea is same
ok thank you for ideas, i'll try to compile it in some solution ๐
I actually wonder if you can acess parent's comp in children
and how it'll affect perfomance
with 1 depth level it is simple as LocalToWorld.Position - LocalToObject.Position
btw, has anyone had an issue where Entities calling IsEmptyIgnoreFilter result into a null reference exception?
FAULTING_SOURCE_LINE: ..\Unity\cartediem\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.Entities5.cpp
FAULTING_SOURCE_FILE: ..\Unity\cartediem\Library\Bee\artifacts\WinPlayerBuildProgram\il2cppOutput\cpp\Unity.Entities5.cpp
FAULTING_SOURCE_LINE_NUMBER: 10675
SYMBOL_NAME: GameAssembly!EntityQueryImpl_get_IsEmptyIgnoreFilter_mC61848E0EE4543DE37D44F14346CC26454719F78+54
I'm looking at a dmp file in windbg to see if I can figure out which query is causing this in an IL2CPP build ๐ค
how do you create / enable a system you marked a with [DisableAutoCreation]
using World.GetOrCreateSystem() doesnt seem to create it
Any idea what is wrong? I simply loaded new scene aaaaand all materials are black (they should be white and red instead).
Even though in component it's visible as red
by loaded new scene I mean this
this.Q("button-newgame")?.RegisterCallback<ClickEvent>(StartNewGame);
private void StartNewGame(ClickEvent evt)
{
SceneManager.LoadScene(1);
}
Meanwhile if I load scene directly, not during runtime - it's all works as intended
Anyway to "FUSE" a gameobject into all its children so you can turn it into an Entity?
Another general and fun question: Lets say I have Entities with "Attractor Logic" Aka, if you're within X range, pick it up.
In Gameobject terms, I just did an update and searched for nearby objects every few frames.
I wonder if there is a better way of doing this using ECS/DOTS.
Ie, you're pacmanning dots
And if you're within X of the dot, it collects.
The way I'm thinking of doing this is making an Attractor SystemBase .foreach parallel
the IcomponentData will be AttractorData
prolly won't have much in it, more of a tag, but maybe could have a modifier to be collected further, say its a magnet itself
In the systembase I am thinking of looping through all entities, and each entity will need a counter
Cuz one of the best things you can do in ECS/DOTS is to not do mass AI calculations every frame
So in AttractorData I'll have an int called: CycleInt
on the .foreach it will add +1;
then if Cycleint> 7, then look for a collection
and set cycleint=0;
Also...
It will be good to randomize
Every cycle int
well only if spawned
I'm thinking I want the jobs to cycle evenly, not spike every 7 frames, but thats minor
I'll need to find a function or something to find entities nearby.
Typically this involves a 3d array of stuff nearby...
I wonder if Unity supplies such functionality for DOTS/ECS
I think that's my big question.
Can you find stuff close by in your sector on a fast scale, or do I have to roll my own 3d grid buffer system to know stuff in the general zone nearby?
Light is disabled ?
when light is enabled, it's still balck
just highlighted
spheres are fully white originally (standard material)
here how it looks when I load scene directly
Original post with details of this problem:
#archived-dots message
Oh great the unity example is in the boids example
I get a chance to recompile it
My youtube video doing 2.5 million boids got thousands of views...
But I never standaloned it for 10x as much processing...
That will create a system fine but it won't add it to the playerloop to update
how do you add it to the playerloop?
https://docs.unity3d.com/ScriptReference/LowLevel.PlayerLoop.html
That or from memory you can manually add it to a SystemGroup
thanks for the info, I'll have to look into it ๐
Trying to understand the order that the conversion system runs compared to the regular player loop.
Specifically I'm looking to initialize regular GO components in a script and ensure that they get converted.
Normally this works fine, but with prefabs it falls down.
take a look at this tutorial
high quality explanation
Thanks @rustic rain, moetsi tutorials are great.
I think I gave a shit explanation of my problem.
I essentially want to know what people do for the equivalent of the Awake function in DOTS.
Sometimes I will have a mono that will add components via script dynamically instead of statically.
This means the added components do not have any data assigned from the inspector, the data would all just be sitting in the mono fields so would need to be assigned, normally I do this in OnValidate, then I would then call that OnValidadate func again in Awake so it works for prefabs too.
In DOTS, you don't get Awake afaict, or at least it's unreliable.
Thinking it through, I think Awake essentially becomes the Convert function, does that sound right?
However, this is what gets me, I dont think you can add components during Convert
Try to stip thinking in OOP
Can you explain what you want to achieve gameplay wise?
You can addcomponents and data after you make em
It's not a gameplay thing, its purely an authoring workflow.
In this example I want to set the material to my mesh renderer before the prefab is spawned.
Material _material;
MeshRenderer _meshRenderer;
OnValidate()
{
_meshRenderer = AddComponent<MeshRenderer>();
_meshRenderer.hideFlags = HideFlags.HideInInspector;
Setup();
}
Setup()
{
_meshRenderer.material = _material;
}
Convert(Entity ent, EntityManager em, GOConversionSystem cs)
{
Setup();
}
The conversion process is fickle
Either it works before or after, get anything working
I have mine to slap on diff mesh and materials but I forget how
The thing with dots now, is it ain't always pretty
get it functional, get it optimized
Just assign component after instantiating entitiy
Listen to issue
I'm confused with this statement here ๐ค
Sometimes you cant even add components and stuff before conversion
Ah gameobject components
You want to convert once, and keep an entity around to clone
like object pool
If you messing around with game objects live en mass, you doing something horribly wrong
I don't really get what you want to achieve
Entities don't run code
Only systems do
He wants to slap gamedatacomponents on gameobjects before convert
I ran into th eissue too
its a mess, but thats fine, you shouldn't be doing that anyway
Thanks for the help guys ๐ I do really appreciate it
I keep all my "objectpool" entities in memory
with a disabled and disablerendering tag on them
They don't slow the system down, but make the entity debugger a bit crowded
Then when you entity e=instantiate it, then you can add to e.addcomponent
or ecb.addcomponent
either entity directly or entity command buffer if needed
I just realized, my game is almost ready to launch.
Tomorrow I'll launch and do the tutorial video
I wonder if my Unity Asset store application vetted
For what purpose?
I will make this sooooooooo Easy for everyone, even people with mature gameObject games
Issue, if you keep disabled and disable rendering on a zillion stuff spawned from your resources folder
you can immediately isntantiate off them like they're object pooled
its easy pz, and no GUI editor work.
Can you wait a day?
I have a million small tricks that all add up to a Smooth Design Patterns Architecture for DOTS
Well
Ok I'll walk you through this part
You know the resources folder is a special folder?
Let's assume I do xD
Its the one folder that allows you to load game objects from disk on the fly
so you don't need to drag em in a scene or something
Ah, I did it once
Unity says not to do it
Because they think people are morons
But no coder is a moron
Ha
People who make GUI IDES think no one should code stuff they can drag and drop
Anyway, you load up your gameobjects, then slap em in a buffer pool
Then you can use em anywhere
I need to cool down, get some sunlight before close
I'll do this tutorial, I told people for a year I'd do
I finally have a core, everything works
And everyone needs this.
I'll be back in an hour after cleaning shed, and then I'll do my absolute professional youtube + clean up code for this one.
I have people like Turbo Makes Games amazed at what I came up with.,
oops
If you understand this video, you do not need to make new games from scratch. You can simply use your gameobject games and entityfy new levels with em. I apologize for this video being extremely rambling on, but I was also doing some dev and I plan on getting you a great video soon, but to some, this will be a God send Holy Grail of Dots ECS ...
Not a lot of you will understand this, but this is how ANY GameObject video game can get DOTS ECS update levels.
Its rambly, bad production. I promise you guys, in an hour, I'll get it making sense, with tons of other big time methodology not being used, but should be industry standard.
In short, I'm going to make DOTS/ECS easy, but give me 8 hours to produce it.
People say you can't even make GameObject games into DOTS/ECS, you have to start from scratch. That is not true.
HUK
I want to make the chobo gosu
well discord bots killing my Korean whale face
\
\ ( ^ ________ ^ ) /
sposed to have more underlines
\ ( ^ _____ ______ _______ __ ___ ^ ) /
what the lol, those are all _
Discord made it into a creepy hockey veteran Korean whale
Thats a cursed whale
hhahaahh
i think you're forgetting about memory management here. you've just loaded all your assets in memory permanently without anyway to release them. this might work with a small game but it's not feasible for any asset heavy game.
Nah, you can load/unload em at will.
Initialization of gameobject can happen over and over.
This system is literally perfect.
Well for all my use cases and I am quite demanding.
My software architecture always demands the ability to build upon.
I think you'll be impressed my tertle bro, remember, you helped bring this to fruition.
You don't seem to understand how memory management works with asset bundles (resource folder is considered a single asset bundle)
Just destroying the asset from a resource folder is very unlikely to free any memory
I was under the impression, the resource folder was a disk hit.
This is the reason Unity tells you to avoid the Resource folder
Where's the one to load from disk then?
You can avoid that by not using the Resources folder, which makes detailed and controlled memory usage quite hard to achieve. It will be build into a single AssetBundle and then fully load the index into Memory. Assets loaded from it may remain in memory longer as needed in the scene and you have less control over when they get loaded in, as e.g. loading an object that references them will load them into memory. Instead, you can get more control by placing these assets in separate asset bundles.
The quick explanation of how asset bundles work.
- Lets say an asset bundle has 2 assets, A, B, C
- You load asset A, B
- You unload asset A. Both asset A, B will still be in memory
- You load asset C. A, B, C now in memory.
- You unload asset A, B. A, B, C now in memory.
- You unload asset C. All memory freed
I know of alternate ways of loading assets, but I always thought Unity was convoluted in not allowing us just to load from disk.
TLDR; all assets in a bundle need to be unloaded before memory is freed for the bundle
I definitely keep one copy of every asset in memory.
yeah so if you have 20GB of assets you now permanently have 20GB of memory used...
now imagine AAA games with 100GB+ assets
But you're saying like if I have a resources folder of 64gb, that even if I don't load anything, it will take up 64gb
The one exception is for the Resource folder which has this function
Resources.UnloadUnusedAssets
Which will force unload assets from memory that are not used
The problem is, it causes huge frame spike
so can only really be used during a load screen
Of course it should
Loading/unloading from disk is uge
But should be used sometimes
That's all very valuable information. I have many ways of loading things, not just resources.
Just resources is the fastest way to type it out. Keystrokes are faster than mouse drags.
(I'm very bitter about memory management atm. I've spent around 3 of the last 6 months optimizing asset loading and memory manage for old gen consoles...)
Imagine 40,000 mesh game objects drag and dropped
ahhaahahah
Your wisdom is well spent my man.
For if you ever see me flush with cash, from games, just hit me up
Rather just type out 40,000 or index loop em than drag and drop 40,000... especially if you need to shift, I think we're good to go.
I'm just glad you added to knowledge.
i always found assetbundles hard to understand ๐
The demo I wanted to post has weird compile errors
I need some help with structuring my code. I'm a bit of a newbie, but I'm stuck on the following problem.
My goal is to have an inventory with 5 slots, and when you would select, let's say slot 1, it shows a preview mesh at your cursor, and when you click, it builds that entity. In my case a turret for a tower defense game.
So I need to convert and declare these GameObject prefabs through a GameObjectConversionSystem, simple enough. But then I need to store these in an inventory that I can reference to when I select a slot, I guess a BlobAssetReference?
In Standard Unity, I would have an inventory manager with an array of 5 scriptableObjects containing the GameObject turretPrefab, the Mesh previewMesh, the int buildCost, and Sprite iconUI.
But how would I convert a ScriptableObject that contains a GameObject prefab?
@still pewter while maybe not an inventory, conceptually are you trying to do something like this? i.e. preview + place
If so I can kind of detail at least part of how I'm handling this so far (it's a work in progress)
I was making the standalone template and ran into this error: IndexOutOfRangeException: Index 0 is out of range of '0' Length.
Unity.Collections.NativeArray1[T].FailOutOfRangeError (System.Int32 index) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0) Unity.Collections.NativeArray1[T].CheckElementReadAccess (System.Int32 index) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
Unity.Collections.NativeArray1[T].get_Item (System.Int32 index) (at <d3b66f0ad4e34a55b6ef91ab84878193>:0) Unity.Physics.Broadphase+DynamicVsDynamicFindOverlappingPairsJob.Execute (System.Int32 index) (at Library/PackageCache/com.unity.physics@0.6.0-preview.3/Unity.Physics/Collision/World/Broadphase.cs:1052) Unity.Jobs.IJobParallelForDeferExtensions+JobParallelForDeferProducer1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.jobs@0.8.0-preview.23/Unity.Jobs/IJobParallelForDefer.cs:62)
probably forgot to add a handle to the physics world
Also just a heads up to developers , Unity 2020.3.26 and 2021.2.8 appear to have broken DeferredJobArrays or something related to it (and therefore Netcode). I believe it's likely this change
Kernel: Fixed an issue where low bit set in NativeArray buffer pointer assumes NativeArray is created by NativeList.AsDeferredJobArray which is not always the case. In some cases NativeArray can be created by NativeArray.GetSubArray, where pointer would have lowest bit set for odd byte aligned offset. (1294627)
@rotund token yeah that's pretty much what I'm hoping to accomplish too!
And I assume that you can press 1 or 2 to change your object? Because that's also what I'm trying to do
yeah 1, 2 currently changes type. adding remove tomorrow
i've split the prefabs into 2, I have the 'preview' and the 'ghost' (i'm built this using netcode, so by ghost i just mean the actual placed structure)
these are just prefab instances for maintainability. the ghost is basically just the preview with physics collider added and a couple of other scripts etc
is there any up to date example of character controller?
Mostly interested in collision with environment
and how it's done
The sample from Unity is not so great
you can find better implementations on blogs (and maybe the forum ? not sure)
Worth mentioning Rival asset too
Rival is not open source project I assume
hm
is doing public float3 CurrentDirection { get; set; } such properties ok for structs?
components I mean
what's the difference between just using field of float3
as value
Do you guys know, is IJobChunk smth obsolete?
Awesome! Can I ask, how did you convert and declare these prefabs? And are they part of some sort of inventory?
Question: how are we meant to check equality of components? In one case I'm using Equals which is throwing the following Burst error: Burst error BC1001: Unable to access the managed method object.Equals(object) from type RockMine.C4.Generation.City.Networks.NetworkNodeArchetypeData.
What equality are you trying to test? Equal values in the component or the same component by reference?
Two components may have all the same values but not be associated with each other.
And since components are structs they are passed around as values and aren't really objects to be equaled with each other.
do I need dots physics to make selection in pure DOTS?
I mean, normally I just make a raycast but it needs a collider on the object part so can I do it without somehow?
I have no use for physics in my game so using it this way seems to be an overkill
^ There's ways to spatially partition stuff and query for selection other than resorting to raycasts with the physics package, but you'll have to do a lot of it yourself, so that's a tradeoff
in case you go with dots physics, it's pretty lightweight when it has no objects to work on
literally 0.01ms on 0 objects
entities*
what do you mean? I will need colliders on everything selectable
like rigidbody equivalent?
I mean is that if they will be kinematic, they won't cause anything to process
I'm currently trying to understand unity samples of physics
and ngl
my head hurts
even after bull sized sugar doses kek
AFAIK it will produce pair collision event that you need to handle and that's everything
if you just want to select on mouseover
then we are actually studying same thing rn
I'm looking through "Mouse pick" system
for every collision it's the same
that lets you drag objects
in short, this is how it looks
I don't really get the magic behind CollisionWOrld.CastRay tho
but it seems like it's ready to use code for getting entity on mouseover
with precision of exact point of body you click
nice, thanks! that will definitely help me
here whole code
btw
do you have any idea about
IJob interface
IJobChunk
and etc
are those about to be deprecated?
Those are pretty old samples
and I haven't yet seen those interfaces in any new tutorials
so I kind of fear
if I should learn more about them or not
I know only that IJobChunk will be replaced by IJobEntityBatch or something similar
but never used them
IJob is just a simplest job type
I only worked with Entities.ForEach or Job.WithCode
haven't touched any interfaced job structs
then just try it ๐ they are simple
sadly in my company we don't use ECS so I'm constrained to jobs in MB
they are pretty same as Entities.ForEach, just couple more lines like .Complete()
is there any reason to use them tho?
I assume whatever code is done with them
can be done with ForEach and etc
i.e. I have "attack component" with target and value
in my system I do 2 jobs, first sort components by target and second one apply dmg to the target
It would be difficult to do this in .ForEach manner
yes you can, but after my first loop/job I have NativeHashMap so
If you guys are working on selection with DOTS, TurboMakesGames just released a video on that this week if I'm not mistaken
ECS*
I'm just learning stuff I don't know by looking through 2 yo examples xD
thanks I will check that
Try it out, learn how they work and use whatever you find easiest to implement
learning about stuff gives you more options to use in the future
My current goal is actually to make a character controller
if you want to learn jobs look into basic DOTS samles
similiar to GO one
that is responsive and not really attached to physics
besides collisions
not phisics or any other package specific
I remembered now, there are different samples for jobs only
like not even in ECS
I don't find jobs hard
I find physics hard kek
these examples seem to assume that you know what all that means already, just showing how it's done in dots...
but I'm learning this stuff from ground zero (besides irl physics knowledge, which doesn't help a lot tbh)
and they should be as they are "physics samples" not "job samples"
it's your mistake to start in the middle ๐
yeah, that's I was asking whether
those job struct interfaces are deprecated or smth
cause they appeared only in old samples
so the answer is: no, they don't. ForEach it's just a wrapper to reduce boilerplate, it's all jobs under the hood
sometimes you want more control that ForEach gives
and you can make your own custom made job types for whatever reason
the only reason I found is to iterate other collection than array in the IJobFor
probably your own custom native collection
IJobChunk will, I believe, eventually be superseded by IJobEntityBatch & IJobEntityBatchWithIndex, though, it's unclear if that will happen in version 0.5
I tend to make ForEach in systems that operates on single entity, and Jobs in systems that communicate between enities and need 2 or more entity queries
as an example for uses of jobs
You can do things when you operate on entire chunks that's not as efficient when just using entities.foreach
I don't suppose anyone knows if when using a CommandBuffer in a job to create an entity there's a way to ensure that it only creates one of those entity's?
single bool value?
What do you mean here? If you only create 1 entity there will only be one entity
i mean definitely don't put the spawning logic in a parallel job then
I have a weird job loop that's running over multiple entity's and can run multiple times for a single entity
Yeah doing it in parallel will be problematic. If you run it in parallel and create multiple you'd need some cleanup job to run later and clean up all but 1 of the entities.
I want to create like a singleton event entity that will cause another job to run
In this case you could create multiple, and as long as one exist then run and cleanup
hmm yeah maybe the job to clean up the excessive entity's run after the AddJobHandforProducer would be the only way then ๐ค
like peppej said, if it's just an event flag, it doesn't matter if there are duplicates
but [RequireSingletonforUpdate] requires a single one
The way I would do this is have an entity that always exist and flip a bool value on it. Always run the job and if the value is false just early return.
and RequireForUpdate
Depending on how often your "event" entity is spawned/destroyed it's probably faster the just flip a bool value
To prevent err
yeah, your systems will still run, so you might need to modify your OnUpdate code
yeah that is one way I thought of
actually, your dependent jobs will all still run
~~wtf I can't remember what its called. ~~Structural changes is expensive if you have to allocate a new chunk.
cause the changefilter will always return true
it's a tradeoff of structural changes vs scheduling jobs that don't do anything/early-out
ok boolean it is then, thanks everyone ๐
๐
there's an old forum thread that compares bools vs tags at scale for performance, and there's definitely a tipping point somewhere, but not sure it matters for individual tags, unless it means the difference between having/not having any structural changes on a given frame
Is StepPhysicsWorld very slow for anyone else?
I have 32 physics entities, which seems like a paltry amount, and the system takes ~3-4 ms...
Turn off jobs debugger etc and then profile
sooo. I'm looking into collision filters. And I found this funny example:
Object belongs to nothing collides with static env
and then I have static env, that collides with everything
and they don't collide
any explanation why?
How to put I componentdata onto an entity? Was trying to use ECS visual scripting to wrap my head around ECS
However for certain code to work on a certain archetyoe of entity I need to make sure those entities have certain data
SetComponentData
How do I attach it to an entity in the hierarchy for testing
a bit more details? Do you convert GO or create entity in runtime or?
Well the thing I'm confused about setting entity at runtime
How do I set the correct entity's at runtime
Eg I have cows and pigs
you create new entity either by archetype or you manually add components
If they both start as the same archetype how do I set an individual to have a certain component
Is there a way to set an archetype in the editor
here how authoring components usually look like
if you have some sort of prefab
you usually just make authoring components
and put them on your GO
Ok so you would add this script to the prefab
so they get converted upon start
this script is mono
create->ECS->Authoring
you'll get your template
with detailed comments
I really recommend this site for tutorials
Oh excellent
Awesome. Yeh Im not even sure how to wrap my head around ECS especially since it's apparently always changing
ECS is not changing
dots does
but it's irrelevant
it's mostly about learning this new way of thinking anyway
Honestly I wasn't that good at the old way of thinking so maybe I have a head start there haheha
But there seems to be a lot of seasoned developers saying "oh I'm not touching ECS properly until they sort it out"
I kind of already was using sort of ecs system while doing tile based gas
where gas was literally an index of array kek
eh, you can wait forever
or you can start now
and then just catch up on changes
can be compared to watching series on season's releases or watch whole thing in one sitting xD
hello, I've been messing around with quaternions in order to fix a problem with my prefabs being spawned sideways, yet for some reason it's also changing the size and shape??
seem you don't know how the quaternion works, it's not just a x,y,z rotation as it was before, I think you should just google it as I will not be able to properly teach you how it works by few messages on discord
changing scale is probably due to wrong quaternion values as it lands in local to world matrix
you don't change quaternions yourself (I doubt there's a sane person who can actually edit it manually)
instead you generate them from Euler angles
ideally you just use quaternions
if you don't want rotation use quaterion.identity
it's only rotation I want
what you have here is a non-normalized rotation
so will cause all sorts of issues
I just want them to face upwards tbh, instead of sideways
cool, so how do I fix this
Quaternion.Euler(Vector3.up) should do
I think you should avoid both Quaterion and Vector3 if you're using entities
oh? may I ask how this works?
but how?
I understand how to get rotation out of 2 quaternions, but some fixed quaternion without euler angles? That is just not smth you can calculate in your head
I'm ridiculously new to this
it's just simple math from euler angles to quaternion
quaternion.Euler(math.up()) would be the math library equiv
you can easily switch between two
but when cpu works with it, it doesn't do that. It works purely with quaternions, which avoid all bugs related to glitched rotations, that happen with euler angles

in short: quaternions is just different way to describe rotation of object.
The reason it's used: it's bug free. But unreadable for human.
actually, it is readable, just not for sane ppl xD
while, I'm here, as you can see I'm making a beehive. What would be a good video for ai pathfinding that I could use
I spent about 10 hours trying to understand them, but I gave up
I literally watched through math course just to try and understand them xD
add == multiply in quaternions
no, I mean how do you just go and define certain angle
for example Vector Up
in quaternion
so value * quaternion.RotateY(90) is rotating something by 90 in Y
or instead of degrees it take radians, don't remember now
there are many ways to represent stuff depending on what you need, another example is quaterion.LookRotation(float3 forward, float3 up)
yeah whole math library is in radians
radians = angle/360 * PI
and what quaternion will it give?
what is Euler alternative for it?
or quaternion.AxisAngle(float3 axis, float angle)
depends entirely what you feed it
if you're standing up, you're forward 0,0,1 and up 0,1,0
if you're lying down you're forward is now 0,1,0 and forward is probably 0,0,-1
but I think it takes only normalized direction vectors?
kinda, that's what I meant:
You can transform quaternions, it's pretty simple.
But not just define it, without using euler angles.
so initial rotation will always come from euler -> quaternion transformation
i'm just saying you can define it in direction vectors instead of euler angles
and if anything it makes more sense
to do that you actually need to know math ๐
just think about real life. you don't think 'my tv is rotated 90* in the Y direction'. You think 'my tv is facing forward'
it's interesting we choose to think differently when developing games
just food for thought
sorry boss, it says it can't recognise Euler
EulerAngles
no, it's for extracting
you sure you use Quaternion, not quaternion?
I don't remember alternative of Euler in quaternion
literally wrote it above
Just
strange, but quaternion is ok?
yes
do you use assembly definition files?
oh wait, you actually might want ZXY
looks like this is what Unity editor uses with GO
first of all restart unity XD

see, that's what I'm confused, Euler is actually used
but it's NOT accepting it?????????
and how exactly you are trying to call it?
as a new rotation
just show
welp
do you even have quaternion.Euler here?
I guess you need to learn C# syntax a bit more
instead of new, just put
quaternion.Euler(whateverEulerAnglesYouwant)
won't unity not accept that?
also no
I don't use it, that's the problem ๐ข , this the first time I'm trying to touch rotation at all
but oh well

it worked
kinda
but I can work with this
thank you very much!
np
if I have any other questions, I'll be sure to come back
thanks fr man
I'll mess around with rotations
I think it's radians as Tertle said so if you want to use degrees:
radians = angleInDegrees/360 * math.PI
oh there is helper function, neat!
DynamicBufferTriggerEventAuthoring
Can anyone explain this a bit?
So I read through code of this system about 5 times
But it's just feels like reading unknown language xD
Am I correct to assume that whichever entity has this component will collect all collision events in it's component buffer?
Or maybe just explain in short how you're supposed to use it? I generally get the code behind it, but I just don't get how to work with it
doesn't this basically just add support for stateful trigger events "TriggerEnter" "TriggerStay" "TriggerExit"
yeah, it converts simple trigger events into stateful events
as far as I understand
and looks like it gets it from some Unity Physics system
chunk.GetSharedComponentIndex() seems to return an index of 2 but the array populated by GetAllUniqueSharedComponentData only has index 0 and 1. Why is it returning an out of bounds value?
it might return the length (how many shared component date) instead of the index?
First hunch would be a structural change between the two get operations ?
Yeah I think this is my issue, currently investigating
Sorry for the delay on that DOTS/ECS Ez mode tutorial, my old code that worked last year got hosed with a UNITY editor update.
Gonna do a modified version with only code snippets instead of a full project.
I rabbit holed like 7 hours trying to just get old code working for tutorial purposes. Did not succeed.
Once I finalize a few things on my game, I'll be able to do the DOTS/ECS ez mode tutorial, but I can't give a full project, just classes and stuff to assemble.
there's this one https://www.youtube.com/watch?v=I1KX6YM_GeI
๐ Download the project files from this video: https://tmg.dev/DOTSFlowField ๐
๐บ Learn how a flow field works: https://youtu.be/zr6ObNVgytk ๐บ
๐ฌ Join the conversation: https://tmg.dev/discord ๐ฌ
๐ฅ Flow Field Tutorial Unity MonoBehaviour: https://youtu.be/tSe6ZqDKB0Y
๐ฅ
๐จโ๐ป GitHub repo for this project: http://bit.ly/DOTSFlowFieldGit ๐จโ๐ป
๐ป My Game...
I saw this, but the problem is that it's 2D and works by clicking on a place. I want to make bees come out and in of a certain place
it wouldn't bee that hard to make it work in a 3D space or however you want
isn't 3D pathfinding is same 2D in most cases?
unless you have some sort of space game ofc
I see what you did there 
nah, I just wanna make the bees from before come in and out of the beehive
do you really need pathfinding for that?
I mean yeah it wouldn't be hard to add an extra z dimension if you really needed to but it doesn't sound like pathfinding is needed for this problem at all
I mean, if they're being randomised every time they come in and out, I thought they would?
randomized how?
I don't suppose anyone knows how I change a singleton inside a job you can't seem to manipulate the value gotten from Getsingleton and SetSingleton doesn't work?
it says its only allowed to be withoutburst() and Run()
I know I don't get it what's even the point of singletons then ๐
yeah and which you cannot change inside a job
because the whole point is to run a job with Burst that's how you get the best out of dots
@pliant pike What are you trying to run?
I really wonder tho, what kind of job on singleton you want to do, so you need burst for it
I'm just trying to set a boolean Singleton inside a Schedule() singlthread bursted job
What type of Singleton? An component singleton?
yeah what other types are there?
Singleton means there is just one type of that thing in the program. So singletons can be classes and other stuff
no yeah just a single componentdata
So you have a component attached to a entity and you want to modify that component?
I mean I guess I could just use an EntityQuery and that would work but then what is even the point of GetSingleton SetSingleton etc
to get and set unique data?
There are a lot of non burstable stuff that makes it easier to do certain things. But yeah, doing a query would work. SetSingleton is definitely a regular write.
There may be some methods to write a to a singleton. A lot of the ECS code has regular non burst stuff in it just to get it to run. Then they loop back to make it burstable and job ready later
I want the bee to leave the hive then run around the hive and return through the same hole. But I want to make it so that the bee always uses a different path when it leves the beehive every time
You could generate a Random spline and adjust the bee position and rotation along that path. Never tried splines in 3d though ๐ค
it turns out the ecb does work to set a singleton ๐คท
huzzah
+1
instead it's just gonna be only on next frame
that should be plenty fine though
the singleton value will not be used in other jobs anyway in this frame
yeah its not super time sensitive
idk, most things I can imagine with singletons are just global settings
sure. but then next frame is perfectly fine
it will rather create glitches if it's instant
thought this was mildly interesting
in what way?
hes the lead on the hybrid renderer
cool I didn't think it would be that quick before other engines would emulate nanite 
eeeehh, i mean i am looking extremely forward to a nanite equivalent but i wouldn't give anything about a speculative twitter comment
nanite with dots would be insane 
i figured they wouldnt even bother attempting an equivalent tbh
true. though the benefit would even be without dots
nah they definitely would / will. it wouldn't make sense not to
Well, we'll see in 10 years then ๐
I thought as soon as Unreal announced it every other engine would be trying it
nah thats when we'll see 1.0 @karmic basin ๐
'every other' probably not. crytek and unity, definitely
Haha yeah
i hope we get mesh shaders before nanite equiv though
How would I even go about starting to do that 
by googling and researching
The power of google and stack overflow. Coding is 40% Googling, 40% debugging why those googled code doesnt work, and 20% actually coding.
research 9 times, write code once
hmm
I wonder if there's a way to create some sort of abstraction for job system
I want to create some sort of system that will process whatever Job component entitiy has, where that Job component is AI state for doing something rather complex
Let's call it work:
so that work can be either going from one point to another, or doing some action on certain position
Thing is, amount of such jobs can be thousands
and you don't want to define each as system
anyone knows anything about this sort of stuff?
in OOP that would be just abstract Work class and whoever needs that AI, would just tick over some virtual method
I want to know how you can implement smth similiar with dots
Yeah that's not really a DOTS question at this point. When lost you can start by deconstructing the problem in lighter tasks. Here it could be
- learn how to generate a 3D spline
- learn more about path following. For example, Craig Reynolds' "Boids" implement a simple path following solution https://www.red3d.com/cwr/steer/gdc99/ (actually all of the Boids concepts would be useful for a beehive, depending how far you want to push your scene)
you can still create a 'MyThingJobSystem' and derive from it like in oop
Dev blog about how awesome DOTS/ECS mostly and Gameobject only games are. Take any GameObject game you had, and add DOTS/ECS levels without rewriting player controller twice: https://old.reddit.com/r/devblogs/comments/s5th2g/two_paradigm_shifts_indie_revshare_can_employ/?
Yeah, but I don't see it work without some managed component and calling virtual methods of this component. Which basically defeats the goal.
Any idea how it can be done alongside DOD?
? It has nothing to do with components. You're in the system. And also just use static methods
Hello guys, I have a big question.
I wanted to know if it was possible to use "Graphics" command buffers in a base system running a ComputeShader in parallel with burst?
At the moment I have this working but I think it's not optimized and I'm missing some features to know.
so if you have the best way "the most optimized" for this kind of features, with pleasure!?
Command buffer will be executed on main thread only btw. Also compute shader works on GPU, not CPU, and I don't think you can dispatch them from a different thread cause that wouldn't make a difference anyway
So for this you are sure i can't do it ?
so why i can fill command buffer in SystemBase ?
and i have async btw
For this I am 99.5% certain that's not possible
aie ๐ข
Also, the command buffer in dots and in graphics are not the same
i know x)
that's why i try to make fusion
because i don't want to wait end of my compute shader
need to find solution to get handle or async c shader
At least how you propose it it's most definitely not possible
humm CPU is use only to write data in GPU for compute shader ?
I don't think there's any. The compute shader already runs on all GPU threads. And the GPU has to finish all tasks anyway before drawing anything
ah
Yes
"GPU has to finish all tasks anyway before drawing anything" this is important thing
sad
so i can't dispatch end wait an handle to make "async"
I'm 80% certain that doesn't exist
like this
class A {
bool chocolat;
void thread() {
chocolat = true;
}
void update() {
if (chocolat)
doSomething();
}
}
@rustic rain its you, you said me i don't need to use async dispatch
btw
And how you know when it's finish ?
Isn't that something else than he asks for?
i think ^^
I haven't actually worked with async, but I saw a lot of mentions that it's supported
here another link I found
yes look my pictures here so i m thinking how to make it properly, finally that's why i made this question because i have too less experience with CShader and ECS
possible to play with that
ok ok i see better now but not ultime mind x)
btw sorry for my english ^^
ahem
?
It's my own problem:
I don't get what is wrong
SceneManager.LoadScene("SampleScene", LoadSceneMode.Single);
I literally try to load other scene
and it won't go flawless
now it's doubled xD
here exactly what I do
World method is irrelevant (it's just resetting DefaultWorld of entities)
Ok and what is "please use ..." you have plugin ?
what plugin?
It says "Please use SceneManager.LoadScene()"
xD
btw
I checked
LoadScene is also using LoadAsync
inside
I'll try to build and see if it'll be same
ah yes, Build exceptions
my favorite
hmm, input system doesn't work in build for some reason
I use new input system
same i try to make all from scratch (hand build) ^^
you cant unload the current scene before having switched to a new scene
no difference if I put it or not, I still get yellow warning
and broken materials
uncomment the unload and try again
same deal
How are you waiting for your scene to load before unloading
Because it looks like you're unloading before loading a new scene
Unloading is part of loading new scene
it's just a trigger event
of clicking button
Hmm It's not the same scene you're in is it?
no
Oh wait you're using the entities scene manager not the unity engine one?
I basically copied a sample of unity official repo
Except they use load scene
Not load scene async
Which is what the warning is telling you to do
Ok I'm tired and on my phone
Clearly I can not read
Got no idea then mate sorry
I have been no help but I don't use scenes so no experience sorry
Any idea about new input system not working properly in builds? COmpared to Editor
What's the error
No errors, it's just not working
We use input system at work in a released title no issue
How are you setting it up?
in a system
so, basically after loading scene - no logs are registered
not even before loading scene
Is your asset being included, wonder if that matters for c# anyway
Just wondering if the asset isn't referenced its being excluded or something
I honestly don't know if it's needed or not
You're referencing the code generated not the actual asset
Anyway I don't think it matters
Mono build?
how do I check?
Project settings
2021.2.7f1
1.2.0
Hmm not sure then sorry. I know there were a few issues in 1.0.x that I thought we fixed in 1.2
This is certainly not an uncommon issue though
Anyway I must sleep gl with it
just bought this so off to learn mono for a few weeks less dumb qs coming through ๐
https://www.udemy.com/course/awesome-builder-defender-game-in-unity/
anyone know how i can run a simple job x amount of times?
Job.WithCode and just add some counter?
addendum: i need to schedule them for parallel
Just to make sure, do you make your build from the build configuration asset instead of the Build menu ?
nnnope
I have a feeling build configuration inspector is broken
no matter what you press at this point
this window is static
ok, so appears it's partially broken. Even tho component list is invisible, I can still click them in correct order.
Any tip in what category can I find Pipeline component?
So I can fix it
@rustic rain you installed say? https://docs.unity3d.com/Packages/com.unity.platforms.windows@0.10/manual/index.html
yeah
that's what I mean
after clicking one of categories
I still only see categories
yet I can blindly pick actual components
So I just added all of them
then you did a "Classic Build Configuration" asset for each platform (via the "Assets > Create > Build" menu). The properties of that asset will contain a "Scene List", which is the only way of adding subscenes to a standalone project. Make sure you add at least one scene or that the "Build Current Scene" checkbox is toggled on.
do I need to include in scene list subscenes too?
not sure soz
you need to make sure you add all your scenes otherwise your next levels wont load ๐
I know that much
any tip how to choose where to build using this?
cause after click:
Add Component -> Global
I see this:
Looking for this one I guess ?
yeah
Inside Unity.Build.Common
what order?
the third one for me
halleluya
looks like build works ok
it loads, it's not broken
even textures are ok
So you're saying the build config component is glitched ? In 2021 ?
yeah
ok good to know
Once it's open it's static picture, you only see category folders
if you click one - nothing changes, besides
clicking on first - will actually add whatever component is there
frustrating
ngl, all those annoying things make me want to go back to OOP for a while. At least until we see dots beta
i've got this struct here:
private struct ReturnValues
{
internal long _seed;
internal NativeArray<Materials> _lc;
internal long _lcProbability;
internal NativeArray<Materials> _ap;
internal long _apProbability;
}
why can i not use that in a NativeList?
NativeArray contains a DisposeSentinel which is a class so it can't be contained in a NativeList
Can't use a safe container inside another one
Could always alias another struct to the native array's pointer ๐
How would I go about this then?
Something like this can work
unsafe struct UnsafeArrayWrapper<T> where T : unmanaged {
[NativeDisableUnsafePtrRestriction]
public void* Ptr;
public ushort Capacity;
// Add your get/set if you want read/write bracket accessors
public this T[int i] => ((T*)Ptr)[i];
public UnsafeArrayWrapper(NativeArray<T> values) {
Ptr = values.GetUnsafePtr();
Capacity = (ushort)values.Length;
}
}
Ok, nice to know. Thx
I have a global Status I want to check - when this is not the required Status the System should not run at all.
In the System I have much code and a Entities.ForEach loop, so I don't know if I could use anything for Update Requirements? This is how I do it currently (with the system running constantly)
protected override void OnUpdate()
{
if (currentStatus != Status.RequiredStatus)
{
return;
}
// some other code
// and a Entities.WithAll<ManyComponents>().ForEach().ScheduleParallel();
}
That's how we did in my company for a few systems that we needed to be conditionally run
But we usually used a query with CalculateChunkCount()