#archived-dots
1 messages ยท Page 21 of 1
like paint tool
over terrain
then you need editor code, that yes spawns Game Objects
with all authoring components
basically designer tools
have nothing to do with ECS yet
The V Rising team does something close to it ๐คทโโ๏ธ https://www.twitch.tv/videos/1517796421 at 52:00
unitytech went live on Twitch. Catch up on their Software and Game Development VOD now.
They did mention they had to modify the package to get Entities running in the editor properly, but didn't elaborate what exactly
well yeah
there are 2 ways to achieve it
the one I mentioned above
or through procedural generation during conversion
so either your tools add game objects into subscene during editing mode
either you add game objects that represent instruction to conversion how it will be converted into whatever you want
for example you put cube with special tag and it gets converted to random bush
Yeah at least there's a way, even if not as simple as I first thought it would be. I'll have to think about the best approach, thanks for all the input!
@ocean portal Alright, after a bit of digging the best way to create a custom procedural level generator editor tool is to do something similar to this:
- Create level generator scene (NOT subscene)
- Add a GameObject at the root of the scene for you generator script to be attached to
- Create another scene with the name like "Level 1" (again, not a subscene)
- In your generator script, get a reference to that scene and load it as additive.
- procedrually generate stuff using GameObjects like you would for a non-ECS project and move them to the "Level 1" scene.
- mark scene as dirty, and save when necessary.
- Since it's a scene, you can loop over all the GameObjects in that scene pretty easily and set authoring component fields, add/remove components, etc
- Profit $$$
also, here's an example script for adding a GameObject when you reset the script:
public class TestAddGameObjectScript : MonoBehaviour {
private void Reset () {
Scene scene = EditorSceneManager.OpenScene("Assets/Scenes/SomeScene.unity", OpenSceneMode.Additive);
EditorSceneManager.MoveGameObjectToScene(new GameObject(), scene);
EditorSceneManager.MarkSceneDirty(scene);
}
}
Ohh and it could be split in to subscenes later
Yeah, there's literally 0 difference right?
You just get an entity representation which you can instantiate
What?
When you do this sceneSystem.LoadSceneAsync(sceneGuid, loadParameters); it returns an entity representation of the subscene, which I believe you can even instantiate multiple times with an EntityManager
I assume so, yes
at runtime subscenes are just a giant chunk of pre-converted entity data
the scene no longer exists
Right. I kind of wish the conversion system didn't exist and we could just deal with pure entities :P
yes but this is an editor tool
What I complained about when I first started using DOTS lol
what everyone complains about for whatever reason
then i link them the gdc talk
and we go on the same little journey
Maybe one day when everything is dots and go's don't exist
I mean in a few decades maybe :P
But here's the thing, an Entity is not a "singular object" like GameObjects.
it has components that can be scattered across many points of memory
GameObjects being managed doesnt have that issue
granted Entities are chunked, but that's beyond the point im making
Yeah they're a bit different, sure, but I don't think it would stop "prefab entities" existing for example
That would be just normal prefabs since they're serialized the same way as scenes
you can get a prefab reference and have it be used during creation of entities
I guess, still the authoring workflow irks be a bit
Yeah not disagreeing
idc if under the hood it's GameObjects, just make the workflow a bit more intuitive
From what I've been told it's to not make all the editor tools useless
Oh, also I think something entities-only is planned because their roadmap has a DOTS runtime as a potential feature in the future
For sure they have good reasons to keep it like this, at least for the forseeable future, just daydreaming ๐
no reason to tbh
game objects are easier to understand for humans
entities are easier to work for CPU
having both is good
Maybe, can't see in to the future, but I wouldn't be surprised if everything was entities in the backend at some point. But even so the difference between a go and entity is pretty small, so this gets easily in to semantics
difference is huge
entity is just data
game object is self registered object with tons of allocations
This is the semantics part I meant ๐ Cause I could argue that data = allocations
I know there's a huge difference in the backend, but we were talking about the authoring side mostly
key point is self registered here
I've come to like the entity way more, it feels easier with all the help you get from unity, so I could also argue go's aren't necessarily easier for all humans ^^
What if I don't design with inheritance in mind? :P
But you can do inheritance without GO's too
yeah and here you go recreating everything GO's already have yourself xD
I forgot what the argument was, I can only say I haven't missed the managed components
the need for GO's in the future ๐
Hmm yeah I can see how they might be around, but I usually steer away from the GO stuff even in GO projects and just use custom classes which store references to components, so I personally wouldn't mind if GO's didn't exist :P But yeah ppl are different, it was just a far off throw thinking about the future in a few decades or even more, tried to defend it, failed :D
of all the things to complain about people chose the authoring workflow most often ๐ so weird
The hardest part in the ECS learning process for me has been the hybrid approach, it took months to understand how to interact with both sides from a system for example. Maybe I'm just slow idk
i mostly blame that examples and samples are hard to find. once you get the grasp it's very straight forward. just a lot of bad terminology like hybrid itself but then you want to add a MB component to an entity and you have to call AddComponentObject. Then the whole thing about (the near obsolete) CompanionLink that i've given up now because it's mostly useless by design.
Pretty much this^ Once I saw stuff like go transforms in components it became a lot easier, but there was a lot of stuff to shift through to find the good stuff like that
Same goes for CopyTransformToGameObject and the like
because it's shit. Entities are a seperate workflow. forcing entities and GOs to work together isn't the best idea
I don't suppose anyone knows what happened to this method or what it doesCollectionHelper.AssumePositive()
my guess is it works like math.abs()
IIRC it's now an optimizer for the burst compiler
Unity.Collections.CollectionHelper.cs:
/// <summary>
/// Tell Burst that an integer can be assumed to map to an always positive value.
/// </summary>
/// <param name="value">The integer that is always positive.</param>
/// <returns>Returns `x`, but allows the compiler to assume it is always positive.</returns>
[return: AssumeRange(0, int.MaxValue)]
internal static int AssumePositive(int value)
{
return value;
}```
Where Unity.Burst.CompilerServices.AssumePositive:
/// <summary>
/// Can be used to specify that a parameter or return has a range assumption.
/// Assumptions feed directly into the optimizer and allow better codegen.
///
/// Only usable on values of type scalar integer.
///
/// The range is a closed interval [min..max] - EG. the attributed value
/// is greater-than-or-equal-to min and less-than-or-equal-to max.
/// </summary>
[AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Parameter)]
public class AssumeRangeAttribute : Attribute
{
/// <summary>
/// Assume that an integer is in the signed closed interval [min..max].
/// </summary>
/// <param name="min">The inclusive minimum value.</param>
/// <param name="max">The inclusive maximum value.</param>
public AssumeRangeAttribute(long min, long max) { }
/// <summary>
/// Assume that an integer is in the unsigned closed interval [min..max].
/// </summary>
/// <param name="min">The inclusive minimum value.</param>
/// <param name="max">The inclusive maximum value.</param>
public AssumeRangeAttribute(ulong min, ulong max) { }
}```
how do you even find that 
Rider Decompiler ๐
You can find it if you go through the package source as well:
Visual studio can decompile source code
And yeah, packages are all uncompiled so just a simple search will work
well that's great thanks a lot
are you talking about authoring or hybrid because those are 2 different things
they're both equally shit
lol, i somewhat agree on hybrid but authoring is the best unity ever decided. to split runtime and design data
How does adding entities have anything to do with "splitting runtime and design data" that you couldn't do already?
Point is, Entity workflow shouldn't use GameObjects purely because the workflow is completely different
Again, I don't care if they Have to use GameObjects in the background, there just need to be an obvious distinction between what qualifies a GameObject to be a GameObject, and an Entity to be an Entity
You have to keep track of what is going to be converted, and what is not because both normal Mono runtime and Entity conversion use Monoscripts
Having "Authoring" at the end doesn't really make it qualify as an Entity explicitly
it's pretty simple though, GOs in subscenes are converted to entities and serialized as binary subscene data. no GO is left and only lives in the editor
Yes, I know how it works
that's off topic
I'm specifically pointing out the conflict of interest between Mono workflow and Entity workflow
I'm honestly tempted on making a completely standalone editor tool that doesn't use a single GameObject purely for entities
there is no pure entity workflow. that's what unity decided on and it makes sense
No it doesnt
unless you code your own system, archetypes and loading/saving data. and then you'd end up with something like the authoring workflow
I don't see how that is relevant
my entire point is to strip GameObjects out of the equation
but there are no GOs when using subscenes. what's with the arbitrary hate on GOs?
ok
I don't hate GameObjects
The entire workflow behind data oriented design is to be completely linear compared to OOP which is GameObjects
the two dont mix well, that's why the Job system is a PITA to work with because you need to squeeze in these little changes to work with OOP and DOD (really depends on what you're doing)
What I personally want along with a lot of other people want is a new/similar workflow that doesn't involve GameObjects
needing to convert your MonoBehaviour script into an entity component type is a bit absurd at times, especially with "simple" components that have multiple aspects to them
Need an array? Too bad, gotta use a dynamic buffer
you mix a lot of topics together. i get the impression you have not fully understood why this workflow system exists. it's not made for the solo dev but big teams with designers who work daily with the comps the programmers made. you say a lot of other people want this but this channel is full of people who came and went with the same prejudice and then realised that their understanding of the workflow was just lacking and they changed their mind. can it be improved upon? sure, that's what 1.0 is about with the new baker feature. but nobody who worked longer with it is really talking about a huge paradigm shift in the workflow or find the need to voice that they don't want any GOs involved. GOs in the workflow are just data containers anyway but for some reason you ignore this.
mono workflow is easier
you have inheritance here and all sorts of stuff
easier to mod and extend
if you only had tools to construct entities...
ooof
runtime data of entities can be very awful to work with
so you end with same approach
of having authoring components
i think regarding "new/similar workflow that doesn't involve GameObjects" i sort of get it and agree, that in an ideal world maybe something newer for an authoring workflow that didnt have some of the cruft that years of ancient and quasi obsolete monobehaviour functions would be nice.
sadly in reality that would extend the production of dots unreasonably so unity is making do with what they have and its versatile enough for the authoring conversion workflow
Unity is considering making a DOTS-only runtime that wont have anything to do with GameObjects, so it's not unreasonable at all
they canned tiny and that dots only runtime was once part of the active roadmap, only to be shifted to under consideration, so time considerations apply again.
This has nothing to do explicitly with the mono workflow, but the combination for mono and ecs
by mono workflow I mean transform hieararchies and managed components (monob)
which is far more simpler to work with rather than runtime entity data
yes, but that's not what I'm talking about at all
unmanaged data types are also far easier to work with for a lot of reasons. ECS/DOTS/unmanged forces you to actually write clean code, have an understanding of the logic flow, and how to manage data correctly. The only difficult aspect regarding unmanaged types is pointers and managing array-like types (NativeArrays for example.) While it's not "difficult" it's something to be cautious about.
I can already see setting up rotation for objects through quaternions ๐
authoring components is a really cool concept
good example. now that would be fun ๐ the authoring concept of quaternions is angles. easy to understand and work with
also colliders, hehe
allthough maybe setting up all that authoring data is possible through pure entities
but I find it quite painful, considering every component change equals = other archetype
there's a plethora of examples. like an ai authoring MB that chains into many ecs comps and/or buffers. maybe I'm missing something here but I'd see no improvement when these have to be setup in the editor with pure entities
miss one comp, the whole thing doesn't work. we had this for a long time with standard MBs too when devs didn't know what they were doing
same goes for any type of string selection in an array that gets converted into an integer index
I need a second world with the systems in FixedSimulationSystemGroup. Can this be done automatically instead of always remembering to add each new system to the list for the separate world?
not without using reflection unless you want to include all your systems in the world
how would i burst a for loop, according to the docs it should happen automatically, is this true? Does this also happen in mono behaviours or only systems?
you can only burst functions or jobs
[BurstCompile] attribute
well first of all, that will be burst compiled only if it was called from burst called
then you have
[MethodImpl(MethodImplOptions.NoInlining)]
im afraid im a bit of a noob, so you are gonna have to try explain simply lol
ah, i shall, thank you
ok thanks!
ok i think i get it, so all for loops within a IJob thingy should burst compile?
all code within burst compiled job is bursted
oh i see having a managed array inside a job is not allowed, that is unfortunate
And this is another part of manual ๐
https://docs.unity3d.com/Packages/com.unity.burst@1.6/manual/docs/CSharpLanguageSupport_Types.html
ah thanks!
Hello everyone,
happy to have found this discord.
Quick question:
Would you recomend stickinging with HDRP for a new DOTS project at the moment or is URP sufficently supported?
hey, wondering how you debug errors in jobs, as im getting this error, and i dont even know where to start looking lol
What's the callstack?
What's a callstack?
That's kind of like asking how long a man's legs should be, it depends.
Click on that message, it should include more text that describes the sequence of function calls that lead to the issuing of that error message
oh ok sure!
i feel like an idiot now, i only just realised you can scroll in them, and now i know atleast where the error is coming from, thanks so much, ill come back if i cant work out why my spaghetti code is not working!
sweet
aha turns out i was accidentally running it on every physic frame and every regular frame, and also every time the particle system wanted an update
oh also it really doesnt seem to like converting from ParticleSystemNativeArray3 to Vector3
now that im thinking about it, how on earth do i convert ParticleSystemNativeArray3 to Vector3? the more i think about it, the less it seems possible
they appear to be 3 dimensional (perhaps 4?) so im not quite certain how to interact with them in any way, and i cant ignore them either sadly, how unusual and terrifying
by components would be my guess
https://github.com/Unity-Technologies/DOTS-training-samples/blob/dots-training-2022-09-na-group1/DotsVersion/ZombieMaze/Packages/manifest.json
DOTS has landed 1.0 at Unity. Exp.2 so very early stage but it's probably in feature freeze rn.
https://github.com/Unity-Technologies/DOTS-training-samples/blob/dots-training-2022-09-na-group1/DotsVersion/ZombieMaze/Assets/Scripts/Systems/RotationSystem.cs
Unity intends for all stages of a system to be bursted (create, destroy, and update seem to have burst compile tag in the prefab)
https://github.com/Unity-Technologies/DOTS-training-samples/blob/96420b673580e3dad381c06bbeb602dd84cb3abc/DotsVersion/ZombieMaze/Assets/Scripts/Systems/TileCreationSystem.cs#L177
There's now a quick access singleton buffer component function, which is nice.
No appearance of a scheduled / threaded integrated aspect - foreach loop. Only mainthread so I dont think they've managed to make that work. So far.
Foreach loop as in the C# foreach () {}, not the foreach jobs.
great find!
I wake up every day and check the github for new training branches.
I imagine we're getting really close to 1.0!
So excited lmao
I'll rephrase. I'd like to use URP, but I seem to remember that some features of URP are not supported with DOTS and HDRP had more supported features. That might be outdated information though. So is there any reason not to use URP with DOTS?
Another question:
0.51 does not seem to work with the animation package, so right now I am proxying animated/skinned characters as gameobjects to be able to use the non-dots animation system. Does anyone know of a better solution or will I have to wait until animation is implemented?
Even just getting gpu-skinning to work would be great so I can to dots based procedural animations.
no animation as of now
you have to use hybrid approach
for animated characters
look on the forum for kinemation or dmotion. it requires compute shaders though https://github.com/Dreaming381/Kinemation-Skinning-Prototype
other than that you are out of luck and need to use GOs
Thanks for the links! Do we know if aspects can be used to create entities? ๐
No clue. No example has been done using it in entity archetypes thus far.
fingers crossed we get something on wednesday or next week ๐ค
Pretty much everything normal GOs can do entities can (eventually)
Depends on the version
their documentation is a little confusing. Most versions say this
2020.1.2 and later (recommended)
This package uses Unityโs Entity Component System (ECS) as a foundation. As such, you must know how to use ECS to use this package.```
, but then once netcode reaches version 0.51, it starts to say
```This version of Unity NetCode is compatible with the following versions of the Unity Editor:
2020.2.4f1-dots-5 and later (recommended) Get From Here
This package uses Unityโs Entity Component System (ECS) as a foundation. As such, you must know how to use ECS to use this package.```
i was hoping there would be a list of explicit dependencies in the documentation
All the 0.51 packages were released together
ok, so Netcode 0.5, the version just before 0.51 could be for Entities 0.17 then
0.50, and no because all the 0.50 packages were also released together
before then it was the wild west
oh ๐
ok then
well I can always manually install it and look at the package-lock file I guess
always an option
thanks
looks like Netcode 0.6.0 is the last version that works with Entities 0.17 before moving to 0.50 or 0.51
though netcode documentation shows there was a 0.7.0 and 0.8.0, but they don't appear anywhere in the package manager
also the dates in the netcode changelist don't match the dates in the package manager for when they were released 
maybe because the preview.# versions aren't documented in the changelog
did you guys know that handle dependencies is much slower than schedule then complete? it was a surprise
They sometimes have internal versions that were never made publicly available. Same thing happened with the entities package for version 0.18 and 0.19
a few weeks ago I actually benchmarked our project to show this. while schedule costs aren't insignificant, dependency costs are quite a bit higher
179/frame - Median 1.23ms, Mean 1.24ms, Min 1.02ms, Max 1.41ms
m_DependencyManager->AddDependency
171/frame - Median 0.20ms, Mean 0.24ms, Min 0.17ms, Max 0.48ms
JobHandle.ScheduleBatchedJobs
171/frame - Median 0.62ms, Mean 0.61ms, Min 0.47ms, Max 0.69ms```
unity is aware and some time ago a dev made a forum post that the job system is completely rewritten and (i think) scheduled to arrive in unity 2022 or was it 2023. i can't remember
That matches our findings and emphasizes once more the importance of benchmarking everything instead of buying into the Unity best practice
Good to hear, so maybe next year when 2023 is rid of all the many regressions we can use job best practice
@rotund token which version of Unity are those timings from?
how can i read these timings and what could we do about it? so GetDependency is really expensive for some reason
GetDependency does a lot of work compared to Scheduling a job. It has to collect all JobHandles mapped to each component being read/written to and then it combines the dependencies which is the same thing as scheduling an empty job with all dependencies.
This is work project so still 2020.3.30f1
Get dependency is what is called at start of system
AddDependency is called at end of system
Then scheduled batch jobs is called right after it
Which is what actually schedules all the jobs you just created in the system
Should be in 2022.2
It might actually already be public - I haven't bothered to confirm though due to effort of getting entities to run there
Yes, the job system improvements came in 2022.2.0b2. From the release notes:
Core: Improved the Job System to better scale as core counts increase and reduced the cost of scheduling jobs and combining dependencies.
As for what you can do about it, use ISystem
Also use less systems
About all you can do until 1.0
Just looking at this code in the unity physics samples:
any clues why they've memcopy'd the indexs but not the verts?
it's actually just in the unit test code
i'm guessing that basically the vert positions aren't important
but obviously the indexs are
seems like a mistake to me. the verts are still used but empty
depends what it's testing
true, still an odd setup
agreed
i'm guessing it's simply testing the creation of the collider/blob
it basically just creates one of each type
i'm trying to create a collider that matches the camera's frustrum to run a collider cast with
so this seems like a nice setup to quickly build one, i just feed in the points i've calculated for the corners of the frustrum
Quick question: Unity NetCode for dots, does it have platform limitations? aka can it run on WebGL with websockets?
probably not
not out of box anyway
might need to setup your own transport
these are transports people have written for netcode fo gameobjects (in particular websocket/photon for webgl)
you will probably need something similar for entities netcode (though the transport layer should be somewhat decoupled so hopefully not that hard to port)
So uhh.. after getting this frustrum collider setup and running it's clear that the cast only returns hits on the surface of the mesh collider..
Which renders the whole idea pointless ๐
Any ideas on how to return collisions within the volume of the collider?
I should have realised this would be the case tbh, it just never occurred to me
obviously the alternative would be just create a spacial hashmap of all units, rebuild every frame and poll that
but i figured leveraging the physics bvh would be a neat and tidy way to do the same thing, and the data's already there
One workaround i think might work is cast the collider from the end point back towards the camera position
I'm only collecting when the user makes a click-drag selection rectangle so i don't think performance of that would be a huge issue
how can i imagine this? an rts click & drag selection?
yeah pretty much
sweeping the frustrum-shaped collider back towards the camera works
huh, i'd just use the collisionWorld and a overlapBox cast. you probably know the starting and endpoint
yeah the problem with that is, as the box gets further from the camera, it gets smaller due to perspective..
so if you're drawing a rect in screen space.. objects that are say 100 units from the camera near the edge of that rect might be missed by the box overlap/cast
yeah i see the problem ๐
oh that is an interesting problem
hm, maybe you need to rethink that completely. the entity picker approach renders the entity index to a texture. you could do something similar. it turns into a 2d problem then
i'd probably still do some type of overlap and then just cull individually
optimized you don't even need to render a fullscreen texture but just the part that was selected. for a prototype fullscreen is much easier though
well if you think about it.. a box that is worldspace the width of the screen at a distance of say 1 from the camera, will be tiny by the time it's cast out to say 100 units
if you do the opposite ( make it large enough at 100 units so that it covers the width of the screen ) - it would be enormous at camera z
there is one disadvantage with this method i'm relying on Camera.WorldToScreenPoint unless i can find the math that goes on behind that
for each hit, i use that to check if the hit is within the screen area of the drawn rect
i guess i'd have to use WorldToScreenPoint and reference the camera whichever method i used to collect the objects within view
how many units are we talking here?
my suggestion has the obvios flaw that bunched up, non visible units wouldnt be rendered. though i think this case could be rare or non existent
depends on the camera angle
because with units <10k i would not overthink this. just brute force it. burst and entities is fast enough
that's true also yep
Just to point out as it dawned on me, WorldToScreenPoint requires a reference to the camera and isn't burstable, and you're having to check every entity world position against it
yeah that sucks. it's not that easy, what you need is the inverse matrix to cast from world to screen position. some shader tutorials should get you up to speed how to do this
or its just multiplication with the perspective matrix. it's been many years I've done this the last time
i think ive some code around that does this
Yeah i mean for what it's worth, creating a custom mesh collider that is the shape of the camera field of view and required depth and then casting that from camPos+(camFwd*depth)/towards camPos and collecting the results works and does the job quickly enough..
I might try and dig out the code behind Camera.WorldToScreenPoint though to avoid needing that managed reference
I just looked at this again and got what you actually meant ๐ Yeah i'm going to open the unity core assembly in dnspy and check if the code is visible, barring that i'll use what i've got just now ( which collects all entities/positions from the collider cast inside a bursted job and then iterates the results with Camera.WorldToScreenPoint in a non bursted job.
Found a method of WorldToScreenPoint online and converted into burstable code:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static float3 WorldToScreenPoint(float3 wp, float4x4 camProjectionMatrix, float4x4 camWorldToCameraMatrix, float camPixelWidth, float camPixelHeight)
{
// calculate view-projection matrix
float4x4 mat = math.mul(camProjectionMatrix, camWorldToCameraMatrix);
// multiply world point by VP matrix
float4 temp = math.mul(mat, new float4(wp.x, wp.y, wp.z, 1f));
if (temp.w == 0f)
{
// point is exactly on camera focus point, screen point is undefined
// unity handles this by returning 0,0,0
return float3.zero;
}
else
{
// convert x and y from clip space to window coordinates
temp.x = (temp.x / temp.w + 1f) * .5f * camPixelWidth;
temp.y = (temp.y / temp.w + 1f) * .5f * camPixelHeight;
return new float3(temp.x, temp.y, wp.z);
}
}
can swap if with math.select
should be a tiny bit faster and potentially vectorizable
ah okay - thanks for that!
so burst doesn't pickup on that and compile it in the same anyway?
I have no idea how exactly it works
but
KornFlaks showed comparison
and normal if was different to math.select
which was quite surprising
I mean in assembly code
maybe Burst has it's own conditional code
which compiles certain functions with special constraints
yeah that's interesting
i assume it depends on the nested code, how burst handles it and if it gets vectorized
ie if it's vectorizable, it'll get the benefit of math.select
if not, it's maybe marginal
so it's probably better to use it everywhere possible than not
i think you'd probably better be off just doing if (Hint.Unlikely(temp.w == 0f)) unless you're actually getting proper simd on this
since it's such a rare case
math select isn't always faster, it requires execution of both paths for the sake of removing branching
and in this case using math.select will cause nans in one of the paths
does that matter? hmm maybe not
interesting, thanks
just raising awareness of this tweetstory that I posted last week in case it's helpful: https://twitter.com/MrAndyPuppy/status/1568716388499619840
I know people are increasingly asking about DOTS this year, so here is my current top ten DOTS links:
- DOTS Beta Forums - Dev Status and Milestones - https://t.co/1rhV0ZglXf
113
Great ! We have some in the pinned messages, but always nice to refresh with more recent resources ๐
pinned message here should probably be updated ๐
@solar spire
Hello, I am facing two issues in my project which uses DOTS. Can anyone please help me with this?
- I am controlling a sphere object through below movement script. It works fine but when I reload the scene, this is no longer working. I am not able to control the sphere.
- I am increasing the composite scale of a plane at runtime but mesh collider is not increasing automatically with it. So objects which are on the plane are falling through the plane.
are you reloading the domain? if you don't, statics will have old values
for 2. physics only uses the translation and rotation for non static rigidbodies(and i dont think statics use more than ltw?)
you will have to edit the collider blob data
class System : ISystem
i need unity to add a static analyzer for this to save me from myself
Great idea
How can I get ComponentData if all I know is the TypeIndex?
so you don't know what component it is?
you can get ComponentType using ComponentType.FromTypeIndex()
from there you can get dynamic handles
I have an attribute I mark on my Components, so I know what component it is, but I can only find <T> ways of getting ComponentData
Closest I found on DynamicHandles is GetDynamicComponentDataArrayReinterpret<T>
which still requires a Type, I suppose I could maybe just pass IComponentData?
What I'm trying to do atm is to just dump the data of all components marked with my attribute, if I have to crawl raw pointers that's fine too. But I think I could probably get the info from reflection as long as I can get the structs somehow
you can just pass it byte
and use info from typemanager about elementsize etc
to do with it as you will
var components = chunk.GetDynamicComponentDataArrayReinterpret<byte>(this.ComponentType, this.ElementSize);
Hmm interesting, I didn't think that was a thing
Is there then a way to reinterp a byte array to the actual component given its System.Type? Assuming I've already split my array up in to the byte representation of the component
not really
I suppose I could use a binary formatter or similar, but was hoping there's a native solution
c# is for the most part statically typed however you could maybe use 'dynamic' to get this to work. maybe...
{
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)```
i find it strange Unity has updated IJobChunk for the new enable features
when IJobChunk was meant to be deprecated for IJobEntityBatch
while (chunkEntityEnumerator.NextEntityIndex(out var i))
{
var tmComp = transforms[i];```
i am somewhat concerned by this api though
though I assume if I am not use enable masks I can just iterate the array normally
for the sake of simd
but what exactly are you trying to achieve here?
what do you reinterpret it as?
and how do you plan to use it?
The basic idea is to supply a UI system with any Component's value from DOTS. So in essence someone could say MyUI.Width = "Namespace.HealthComponent.Value". Note that our UI isn't made in Unity, so we'll resolve the string to the actual Type. Then my idea was to use this Type to query for data in ECS Worlds, then use reflection to grab the property (Value) and pass it back to the UI.
Still early prototyping so looking if there's a nice way to get entity data from a System.Type
I had idea about it
my solution was to create personal type manager that solves componentdata into string
to do it untyped
it'll require to implement either extended type with method that does conversion
or conversion from byte array
let's say component velocity
and you want to show on UI it's value as
"Velocity: {value}"
you reinterpret byte array as value type
viola
and it can be made native
but it'll be very low level copy of Unity ISystem implementation xD
you'll have to store managed and unmanaged function pointers basically
somewhere
which will be accessed by your converter's type index
just tested my subscenes / dots / ecs scene for the first time on android, skybox renders nicely, other than that - nothing is showing. everything seemed to show fine in editor player game mode, but nothing showing on the actual mobile device. gonna start trying to investigate.. meanwhile if there are any obvious caveats / should-knows / usual suspects etc. please advise
why not start by attaching logcat?
is that in the profiler?
nah, it's package
or you do it manually through adb
should just look up Unity tutorial on it
hope this is the right one https://docs.unity3d.com/Packages/com.unity.mobile.android-logcat@0.1/manual/index.html
i vaguely remember previous times Unity came shipped with logcat... maybe when i was playing with unity 2022.*
ok i got profiler and logcat, anything specific i'm looking for?
Is it somehow possible to schedule a deferred parallel job based on the length of a specific dynamic buffer?
If it's a IJobParallelFor you can specify the batch count, if that's what you mean
But I can't access the length of the buffer without calling Complete on the systems modifying it
I don't think it's safe to hold a copy to a dynamic buffer while it's being change though and then scheduling a deferred job on it though since the memory may be moved by ECS
why would the URP/* shaders have compatibility issues with hybrid renderer?
ok so Vulkan works...
but i was hoping it will work on OpenGL ES 3 maybe even 2...
does using dots/ecs require higher-end mobile devices? are signifigant swaths of older devices like Android 6.0 etc. going to not be supported?
OpenGL and GLES are not supported in the current version of hybrid renderer, but it is planned for the future
It only supports Vulkan on android and linux atm
DOTS / ECS does not have any specific hardware requirements itself afaik
ok so how do i troubleshoot why standard shipped shaders like URP/Lit or URP/SimpleLit don't work with OpenGL ES in dots/ecs
Are you using hybrid renderer?
yes
^
wha ๐ฑ
is this documented somewhere?
Of course
please do share link
I'm not sure if they've announced anything, I don't follow ECS development nearly as closely as some of the others here, they'd probably know more
I don't use hybrid renderer for my own project
this does imply some degree of hardware requirements kinda sorta
Well yes, for the hybrid renderer, but not for DOTS / ECS as a whole
They are entirely separate
right
so you probably use dots/ecs mostly for speeding up logic processing, like moving lots of code which would have been in Update() methods into ECS systems. But for my prototype scene where i'm mostly just testing pushing graphic limits of how much static environment i can render (trees, vegetation, grass, rocks, props etc) on mobile, no significant loads of logics to process ATM, i would specifically benefit most from the hybrid renderer and NOT just plain putting all the game objects into ECS world?
so if i specifically want openGL support, then i have nothing to gain from ecs/dots at all for my particular use case?
If you have no significant gameplay code your game will (probably) not run faster by moving stuff over to ECS
..unless i benefit from the hybrid renderer?
Yes, hybrid renderer should run faster than using game objects for rendering
putting it a bit differently; the initial flashy marketing about dots/ecs was that MegaCity demo, millions of of static environment objects rendering blazing fast. am i wrong to desire to achieve a similar feat by using dots/ecs for a dense scene of lots of static environment?
if someone want to achieve dots/ecs awesomeness like megacity nowadays, is the answer basically = hybrid renderer?
I mean it's certainly possible, as they have shown. In the current iteration you would have to resort to vulkan. I'm not sure how well the megacity demo ran on mobile devices
technically the did show it off on mobile as well
Then you have your answer
so back in 2018 they had some sort of hybrid renderer which also might have only worked with vulkan?
I'm guessing it's still not easy and requires "manual" optimization
I'd guess so
i see
There are limits you will run into regardless, especially on mobile devices
Megacity ran on mobile
hybrid renderer isn't magic and will let you render infinite objects at no cost
funny you should mention that,
i was asking about "manual" optimizing in dots/ecs here https://forum.unity.com/threads/how-to-implement-megacity-lods-and-culling-system.1334756/ they were all saying - no need, it's all automagic, just put your scene in ECS land (subscenes or whatever) and you'll enjoy all the benefits & optimizations similar to / better than megacity
I'm not sure what kind of optimizations they did for megacity besides not using game objects, I was referring more to things like optimizing shaders for mobile, which is something you would still need to do. Again, hybrid renderer itself isn't magic, eventually the GPU will have to handle draw calls
(hopefully significantly less than if a different approach was used)
ah right well ye shaders prolly still need to be optimized as needed, i guess i was referring more to like scene optimization, LODs, culling, scene graph etc. concepts like what was discussed in that ECS talk https://www.youtube.com/watch?v=k_ORJXmPu9M&ab_channel=Unity
and apparently that stuff is supposed to be automagic in hybrid renderer?..
anyway i guess for now the main lesson is; dots/ecs 0.51 + hybrid renderer = only vulkan supported
I can't really comment as I've never used hybrid renderer in a significant capacity myself. If I were you I'd look at the unity samples and see how they did things
ok
Hybrid renderer uses the BatchRendererGroup api to create draw calls, and that only supports Vulkan on android / linux
i see
what's the plan for openGL ES then, they wont use BatchRendererGroup for that?
I'm guessing they will add support for it in the future, at least the hybrid renderer docs state as much
hopefully nearer future than later... maybe they'll just decide meh forget OpenGL/ES... only future devices supported kthxbai...
I'm happy I have very low rendering requirements so I can just use normal URP rendering ๐
why is it even a problem?
lemme know when you're making a game trying to look anything vaguely close to this ๐
You'd probably be able to do something like this in "normal" unity with lots of performance tricks
even on mobile
i'm trying/hoping to support a few levels of older devices too... if at all possible. ex. i'm testing with an LG G4 having Android 6, where vulkan support is 1.0 and famously android devices have flaky early vulkan support and will never be corrected (as the hybrid renderer docs say)
Hello where can I learn about best practices to reload a scene with DOTS or load another scene? Whatever I tried I get problems.
i guess i'd be satisfied with this LG G4
but flaky?...
TBH i dont have that LG G4 with me right now so can't check, will do so in a few hrs
i guess i thought the easiest "performance tricks" would be to throw it into ecs/dots/hybrid renderer, and why not - if there's a motherload of performance awesome to not lose out on right there. performance by default. then you can even optimize further with even more optimization tricks...
having said that - i'd love to achieve great performance in "normal" unity even on mobile... what tricks do you have in mind? frustum culling? occlusion culling? LODs? anything else?
I mean it depends a lot on the scene, but I'd start with draw calls first
hey if i could interest you to join in this little prototype project - it would be awesome to learn good tricks from a seasoned veteran ๐คฉ
Make sure everything that can be is instanced
I have very little graphics programming experience and no time sadly ๐
instancing itself requires opengl es 3.1 i think, no? not even sure if that's available on this LG G4.... maybe tho
There's a reason why my project has low rendering requirements 
of course
hah of course
There's lots of stuff that developers have used over the years, replacing distant trees with billboards, instancing, pooling, etc
right
Depends a lot on what's bottlenecking you
last i profiled it in regular game-objects on mobile i think the main load was Draw Opaque and Draw Transparent calls
How many draw calls did you have?
Also why transparent calls? The scene above doesn't look like it has anything transparent except maybe the water
But why not make it opaque and use alpha clipping
The actual leaves aren't transparent
right
i thought that's what Draw Transparent calls were about, the alpha clipping
so you could see other graphics through the transparency of the leaves texture
i might be horribly wrong about that tho
i also thought "but wait it's a PNG with transparency - it should automagically already be alpha cut out!" but no apparently a shader needs to specifically perform that
which i'm guessing is what causes some Draw Transparent calls or whatever
What surface type are you rendering it as? Transparent or opaque?
opaque
i figured that one out a little while ago
not sure if it matters but i'm also seeting render face = both
I'd check the frame debugger and see how exactly the frame is rendered
ah
Also 2k draw calls is a lot for such a small amount of geometry
especially on mobile
i think i didnt turn on instancing
but again - not sure instancing is available for the LG G4 i'm hoping to target
I'd check this part of the docs, it explains a lot of basic performance optimization techniques as they pertain to Unity
can anyone helpme reloading a scene in a system?
I want to implement a simple method to reload the scene once the game is over
var sceneSystem = World.GetExistingSystem<SceneSystem>();
var guid = sceneSystem.GetSceneGUID("Assets/Scenes/GameScene.unity");
var sceneEntity = sceneSystem.LoadSceneAsync(guid);```
using this
how can I load the scene as single?
What do you mean?
I mean I just want to reset the world and reload the scene
Different ways to do it, ideally you'd just unload the old scene
If you want a "true" reset (including system state), you can dispose the world and create a new one
from a monobehaviour?
what would you like to see?
I see
I'd check where your 2k draw calls are coming from
i'd have to test on the LG G4 in a few hours, the LG V60 ThinQ i am using now definitely has proper GPU and instancing and good performance, 322 draw calls, 24 batches
168.9 k tris
hm now i see indeed most vegetation even those transparent leaves are part of Draw Opaque. only my "water" plane is Draw Transparent
IIRC there were about 2K objects in the scene when i screenshotted that
very cool tool this frame debugger ๐
are you using subscenes? that way you can control it much easier as you'll have the entities coupled in it
handling entities just with scenes needs quite a lot of manual work to get right
I will, I am learning about them now
a subscene is a special component in a scene that automatically converts your gameobjects to entities.
Any sense in pooling entities for performance gains?
I guess it would depend on the amount and how long it takes to iterate over the "disabled" ones, maybe easier with the new enable/disable functionality in 1.0...
depends in what capacity they change and how long they live
a few seconds maybe
if you can batch create the entities i found pooling not necessary.
Basically I have a lot of data that belongs to map chunks, and currently I am storing that data in native collections. That makes it a lot more difficult to schedule jobs per map chunk though, which is trivial if you have an entity for it
where's the difference in scheduling?
Each map chunk belongs to a separate "world" (I talked about this recently, not sure if you remember), not an ECS world, but a place where an Entity can be. As each world needs to store data separately, this already makes it kind of awkward, as I need to use a Dictionary<Entity, NativeCollection> or resort to unsafe collections, which I'd rather not. Then I need to schedule each "world"s update separately since I cannot pass that dictionary to a job, and there is no entity for a map chunk to grab data from using something like a CDFE
It's hard to explain, but I feel like by trying not to use entities for this, it kind of removes this part from the normal (simple) entity dependency management, and requires a lot of manual scheduling and passing job handles between systems. I feel like I could make it a lot simpler if I moved more data to entities
For example, I'm currently playing around with using the manual navmesh API instead of my own written version for pathfinding locally. My idea was to use a job that gathers all collidable primitive shapes (NavMeshBuildSource) for a map chunk, and then in the next frame the previous dependency handle is completed, and the static NavMesh and NavMeshBuilder APIs are called (since I'm guessing these are main thread only).
The question is what kind of data structure to use to store the primitive shapes. If each map chunk is an entity, that would be easy, a DynamicBuffer. But since it isn't, I'd need to use something like Dictionary<Entity, NativeMultiHashMap<int2, NavMeshBuildSource>>, which seems very akward...
(in the entity version map chunks are mapped to worlds using a sharedcomponentdata that contains a single Entity field)
On the topic of navmesh, are you aware they have jobified the API now ?
Anyone got good info on joint motors support ? Just had a quick look at the physics forum. It is... depressing ๐
By jobified do you mean the navmeshquery?
testing now
๐ญ
Is there a way to do the opposite of a raycast in the dots physics API? basically stop once the ray doesn't hit anything?
!
@karmic basin dont think they exist yet
at this rate im not sure if they ever will ๐ฅฒ
but i was hoping to target medium-low end devices such as this LG G4
if it doesnt support vulkan, then i might try pulling off this project in regular game objects after all...
at least until they support opengl maybe
they do specifically warn you about this in the manual
Currently, Hybrid Renderer does not support desktop OpenGL or GLES. For Android and Linux, you should use Vulkan. However, be aware that the Vulkan drivers on many older Android devices are in a bad shape and will never be upgraded. This limits the platform coverage Hybrid Renderer can currently offer on Android devices. OpenGL and GLES3.1 support are planned for a future version of Hybrid Renderer.
wish it was a bit more louder & clearer on the tin before getting too much into the weeds...
it's ok tho - i'll still work on a dots/hybrid renderer version for higher end devices
bit clunky to support multiple versions like that... but i'll try and see how it goes
Honestly, I would expect anybody to have read the manual of the packages at least once before writing the first line of code ๐
Always study feasibility before jumping right into it with your two feet ๐
haha reading manuals
I don't have hope neither :/ How would you approach it ? Apply linear/torque/velocity impulse, managed by a p(i)d controller ?
start writing code, then complain about a bunch of design decisions
this is the way
๐ค haha yeah where's the fun in books !
@tropic venture you did have your early warning ๐ #archived-dots message
anyway Ive never used a joint motor in physx, I just want other features they talked about ages ago. they sound kinda important ๐ฆ
wow impressive necro ๐ i probably didnt fully understand what i was talking about then, was just getting started, but yes apparently you're right i was told about it...
only a month ago. just wait until you've been waiting for features and fixes for years ๐
still hardly know what's what... dots, ecs, hybrid renderer, subscenes or no subscenes, convert to ecs or dont convert, manual optimizations or automagic optimizations... fun times
or you had a feature and it was ripped away from you ๐
animation ๐ญ
alright, thanks for feedback ๐
Yeah that one hit hard
UIToolkit has so many controls and just a fraction is available in the UI builder. so weird
i only realized with intellisense that there's ui:Image and i don't need to use ui:IMGUIContainer
which stands not for image UI container ... lol
lol
generally you can just use visual element + background image
unless you need some very specific image control
you'll also probably end up just writing a bunch of your own elements
that's what these controls do anyway. write out a background-image
but ui:Image at least has a sprite property where I can set it directly
haven't found the binding path. seems missing ๐คท
who needs images in games. such a niche thing
not in a world with no animations
BindingPath is part of BindableElement
yeah i saw that. image is just derived from visualElement. i'm just looking for an image something that can bind a sprite
UIToolkit feels very code centric. I don't like querying all these elements. Such a step back from UnityUI. (and yeah, i know, great rendering and fast) UnityUI could also been fast without this shitty workflow
UnityUI
i'm not sure that's true
probably not for the current version but the workflow is excellent imo
The idea is to go from something nobody knows (unity UI) to something that actually kind of works in a team (html and css)
Also it was originally editor only, which means code only
layout groups are a huge problem in ugui
they may be friendly to setup
but they destroy performance
the best practice is to use layout groups to setup all your stuff
then delete them all so they never run
it's pretty horrific
maybe i'm just pessimistic but we have very little numbers for UIToolkit - at least i don't know any - so who's to tell that they solve all complex UI stuff.
if it was just editor stuff. no editor GUI is utterly complex in layout
it's actually on my todo list for my day off today
just curious how it compares to what i've been doing
same, i'll take a look at it
i mean, not that we can really compare as there's no unityUI sample of the same thing
outside of assigning others to do UI work, I haven't used unity UI in 2 years
so i don't really care about a comparison
i just want to see if I've overlook some useful functionality
when the major downside of UnityUI is performance it's the most important metric
UnityUI performance is terrible
i don't see it yet. unityUI has great WYSIWYG. binding alone pisses me off and can lead to weird errors in teams. it's very rigid.
You mean binding as in callbacks on classes / IDs?
yeah i've read that a bunch of times by now and i can never figure out what kind of UIs one need to build to have terrible performance. i'm looking at all those UnityUI centric games and they barely hit any cpu.
you know you don't have to use bindings right
we have 25-40ms spikes on consoles from ugui
and up to 10ms on 3xxx ryzen
Someone I know worked on a large scale project and they optimized forever to get the UI not to spike FPS
what's happening in those spikes?
you update 1 element
every canvas that touches that in any z direction
needs to be rebuilt
which triggers every layout group
basically unless you're very very careful
any update to any element ends up triggering a full UI rebuild
you have to follow very specific and pretty gross practices
to avoid this
this guy summarized it pretty well
A lot of the optimization tips tells you to not do what the tutorials tell you to do (e.g. avoid Layouts etc).
how much UI panels are we talking about here that this gets into such a spike?
the TLDR
- don't use any layout groups, manually layout everything
- have a completely flat hierarchy, no nesting
- don't stack any UI
this matches our experience
so the main problem seems to be the overly aggressive updates of layouts that aren't even needed
if ugui is your jam, it's unlikely to be removed anytime soon
hell we still have OnGUI support
i don't give a fk about unityUI ๐ i'll take the next best thing
uiToolkit sample in profiler
hits the 144fps cap
looks pretty cool, very smooth
you should've heard what i said about unityUI when i first started it. now it's just something i got used to and all it's quirks. don't think for a second that i like the vertical/horizontal layout groups or layout element that only support percentages in a kind of way. but to its credit. the implementation and interface for it is nice. i like the stretch and anchoring stuff. i can't even figure out what half of those icons in UI builder are. i have to look at the code to understand most of them.
oh boy
still off with match game view.
they certainly use VisualElement for images and set gearElement.style.backgroundImage = new StyleBackground(m_EmptyGearSlotSprite);
I use static resolution in builder
and special setting
that scales texts
makes workflow pretty fluent
match game view sets the resolution to the game view. what's your special setting?
ah, I don't remember
but you choose asset for those
in UI Document
component
match game view is awful, because in Editor resolution can be very small
and there's no autosize for text, without such setting
well that explains a bit. is there no way to get that in ui builder?
in builder
you simply set that "default" resolution
you picked in ui asset
and don't change it
everything else will be scaled
in runtime
btw @rotund token they bunch all screens in the MainMenu.uxml. haven't found a dynamic load yet of a panel
which you can test right in editor
doesn't surprise me
yeah i only use visual element for images
didn't know about StyleBackground. seems easy enough
well redid my whole asset management, thanks eizenhorn...
any particular reason why? also was this something eizenhorn posted on the forums about?
just a random discussion that was on in here a couple of days ago
IDs has been something that has bothered me for ages
i like the general concept he was using and it inspired me to properly solve this
i even solved the issue of 2 people creating new objects and being assigned same ID in different branches
can you link me part of the convo if it was here? getting a case of fomo ๐
ty
(you can see the previous convo that he replied to)
my asset management is so haphazard, one scheme here, another scheme there, then just folders where I dump things willy nilly
yeah i unified everything
everything uses the same definition
ties 1:1 to an entity
data driven categories that a design can create
and would be usable in AI / etc
as well as guaranteed unique ID even with branch merges
on first glance maybe I dont need this complexity
Is there a way to check whether current execution is in burst?
yes
ecb does that
hm, i use the guid from the AssetDatabase for SOs
that was basically the system i replaced
private static bool IsBursted()
{
return false;
}
public static void Method()
{
var isBursted = true;
isBursted = IsBursted();
if (isBursted)
{
}
else
{
}
}```
something like this
Which will be generic struct with pointers to managed and unmanaged function (actually just index that points to shared static array of pointers)
The idea behind it - create a way to queue callbacks
i was using a WeakAssetReference which was just the GUID of the unity object
but my new implementation has quite a few nice benefits
- 4x smaller component size
- i can replace all references in project by changing the prefab in the definition instead of having to find all references in project and replace them
- i can convert my database of assets from a hashmap to an array
hmm that second part sounds really useful
Hmmm
That gave me an idea
For entity reference
What if you create special native container
That stores pointer to entity struct
Similar to blob
On the other hand nvm
Approach doesn't help with reference preservation after all
did i get this right. you now have a SO database which relates guid to integer id?
kind of?
my definitions are just basic SO
(there is also a hidden unique ID field here)
that reference an entity prefab
authoring references these SO and store the ID on a component (int ID is wrapped in a struct so I could change type in future if I need though will probably not happen)
then can just get the prefab from a buffer to instantiate
i use asset importer to guarantee unique IDs
so if 2 different people merge 2 new definitions with the same ID
on the import it'll detect this and update one of the IDs to a new unique one
but existing references won't break because they reference the SO
the only case I can see this breaking is if someone branches from master right before you publicly release, then merge back in after you release
and updates a released ID
(because it might break save data)
isn't that kind of impossible with guids?
im not using GUID though
why not, every SO has one
because i dont want to store GUID on components
and i can't just do
Instantiate(NativeArray[index])
i think eizenhorn does it like this. at least the 2nd screenshot he posted looked like this.
guid#name
he specifically has sequential IDs
and they're solution to merge issues is just, push the new ID straight away quickly
yeah, with that kind of referencing you can generate a sequential unique id without worries
which has worked fine for them
and honestly, solid rules in a team is usually good enough
i just thought of an easy way I can guarantee this
the only more safe way is to have some kind of database in between
i don't need that database
that's the point
i can guarantee these IDs without losing references by fixing them on import if there's a merge conflict
and the code is quite simple
another situation this solves is duplicating a definition
which is usually how a designer creates these things
traditionally we'd use OnValidate() for this type of thing
but it's pretty problematic
because it runs on every SO when you build addressables in editor
another nice perk is I can just create the list of all prefabs in a single buffer during authoring without having to actually create a list
some really nice benefits
so a designer doesn't have to remember to add their new definition to some arbitrary list on a SO
yeah that sucks so hard
i wasn't actually sure this would work
but it turns out it just does
tldr: var guids = AssetDatabase.FindAssets($"t:{nameof(ObjectDefinition)}");
i just find them all using AssetDatabase
during conversion
so the process for a designer to make a new definition
is to hit Ctrl+D on an existing one
and rename it
bam done
i'm doing something similar. that was the reason i didn't want any GO for the CreateAdditonalEntity if you remember. i even wanted to skip the part to setup a ObjectDefinitionRegistryAuthoring (what you call) in a subscene ๐
you pack it all into one. i seperated them on types
oh wait, that was for the SOs to blob converter. slightly different but samey ๐
the first experimental version coming Pretty Soon Now (tm)
๐
WHO SAYS THAT?
noice
after that long post, i still don't see much changes
https://forum.unity.com/threads/new-batchrenderergroup-api-for-2022-1.1230669/page-2#post-8122013
We have landed GLES 3.0 support for BatchRendererGroup, and newer versions of Hybrid Renderer will support GLES 3.1 (due to some compute requirements)
Don't expect miraculous perf on GLES phones though ๐
yes in the job but not in the loop
you're running into this issue: https://docs.unity3d.com/Packages/com.unity.collections@1.4/manual/issues.html
get rid of your foreach basically
the 'AsArray' is getting invalidated by the other temp allocator
yeah
yeah that works, thanks again
it makes some kind of sense i guess, and is no big hassle
be nice if they fix it tho
it's a huge problem imo
like, if I (or someone else with a lot of experience) isn't around to tell you what's up
it could take ages to debug this
this is the most basic case as well
there are much more complex cases where it pops up that are much less clear
i'm hoping this is being addressed with new allocation stuff but i'm not sure
it's been marked as a known issue for 2+ years
ahhh
juggling safety handles i guess internally, without causing problems
i'd like them to fix the using 'this' error
if you use a non-local inside a job
it's really unspecific, and would be a lot quicker to debug if the warning would just mention the name of the offending variable
oh this. flagging annoys me
on the WithStoreEntityQueryInField
it should not flag that as an error
but i'm at the point where I only ever use EFE if i'm quickly throwing something together to test
so whatever s๐คทโโ๏ธ
it's always the stupid stuff when you're trying to rapidly test ๐
i had easily half a dozen foreachs in that job, and same amount of temp lists ๐
my previous selection system was thrown together using entitymanager for quickness/prototyping
inevitably it gets fairly complex so i wanted to start flexible
but it was as slow as hell and caused lag
now it doesn't impact fps at all
so the frustrum collider idea works well,and shoving it all into jobs and ecb goes without saying, magic
hey @rotund token was just reading an old thread - you found that moving entities offscreen was quicker than say disable/enable?
i couldn't gather whether you'd used worldrenderbounds to trick it off screen, or simply moving the translation
ive said a lot of things
and i dont recall this at all
i'll need a reference to myself ๐
haha 2019 i think
oh this would have been hybrid renderer v1
ahh yeah
oh wait
this was completely different
this was for like invisible units you wanted to exist but not render
but there's a component for that now
DisableRendering
currently adding and removing Disabled to my selection indicators and it's not really ideal, bit hacky i think
ah oh DisableRendering
that's probably be better
i was actually going to pull this library out soon
and update it
been 3 years
and i'm finally at a point where i want to use it
when adding and removing Disabled i'm noticing this 1 frame glitch where the objects render out of place for some reason
i'm going to hate the code
hehe no doubt
DisableRendering shouldn't have this issue
as i believe the components should still update
Still getting a slight issue with that, but it's less obvious now..
https://gyazo.com/9c34f50bde836565de3ee0ff9eeebc0d
Can't really see any issue with the code so wondering if it's when and where i'm doing this
what's the issue for unobservant people
when i move the mouse, so the rect selects/deselects units at the edges, you can see the green cubes pop in/out out of place
kinda hard to spot
but it's there
you can see sortof like 'fireflies' where the green cubes appear out of place
i know your stuff isn't really moving atm
but aren't you basically using last frame position then
probably doesn't matter
(i find peoples usages of init system group interesting)
(people use it for all sorts of different things)
yeah i just dumped the system there and it works so haven't changed it if i'm honest
just tried simulation group but using the begin init buffer
and it's the same
๐ค
why wouldn't use presentation buffer if you were doing it in simulation
almost seems as if the renderer is rendering them some internal initialization pos/scale for one frame because they appear out of place and smaller
ahh maybe
(bit of a tangent but personally a system like this should exist in presentation system group because if you were running a headless test client this system shouldn't be updating since it requires rendering/camera/input)
ok no i appreciate that
i'm a little unsure on the exact order and usages of those things still if i'm honest
init | simulation | presentation
and the renderer actually renders between presentation back to init?
using begin presentation with the system in simulation actually solves that issue
hybrid renderer updates in presentation
the actual render stuff happens after that
init called start* of frame
yeap ok, that clears it up a bit in my mind
i think it's when i've been doing it that's the issue there
Is there a more efficient way to spawn many unique objects using an ECB besides instantiating a prefab and setting values?
The prefab is always the same but the values are mostly unique
maybe don't use the ECB?
Are the values predefined?
The majority are (e.g. position isn't)
You could define the variations in one or more ScriptableObject(s) and just pass that into your instantiated GameObject
I don't follow, I'm not using any gameobjects
you are spawning prefabs, what do you thing that does?
Create an ecs entity
Sorry, misread the question
๐
Is it significantly faster to spawn using the EntityManager if you have many unique entities?
well using the ecb is like two steps EntityManager is one and you can batch instantiate with the entitymanager, I guess it depends on the use case, but I'm guessing it will be faster, but you can always test
Why two steps?
I only really use the ECB if I specifically need to schedule a structural change
that's what the ecb does it playbacks the commands later on the main thread
Well yeah but it just calls EntityManager functions, how is that two steps
well the job runs then it puts that all that into the command buffer, then maybe other jobs run in the meantime then when its time the command buffer is played back on the main thread
Ok, that's what you meant. But that's not really different from using my own collections / buffers to write the data in a job and then spawn on the main thread (basically what the ECB does)
I mean yeah it depends on how you are doing it but it could be faster to just instantiate with EntityManager then set all those values in a job
That's not really possible if calculating the values for those entities is expensive (as is the case in my setup)
Where's the best place to call this main thread entity spawning? Schedule a system to run right after something like EndSimulationCommandBufferSystem?
I'd guess close to any sync point would be best
I'm not an expert but I'd just do it when you need it
Are there any rules against creating "prefabs" at runtime in ECS?
(specifically using the Prefab component)
not as far as I know
ECS is kind of new and everyones figuring it out as they go to be honest
I wouldn't really call it new at this point tbh, It's been in development for so long already ๐
true but they keep changing stuff so your constantly have to learn and experiment
if it's meant to be runtime, why not
smth like
saving blueprint
for some building
My use case is that I currently have a single ghost prefab for netcode that is basically an "object". There are lots of different ones that can be created though, and the data for these is stored in blobs.
My idea for a performance improvement was to read all blobs and then create spawnable netcode prefabs on the client and server instead of writing all unique values for that object in an ECB each time it is spawned.
I'm not 100% sure how netcode initializes their prefabs though. They do runtime stripping for components in the ghost collection system, but I'm not sure if there is any other step or if they just use the prefab hash to check what kind of prefab was spawned on the client.
For my runtime prefab, I guess I would just generate a unique hash based on the blob that is creating the prefab (which would be identical on the client and server)
great news! any chance i can already start playing / testing with this on one of my lower-end mobile devices which dont have Vulkan?
i currently have 2021.3.9f1 and ECS 0.51.1-preview.21
that forum post mentions 2022.2.0a13 - must I have that version?
I don't think it's compatible with ECS
not sure at least
ah
Any particular reason why NonUniformScale may be ignored with an instantiated prefab?
could you rephrase?
the entity has the component, isn't a physicsbody or anything, but the visual scale of the object and renderbounds don't reflect the NonUniformScale values
So you see the non uniform scale values
Seems to be ignoring those
Ah
It's..
drumroll
... my fault.
๐ค
I'm setting LTW
๐ฏ๏ธ
why do you even set LTW
just simpler for the particular use case
Hi all, I'm trying to import some older assets and use them with DOTS. I have selected the Convert to Entity checkbox, and am getting several undesired behaviours. One of the prefabs is breaking up, one is lying on it's side, one is pushing into the floor and one is floating in the air. I assume this is all symptoms of the same issue. Can anyone give me some hints where to start looking to fix this? In all instances the idle animation also stops playing. The screenshots show without ConvertToEntity ticked, and with it ticked.
have you worked with Unity ECS before?
relatively new to it. I've fiddled a bit, but this is the first real attempt to build something substantial.
I'd suggest to go over whole manual first then
https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/ecs_core.html
especially important concepts and conversion workflow
so the first thing I'm seeing is that I shouldn't use the ConvertToEntity as the script is going to be deprecated. Should I place the objects that I want to convert into a subscene and write a custom converter?
yes, that's basically what you should do
but just keep going
conversion in Unity ECS is pretty important
Ok, I vaguely remember this, I actually did have some of this written previously, so I'm going to give my brain a moment to absorb and remember, and then I'll take another crack at it. Thanks for pointing me in the right direction ๐
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I think you are missing some components. I just tried converted a default cube and I see WorldRenderBounds, HybridChunkInfo, ChunkWorldRenderBounds and built-in material properties. Not sure which components you need and which ones are added by the hybrid renderer systems.
I would look into using the helpers in RenderMeshUtility.cs. They make it easier to set up mesh entities
I'm having massive issues with any form of physics using raycasts that are a decent amount away from the local origin point of the parent (root) entity.
// This is how im getting the velocity at each point:
float3 velocity = pv.GetLinearVelocity(m, t, r, contact.hit.Position);
//...
// How I'm applying force:
PhysicsComponentExtensions.GetImpulseFromForce(fd.mass, worldForce, ForceMode.Force, deltaTime, out float3 imp, out PhysicsMass pm);
pv.ApplyImpulse(pm, t, r, imp, contact.hit.Position);
It will bounce 1-2 times (as expected) but then it will start spinning out of control, only if the distance from the center is farther than 2-3 meters locally
One message removed from a suspended account.
I think the problem is with how you create your RenderMesh. I assume the layerMask field is getting a default value of 0, which means it won't render.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
The first error is probably due to the second error, but sometimes shows up harmlessly as well. For the second error, it looks like you aren't using a compatible material. Need to stick with URP, HDRP, or ShaderGraph shaders.
It is possible to get custom shaders to work with hybrid, but you have to add a bunch of boilerplate to the shader and its not really documented anywhere
One message removed from a suspended account.
OK, I have now created a Conversion process just using the IConvertGameObjectToEntity, IDeclareReferencedPrefabs approach, but the results are still the same. The mesh is on its side, and broken into the 3 pieces that make it up. Also, the animations don't seem to be running, but I guess one problem at a time. ๐ฎ
Animation is not currently supported in ECS
If you need full skeletal animation, best option is a hybrid approach where you have game objects with animators that are synced with corresponding entities in the ECS world.
Ok, I'm trying to get a handle on the options here, so can you perhaps confirm whether I can do something like this?
- New Input for Input with ScriptableObjects as a bridge (similar to the Open Project)
- Can I use new Physics with GOs?
- Can I use DOTS for particles, projectiles and other "dumb" assets, and then GOs for the animated characters?
Or should I just KISS and wait a little longer for DOTS to mature?
- Can I use new Physics with GOs?
No- Can I use DOTS for particles, projectiles and other "dumb" assets, and then GOs for the animated characters?
Yes
In fact, you can everything in Unity ECS, but animations with hybrid approach
Not familiar with the Open Project so not sure what you are referring to with that. But you can use the new input system with ECS.
The DOTS physics only works with entities, not game objects. However, you can sync game objects to invisible entities which would work with DOTS physics. But it does make things complicated and may not be worth it.
DOTS doesn't have a particle system so it depends what you mean. For things like bullets or other "dumb" assets, DOTS would work great. But if you are trying to more visually complicated particle effects, I would stick with VFX graph.
Just to give an example of what's possible, I'll explain what I'm doing in my game.
Most of the objects in the world do not need skeletal animation, so those are all pure entities. I have a main character that is animated, so I use a game object and animator to do that. The character game object follows an invisible entity around which allows it to collide with the entity world. I use the new input system for everything. All input callbacks are handled by an ECS system and written to a singleton entity. Other systems react to changes to that singleton. For particle effects like smoke and lasers, I use VFX graph.
Thanks. I know what the Open Project is, but haven't dug into it enough to know what you are talking about with the scriptable object bridge for input.
ah sorry, checkout this devlog video - https://www.youtube.com/watch?v=u1Zel20rwOk
In the third devlog, we go over how we implemented the complex input requirements of "Chop Chop", the first Unity Open Project, using Unity's new Input System package.
๐ Get the 2021.1-compatible demo used in this video on the Github branch:
https://github.com/UnityTechnologies/open-project-1/tree/devlogs/3-input
๐ For a more tutorial-like vide...
Hi guys,
It seems you can't use Dots with the Quest 2. Can anyone confirm or deny this?
when you say "follow an entity" are they linked in the scene somehow, or do you move the one and then the other?
Hard to recommend the best path forward without knowing more about your game. In general, if you needs lots of animated characters or want to rely on lots of 3rd part assets, you may want to stick with game objects. You can still leverage DOTS jobs to speed up parts of your game.
yeah, it's a prototype, so I'm just using store assets wherever I can, I'm certainly no artist. I'm working on isometric top-down shooter, so 3rd person with mostly animated characters.
there's built in companion link
which basically copies entity transform to GO transform
I wrote my own syncing thing, but works the same way I think. Every frame, I move the game object to match the entity's position.
unless you do it from transform job