#archived-dots

1 messages ยท Page 21 of 1

rustic rain
#

spawn random trees

#

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

ocean portal
#

They did mention they had to modify the package to get Entities running in the editor properly, but didn't elaborate what exactly

rustic rain
#

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

ocean portal
#

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!

errant hawk
#

@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);
        }
    }
ocean portal
#

Ohh and it could be split in to subscenes later

errant hawk
#

yep

#

subscenes are literally normal scenes

ocean portal
#

Yeah, there's literally 0 difference right?

errant hawk
#

just loaded by a script called "Sub Scene"

#

yes, they're normal scenes

ocean portal
#

You just get an entity representation which you can instantiate

errant hawk
#

What?

ocean portal
#

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

errant hawk
#

I assume so, yes

rotund token
#

at runtime subscenes are just a giant chunk of pre-converted entity data

#

the scene no longer exists

ocean portal
#

Right. I kind of wish the conversion system didn't exist and we could just deal with pure entities :P

errant hawk
#

yes but this is an editor tool

errant hawk
rotund token
#

what everyone complains about for whatever reason

#

then i link them the gdc talk

#

and we go on the same little journey

ocean portal
#

Maybe one day when everything is dots and go's don't exist

#

I mean in a few decades maybe :P

errant hawk
#

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

ocean portal
#

Yeah they're a bit different, sure, but I don't think it would stop "prefab entities" existing for example

errant hawk
#

you can get a prefab reference and have it be used during creation of entities

ocean portal
#

I guess, still the authoring workflow irks be a bit

errant hawk
#

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

ocean portal
#

For sure they have good reasons to keep it like this, at least for the forseeable future, just daydreaming ๐Ÿ˜…

rustic rain
#

game objects are easier to understand for humans

#

entities are easier to work for CPU

#

having both is good

ocean portal
#

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

rustic rain
#

difference is huge

#

entity is just data

#

game object is self registered object with tons of allocations

ocean portal
#

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

rustic rain
#

key point is self registered here

ocean portal
#

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 ^^

rustic rain
#

GO's support inheritance ๐Ÿ˜…

#

can't do the same with entities

ocean portal
#

What if I don't design with inheritance in mind? :P

rustic rain
#

it's not always for game logic though

#

sometimes it's for other stuff

#

like UI

ocean portal
#

But you can do inheritance without GO's too

rustic rain
#

yeah and here you go recreating everything GO's already have yourself xD

ocean portal
#

I forgot what the argument was, I can only say I haven't missed the managed components

rustic rain
#

the need for GO's in the future ๐Ÿ˜…

ocean portal
#

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

viral sonnet
ocean portal
#

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

viral sonnet
#

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.

ocean portal
#

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

errant hawk
pliant pike
#

I don't suppose anyone knows what happened to this method or what it doesCollectionHelper.AssumePositive()

#

my guess is it works like math.abs()

errant hawk
dense crypt
# pliant pike I don't suppose anyone knows what happened to this method or what it does```Coll...

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) { }
}```
pliant pike
#

how do you even find that leahWTF

dense crypt
errant hawk
#

And yeah, packages are all uncompiled so just a simple search will work

pliant pike
#

well that's great thanks a lot

viral sonnet
viral sonnet
#

lol, i somewhat agree on hybrid but authoring is the best unity ever decided. to split runtime and design data

errant hawk
#

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

viral sonnet
#

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

errant hawk
#

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

viral sonnet
#

there is no pure entity workflow. that's what unity decided on and it makes sense

errant hawk
#

No it doesnt

viral sonnet
#

unless you code your own system, archetypes and loading/saving data. and then you'd end up with something like the authoring workflow

errant hawk
#

I don't see how that is relevant

#

my entire point is to strip GameObjects out of the equation

viral sonnet
#

but there are no GOs when using subscenes. what's with the arbitrary hate on GOs?

errant hawk
#

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

viral sonnet
#

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.

rustic rain
#

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

safe lintel
#

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

errant hawk
safe lintel
#

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.

errant hawk
rustic rain
#

which is far more simpler to work with rather than runtime entity data

errant hawk
#

yes, but that's not what I'm talking about at all

errant hawk
# rustic rain by mono workflow I mean transform hieararchies and managed components (monob)

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.

rustic rain
#

authoring components is a really cool concept

viral sonnet
rustic rain
#

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

viral sonnet
#

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

twin raven
#

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?

rotund token
#

not without using reflection unless you want to include all your systems in the world

late mural
#

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?

rustic rain
#

[BurstCompile] attribute

rustic rain
#

then you have

#

[MethodImpl(MethodImplOptions.NoInlining)]

late mural
late mural
#

ah, i shall, thank you

rustic rain
#

here more specific on compiling specific methods with burst

late mural
#

ok thanks!

#

ok i think i get it, so all for loops within a IJob thingy should burst compile?

rustic rain
#

all code within burst compiled job is bursted

late mural
#

ok fascinating!

#

having an unsafe IJob is ok right? (im using c style arrays)

late mural
#

oh i see having a managed array inside a job is not allowed, that is unfortunate

narrow scaffold
#

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?

late mural
#

hey, wondering how you debug errors in jobs, as im getting this error, and i dont even know where to start looking lol

late mural
balmy thistle
balmy thistle
# late mural What's a callstack?

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

late mural
#

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!

balmy thistle
#

sweet

late mural
#

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

balmy thistle
#

by components would be my guess

robust scaffold
#

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.

viral sonnet
#

great find!

robust scaffold
errant hawk
#

So excited lmao

narrow scaffold
#

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.

rustic rain
#

you have to use hybrid approach

#

for animated characters

viral sonnet
#

other than that you are out of luck and need to use GOs

ocean portal
robust scaffold
viral sonnet
errant hawk
unborn totem
#

hello all

#

does anyone here know if com.unity.netcode requires entites 0.51?

balmy thistle
#

Depends on the version

unborn totem
#

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

balmy thistle
#

All the 0.51 packages were released together

unborn totem
#

ok, so Netcode 0.5, the version just before 0.51 could be for Entities 0.17 then

balmy thistle
#

0.50, and no because all the 0.50 packages were also released together

#

before then it was the wild west

unborn totem
#

oh ๐Ÿ˜›

#

ok then

#

well I can always manually install it and look at the package-lock file I guess

balmy thistle
#

always an option

unborn totem
#

thanks

unborn totem
#

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 lul

#

maybe because the preview.# versions aren't documented in the changelog

elfin spire
#

did you guys know that handle dependencies is much slower than schedule then complete? it was a surprise

whole gyro
rotund token
#
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```
viral sonnet
elfin spire
elfin spire
raw mica
#

@rotund token which version of Unity are those timings from?

viral sonnet
raw mica
#

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.

rotund token
rotund token
#

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

rotund token
#

It might actually already be public - I haven't bothered to confirm though due to effort of getting entities to run there

raw mica
#

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.

rotund token
#

Also use less systems

#

About all you can do until 1.0

devout prairie
#

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

viral sonnet
#

seems like a mistake to me. the verts are still used but empty

rotund token
#

depends what it's testing

viral sonnet
#

true, still an odd setup

rotund token
#

agreed

devout prairie
#

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

nocturne dust
#

Quick question: Unity NetCode for dots, does it have platform limitations? aka can it run on WebGL with websockets?

rotund token
#

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)

devout prairie
#

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

viral sonnet
#

how can i imagine this? an rts click & drag selection?

devout prairie
#

sweeping the frustrum-shaped collider back towards the camera works

viral sonnet
#

huh, i'd just use the collisionWorld and a overlapBox cast. you probably know the starting and endpoint

devout prairie
#

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

viral sonnet
#

yeah i see the problem ๐Ÿ™‚

rotund token
#

oh that is an interesting problem

viral sonnet
#

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

rotund token
#

i'd probably still do some type of overlap and then just cull individually

viral sonnet
#

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

devout prairie
#

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

rotund token
#

๐Ÿคทโ€โ™‚๏ธ

#

you can crunch a lot of frustrums pretty quickly

devout prairie
#

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

viral sonnet
#

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

devout prairie
viral sonnet
#

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

devout prairie
#

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

devout prairie
#

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.

devout prairie
#

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);
    }
}
rustic rain
#

should be a tiny bit faster and potentially vectorizable

devout prairie
#

so burst doesn't pickup on that and compile it in the same anyway?

rustic rain
#

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

devout prairie
#

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

rotund token
#

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

devout prairie
#

interesting, thanks

snow iron
karmic basin
#

Great ! We have some in the pinned messages, but always nice to refresh with more recent resources ๐Ÿ™‚

safe lintel
#

pinned message here should probably be updated ๐Ÿ™‚

devout prairie
#

@solar spire

silk nimbus
#

Hello, I am facing two issues in my project which uses DOTS. Can anyone please help me with this?

  1. 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.
#
  1. 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.
viral sonnet
safe lintel
#

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

rotund token
#

class System : ISystem
i need unity to add a static analyzer for this to save me from myself

balmy thistle
#

Great idea

dense crypt
#

How can I get ComponentData if all I know is the TypeIndex?

rotund token
#

so you don't know what component it is?

#

you can get ComponentType using ComponentType.FromTypeIndex()

#

from there you can get dynamic handles

dense crypt
#

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

rotund token
#

and use info from typemanager about elementsize etc

#

to do with it as you will

#

var components = chunk.GetDynamicComponentDataArrayReinterpret<byte>(this.ComponentType, this.ElementSize);

dense crypt
#

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

rotund token
#

not really

dense crypt
#

I suppose I could use a binary formatter or similar, but was hoping there's a native solution

rotund token
#

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

rustic rain
#

what do you reinterpret it as?

#

and how do you plan to use it?

dense crypt
#

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

rustic rain
#

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

tropic venture
#

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

rustic rain
#

why not start by attaching logcat?

tropic venture
#

is that in the profiler?

rustic rain
#

nah, it's package

#

or you do it manually through adb

#

should just look up Unity tutorial on it

tropic venture
#

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?

rustic rain
#

errors

#

what if it's screaming errors on mobile

#

xD

tropic venture
#

hm what if ๐Ÿค”

#

i thought i already made the shaders SRP-batcher compatible....

misty wedge
#

Is it somehow possible to schedule a deferred parallel job based on the length of a specific dynamic buffer?

dense crypt
misty wedge
#

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

tropic venture
#

why would the URP/* shaders have compatibility issues with hybrid renderer?

tropic venture
#

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?

misty wedge
#

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

misty wedge
tropic venture
#

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

misty wedge
#

Are you using hybrid renderer?

tropic venture
#

yes

tropic venture
tropic venture
#

is this documented somewhere?

misty wedge
#

Of course

tropic venture
#

please do share link

tropic venture
#

awww maannnnn

#

is it planned for ECS 1.0 ?

misty wedge
#

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

tropic venture
# misty wedge

this does imply some degree of hardware requirements kinda sorta

misty wedge
#

Well yes, for the hybrid renderer, but not for DOTS / ECS as a whole

#

They are entirely separate

tropic venture
#

right

tropic venture
# misty wedge

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?

misty wedge
#

If you have no significant gameplay code your game will (probably) not run faster by moving stuff over to ECS

tropic venture
#

..unless i benefit from the hybrid renderer?

misty wedge
#

Yes, hybrid renderer should run faster than using game objects for rendering

tropic venture
#

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?

misty wedge
#

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

tropic venture
#

technically the did show it off on mobile as well

misty wedge
#

Then you have your answer

tropic venture
#

so back in 2018 they had some sort of hybrid renderer which also might have only worked with vulkan?

misty wedge
#

I'm guessing it's still not easy and requires "manual" optimization

tropic venture
#

i see

misty wedge
#

There are limits you will run into regardless, especially on mobile devices

balmy thistle
#

Megacity ran on mobile

misty wedge
#

hybrid renderer isn't magic and will let you render infinite objects at no cost

tropic venture
#

funny you should mention that,

tropic venture
misty wedge
#

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)

tropic venture
#

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

misty wedge
tropic venture
#

ok

misty wedge
tropic venture
#

i see

misty wedge
tropic venture
#

what's the plan for openGL ES then, they wont use BatchRendererGroup for that?

misty wedge
#

I'm guessing they will add support for it in the future, at least the hybrid renderer docs state as much

tropic venture
#

hopefully nearer future than later... maybe they'll just decide meh forget OpenGL/ES... only future devices supported kthxbai...

misty wedge
#

I'm happy I have very low rendering requirements so I can just use normal URP rendering ๐Ÿ˜…

rustic rain
tropic venture
misty wedge
#

even on mobile

tropic venture
# rustic rain why is it even a problem?

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)

rustic rain
#

how old do you want ,kek

#

Vulkan is supported on almost anything past 2016, no?

dull scroll
#

Hello where can I learn about best practices to reload a scene with DOTS or load another scene? Whatever I tried I get problems.

tropic venture
tropic venture
#

TBH i dont have that LG G4 with me right now so can't check, will do so in a few hrs

tropic venture
# misty wedge You'd probably be able to do something like this in "normal" unity with lots of ...

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?

misty wedge
#

I mean it depends a lot on the scene, but I'd start with draw calls first

tropic venture
misty wedge
#

Make sure everything that can be is instanced

misty wedge
tropic venture
misty wedge
#

There's a reason why my project has low rendering requirements ok_handbutflipped

tropic venture
#

heh

#

2D? ๐Ÿ˜›

misty wedge
#

of course

tropic venture
#

hah of course

misty wedge
#

There's lots of stuff that developers have used over the years, replacing distant trees with billboards, instancing, pooling, etc

tropic venture
#

right

misty wedge
#

Depends a lot on what's bottlenecking you

tropic venture
#

last i profiled it in regular game-objects on mobile i think the main load was Draw Opaque and Draw Transparent calls

misty wedge
#

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

tropic venture
#

tree leaves use transparency cut-outs

#

alpha clipping

#

otherwise this

misty wedge
#

But why not make it opaque and use alpha clipping

#

The actual leaves aren't transparent

tropic venture
#

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

misty wedge
#

What surface type are you rendering it as? Transparent or opaque?

tropic venture
#

opaque

#

i figured that one out a little while ago

#

not sure if it matters but i'm also seeting render face = both

misty wedge
#

I'd check the frame debugger and see how exactly the frame is rendered

tropic venture
misty wedge
#

No, the frame debugger

tropic venture
#

ah

misty wedge
#

Also 2k draw calls is a lot for such a small amount of geometry

#

especially on mobile

tropic venture
#

i think i didnt turn on instancing

#

but again - not sure instancing is available for the LG G4 i'm hoping to target

misty wedge
#

I'd check this part of the docs, it explains a lot of basic performance optimization techniques as they pertain to Unity

dull scroll
#

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?

misty wedge
dull scroll
#

I mean I just want to reset the world and reload the scene

misty wedge
#

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

dull scroll
#

from a monobehaviour?

misty wedge
#

From wherever you like

#

(as long as it's on the main thread)

tropic venture
dull scroll
misty wedge
tropic venture
#

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

tropic venture
# tropic venture

IIRC there were about 2K objects in the scene when i screenshotted that

#

very cool tool this frame debugger ๐Ÿ‘

viral sonnet
#

handling entities just with scenes needs quite a lot of manual work to get right

dull scroll
viral sonnet
#

a subscene is a special component in a scene that automatically converts your gameobjects to entities.

misty wedge
#

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...

viral sonnet
#

depends in what capacity they change and how long they live

misty wedge
#

a few seconds maybe

viral sonnet
#

if you can batch create the entities i found pooling not necessary.

misty wedge
#

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

viral sonnet
#

where's the difference in scheduling?

misty wedge
#

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)

karmic basin
#

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 ๐Ÿ˜ž

misty wedge
misty wedge
#

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?

rotund token
#

!

safe lintel
#

@karmic basin dont think they exist yet

#

at this rate im not sure if they ever will ๐Ÿฅฒ

rustic rain
#

on PC

tropic venture
#

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

rotund token
#

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.

tropic venture
#

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

karmic basin
#

Always study feasibility before jumping right into it with your two feet ๐Ÿ˜„

rotund token
#

haha reading manuals

karmic basin
rotund token
#

start writing code, then complain about a bunch of design decisions

#

this is the way

karmic basin
#

๐Ÿค“ haha yeah where's the fun in books !

safe lintel
#

anyway Ive never used a joint motor in physx, I just want other features they talked about ages ago. they sound kinda important ๐Ÿ˜ฆ

tropic venture
safe lintel
#

only a month ago. just wait until you've been waiting for features and fixes for years ๐Ÿ˜…

tropic venture
#

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

rotund token
safe lintel
#

animation ๐Ÿ˜ญ

karmic basin
karmic basin
viral sonnet
#

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

rotund token
#

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

viral sonnet
#

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

rotund token
#

BindingPath is part of BindableElement

viral sonnet
#

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

rotund token
#

UnityUI
i'm not sure that's true

viral sonnet
#

probably not for the current version but the workflow is excellent imo

misty wedge
#

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

rotund token
#

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

viral sonnet
#

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

misty wedge
#

They just released a large ui toolkit specific sample

#

I haven't looked at it though

rotund token
#

it's actually on my todo list for my day off today

#

just curious how it compares to what i've been doing

viral sonnet
#

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

rotund token
#

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

viral sonnet
#

when the major downside of UnityUI is performance it's the most important metric

rotund token
#

well personally

#

i think ui toolkit workflow is much better

misty wedge
viral sonnet
#

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.

misty wedge
#

You mean binding as in callbacks on classes / IDs?

viral sonnet
# misty wedge UnityUI performance is terrible

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.

rotund token
rotund token
#

and up to 10ms on 3xxx ryzen

misty wedge
viral sonnet
#

what's happening in those spikes?

rotund token
#

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).

viral sonnet
#

how much UI panels are we talking about here that this gets into such a spike?

rotund token
#

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

viral sonnet
#

so the main problem seems to be the overly aggressive updates of layouts that aren't even needed

rotund token
#

if ugui is your jam, it's unlikely to be removed anytime soon

#

hell we still have OnGUI support

viral sonnet
#

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

viral sonnet
# rotund token if ugui is your jam, it's unlikely to be removed anytime soon

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);

rustic rain
#

and special setting

#

that scales texts

#

makes workflow pretty fluent

viral sonnet
#

match game view sets the resolution to the game view. what's your special setting?

rustic rain
#

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

viral sonnet
#

well that explains a bit. is there no way to get that in ui builder?

rustic rain
#

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

viral sonnet
#

btw @rotund token they bunch all screens in the MainMenu.uxml. haven't found a dynamic load yet of a panel

rustic rain
#

which you can test right in editor

rotund token
viral sonnet
#

didn't know about StyleBackground. seems easy enough

rotund token
#

well redid my whole asset management, thanks eizenhorn...

safe lintel
#

any particular reason why? also was this something eizenhorn posted on the forums about?

rotund token
#

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

safe lintel
#

can you link me part of the convo if it was here? getting a case of fomo ๐Ÿ™‚

rotund token
#

here onwards

safe lintel
#

ty

rotund token
#

(you can see the previous convo that he replied to)

safe lintel
#

my asset management is so haphazard, one scheme here, another scheme there, then just folders where I dump things willy nilly

rotund token
#

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

safe lintel
#

on first glance maybe I dont need this complexity

rustic rain
#

Is there a way to check whether current execution is in burst?

rotund token
#

ecb does that

rustic rain
#

Hmm

#

I just got a fun idea

#

Burstable delegates

viral sonnet
rotund token
#

that was basically the system i replaced

rotund token
#

something like this

rustic rain
#

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

rotund token
#

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
safe lintel
#

hmm that second part sounds really useful

rustic rain
#

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

viral sonnet
#

did i get this right. you now have a SO database which relates guid to integer id?

rotund token
#

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)

viral sonnet
rotund token
#

im not using GUID though

viral sonnet
#

why not, every SO has one

rotund token
#

because i dont want to store GUID on components

#

and i can't just do
Instantiate(NativeArray[index])

viral sonnet
#

i think eizenhorn does it like this. at least the 2nd screenshot he posted looked like this.

#

guid#name

rotund token
#

he specifically has sequential IDs

#

and they're solution to merge issues is just, push the new ID straight away quickly

viral sonnet
#

yeah, with that kind of referencing you can generate a sequential unique id without worries

rotund token
#

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

viral sonnet
#

the only more safe way is to have some kind of database in between

rotund token
#

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

#

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

viral sonnet
#

some really nice benefits

rotund token
#

so a designer doesn't have to remember to add their new definition to some arbitrary list on a SO

viral sonnet
#

yeah that sucks so hard

rotund token
#

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

viral sonnet
#

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 ๐Ÿ˜„

rotund token
#

i'm not really sure why you'd need CreateAdditonalEntity

#

for what i'm doing

viral sonnet
#

you pack it all into one. i seperated them on types

rotund token
#

i don't really get it

#

why do you need new entities though

viral sonnet
#

oh wait, that was for the SOs to blob converter. slightly different but samey ๐Ÿ˜„

rotund token
#

the first experimental version coming Pretty Soon Now (tm)
๐Ÿ˜‰

viral sonnet
#

WHO SAYS THAT?

rotund token
viral sonnet
#

noice

rotund token
viral sonnet
#

after that long post, i still don't see much changes

honest plinth
# tropic venture but i was hoping to target medium-low end devices such as this LG G4

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 ๐Ÿ˜‰

devout prairie
#

I dumped this code into a job:

#

what am i missing here

rotund token
#

are you using other temp memory

#

inside that loop

devout prairie
#

yes in the job but not in the loop

rotund token
#

hithovered entities

#

nativehashset

#

temp memory

#

?

devout prairie
#

ahh

#

ok so what's the issue with that?

rotund token
#

get rid of your foreach basically

#

the 'AsArray' is getting invalidated by the other temp allocator

devout prairie
#

ah shitsticks

#

ok thanks

#

so just use an index to iterate should be ok??

rotund token
#

yeah

devout prairie
#

it makes some kind of sense i guess, and is no big hassle

#

be nice if they fix it tho

rotund token
#

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

devout prairie
#

it could indeed

#

yap

rotund token
#

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

devout prairie
#

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

rotund token
#

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๐Ÿคทโ€โ™‚๏ธ

devout prairie
#

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

devout prairie
#

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

rotund token
#

ive said a lot of things

#

and i dont recall this at all

#

i'll need a reference to myself ๐Ÿ˜„

devout prairie
#

haha 2019 i think

rotund token
#

oh this would have been hybrid renderer v1

devout prairie
#

ahh yeah

rotund token
#

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

devout prairie
#

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

rotund token
#

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

devout prairie
#

when adding and removing Disabled i'm noticing this 1 frame glitch where the objects render out of place for some reason

rotund token
#

i'm going to hate the code

devout prairie
#

hehe no doubt

rotund token
#

as i believe the components should still update

devout prairie
#

Can't really see any issue with the code so wondering if it's when and where i'm doing this

rotund token
#

what's the issue for unobservant people

devout prairie
#

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

rotund token
#

isn't that the intended behaviour ๐Ÿค”

#

what buffer you using?

devout prairie
#

end init

#

and during it during init

devout prairie
rotund token
#

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)

devout prairie
#

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

#

๐Ÿค”

rotund token
#

why wouldn't use presentation buffer if you were doing it in simulation

devout prairie
#

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

rotund token
#

(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)

devout prairie
#

ok no i appreciate that

#

i'm a little unsure on the exact order and usages of those things still if i'm honest

rotund token
#

init | simulation | presentation

devout prairie
#

and the renderer actually renders between presentation back to init?

#

using begin presentation with the system in simulation actually solves that issue

rotund token
#

hybrid renderer updates in presentation

#

the actual render stuff happens after that

#

init called start* of frame

devout prairie
#

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

misty wedge
#

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

pliant pike
#

maybe don't use the ECB?

misty wedge
#

The majority are (e.g. position isn't)

celest jay
#

You could define the variations in one or more ScriptableObject(s) and just pass that into your instantiated GameObject

misty wedge
#

I don't follow, I'm not using any gameobjects

celest jay
#

you are spawning prefabs, what do you thing that does?

misty wedge
#

Create an ecs entity

celest jay
#

Sorry, misread the question

misty wedge
#

๐Ÿ˜…

misty wedge
pliant pike
#

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

misty wedge
#

Why two steps?

pliant pike
#

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

misty wedge
#

Well yeah but it just calls EntityManager functions, how is that two steps

pliant pike
#

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

misty wedge
#

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)

pliant pike
#

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

misty wedge
#

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

pliant pike
#

I'm not an expert but I'd just do it when you need it

misty wedge
#

Are there any rules against creating "prefabs" at runtime in ECS?

#

(specifically using the Prefab component)

pliant pike
#

not as far as I know

#

ECS is kind of new and everyones figuring it out as they go to be honest

misty wedge
#

I wouldn't really call it new at this point tbh, It's been in development for so long already ๐Ÿ˜…

pliant pike
#

true but they keep changing stuff so your constantly have to learn and experiment

rustic rain
#

smth like

#

saving blueprint

#

for some building

misty wedge
#

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)

tropic venture
rustic rain
#

not sure at least

tropic venture
#

ah

devout prairie
#

Any particular reason why NonUniformScale may be ignored with an instantiated prefab?

rustic rain
#

could you rephrase?

devout prairie
#

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.

rustic rain
#

๐Ÿค”

devout prairie
#

I'm setting LTW

rustic rain
#

๐Ÿ•ฏ๏ธ

devout prairie
#

But not building scale into the 4x4

#

Doh

rustic rain
#

why do you even set LTW

devout prairie
#

just simpler for the particular use case

gloomy venture
#

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.

rustic rain
gloomy venture
rustic rain
#

especially important concepts and conversion workflow

gloomy venture
rustic rain
#

yes, that's basically what you should do

#

but just keep going

#

conversion in Unity ECS is pretty important

gloomy venture
# rustic rain 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 ๐Ÿ‘

modern glacier
#

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.

whole gyro
# modern glacier 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

errant hawk
#

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

modern glacier
whole gyro
modern glacier
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

whole gyro
#

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

modern glacier
#

One message removed from a suspended account.

gloomy venture
# rustic rain conversion in Unity ECS is pretty important

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. ๐Ÿ˜ฎ

whole gyro
#

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.

gloomy venture
# whole gyro If you need full skeletal animation, best option is a hybrid approach where you ...

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?
rustic rain
#

In fact, you can everything in Unity ECS, but animations with hybrid approach

whole gyro
# gloomy venture Ok, I'm trying to get a handle on the options here, so can you perhaps confirm w...

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.

rustic rain
#

but you'll have to reimplement many things

#

as it's pretty raw

#

currently

gloomy venture
whole gyro
#

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.

whole gyro
gloomy venture
# whole gyro Thanks. I know what the Open Project is, but haven't dug into it enough to know ...

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...

โ–ถ Play video
gentle gyro
#

Hi guys,

It seems you can't use Dots with the Quest 2. Can anyone confirm or deny this?

gloomy venture
whole gyro
#

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.

gloomy venture
rustic rain
#

which basically copies entity transform to GO transform

whole gyro
#

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.

rustic rain