#archived-dots

1 messages ยท Page 263 of 1

rotund token
#

on server the runtime code to spawn the gameobject doesn't run

#

i might even consider removing CopyMode from authoring

#

and into the same part as instantiation

#

to avoid adding it to server

#

but anyway this here isn't that big a deal, pretty standard probably

#

the cool stuff is just being able to pick skin mesh renderers in scene view and returning the entity

#

it just ties the whole thing in

viral sonnet
#

yeah, that's cool to be able to do that. I don't have much trouble in my current project but in another it was impossible to work without an entity picker. I'm still perplexed that Unity hasn't done anything for it.

#

with an entity picker everything seems so much more solid

pliant pike
#

so you have a gameobject/skinmeshrenderer loosely tied to an entity?

viral sonnet
#

with no presentation entity, how are you handling animations? I mean there's no downside on putting an animation IComp on the main entity but I rather keep the archetype clean from anything presentation like

rotund token
#

main entity has the animator

#

for my client/server architecture the client is nearly entirely presentation so this is fine imo

#

saves an extra copy between things

#

if anything i prefer to move logic to separate entities

muted field
#

Do you have any advice on how to debug jobs, since we can't step through like normal code, mine compiled but the output is wrong so i have logic error in execute function

rotund token
#

you can either turn off burst and debug like normal

#

or turn on native debug mode and hook up a native debugger and debug like normal (requires vs not rider)

viral sonnet
#

damn, since the new VS plugin where for some reason Entities and Collections are added to the main project, VS is choking hard on every line :/

rotund token
#

yeah i've been trying to find a way to remove that

#

bit annoying

#

dont want to see 2134 new projects in the side

#

i already have 12356234 of my own

muted field
rotund token
#

oh you mean the contents?

#

unity setup debug viewers for them
[DebuggerTypeProxy(typeof(UnsafeListTDebugView<>))]

#

so they should work

#

no idea about vs watch tools (assuming vs)

#

i haven't used vs much in the past few years

#

literally only time i pull it up id to debug native stuff

viral sonnet
#

hm, doesn't seem to have anything to do with the actual "Visual Studio Editor" package. Entities and Collections are created nonetheless.

muted field
#

how does that attribute work

rotund token
#

unfortunately you're own packages in the /Packages/ folder won't generate if you turn it off

viral sonnet
#

i have turned this all off

rotund token
#

did you delete the actual project files

viral sonnet
#

yeah, deleted everything a bunch of times. csproj and sln files

#

I'm actually not sure when this started. I think it did with Unity 2020.3.33

#

but that doesn't make any sense

rotund token
#

hmm interesting

#

i tested this just last weekend

#

and could stop entities/collections generating projects

#

but since 90% of my code exists in the packages folder it doesn't help me much

viral sonnet
#

ahh, maybe it has to do with the asmref

rotund token
#

oh yeah

#

that could be it

viral sonnet
#

hm, I have them all in Assets/Plugins right now. Question is, where could I move them?

rotund token
#

do you have any code in Packages/

#

?

#

if not put them in there and it might hide it for you

viral sonnet
#

directly in the folder? no, i'll try

rotund token
#

not just directly

#

you'll need to turn it into a package

#

with a package.json etc

viral sonnet
#

yeah, wanted to do that if all fails.

#

I hope that's not the only way because frankly, having to add packages to an asset is annoying

#

still better than the editor lagging though

#

well, problem solved at least ๐Ÿ™‚

rotund token
#

look at my project list ๐Ÿ˜

viral sonnet
#

question about job handles. Is there any difference if you write Schedule(Dependency) or just Schedule() which uses default then?

#

daaaym

#

You are using Rider, right? Is it also slowing down like crazy?

#

Now I can't peek into entities methods and see the code. There's always something new breaking ... Previously it was aaaall working so fine. Then I couldn't see the decompiled code anymore, just the signatures. Now I can't see anything anymore. How is this even happening...

rotund token
#

once it's cached it's all fine

#

performance is why i moved away from VS in the first place

#

but features is why i stay with rider

viral sonnet
#

ah cool, VS takes like 20 seconds to evaluate a new line of code if it's correct with collections as project

rotund token
#

well that sounds horrible

viral sonnet
#

Yeah and VS is so expansive on top. I mean, I got and need it for work. The pricing looks pretty good for 1 year of Rider

#

do you have resharper too or just base?

rotund token
#

resharper is only a thing for VS

#

all those features are built in (and much faster) in rider

#

i used to use resharper but it slows down VS even more

#

(work pays for my copy though)

viral sonnet
#

yeah, also what I noticed with resharper in VS

rotund token
#

rider gives like discounts for future years, 20% second, 40% off third onwards

#

nice but kind of wish that 40% off was just the default pricing

#

be so much easier to recommend

viral sonnet
#

yeah, 40% is quite the discount

rotund token
#

at least for the individual pricing

#

make the companies stick with you to get a discount

viral sonnet
#

true, I don't understand why individuals are milked so much anyway. companies should make them enough money.

#

to be fair, rider is cheap compared to other software nowadays

muted field
#

so i got my polygon tester working but just curious about if i am doing it the best way.

currently i loop through my polygons on the main thread (Since theres only a handful of them)

the job takes the vertices of polygon A and polygon B (as a paralleljob for each vertex ) and runs the test in my main loop

    var job = new PolygonPolygonOverlap(poly1, poly2, flag);
    var handle = job.Schedule(poly2.Verts.Length, 1);

but im calling complete on the very next line, some of these polygons have thousands of vertices to check, am i not getting any benefit by calling complete on the next line ?

solemn hollow
#

@muted field you certainly lose the advantage of not blocking the main thread but you still get burst and parallel execution.

muted field
#

so whats the alternative? schedule it then poll in the update method to see if its complete? @solemn hollow

solemn hollow
#

the code that needs the result should schedule another job with a dependency on this PolygonPolygonOverlap

muted field
#

what would that job do tho? be empty?

solemn hollow
#

if you don't need the result of your job then i guess you don't need to do anything. just let it complete at any point later in the frame.
i thought u need the result for another operation that should then be done in this next job i spoke about.

#

btw are you using ecs or just monobehaviours with jobs?

muted field
#

i was reading the result on the main thread outside of the job

#

straight after i call complete atm

#

like this:

            for (int i = 0; i < _polygons.Length; i++)
            {
                for (int j = 0; j < _polygons.Length; j++)
                {
                    if (i == j) continue;
                    var p1 = _polygons[i];
                    var p2 = _polygons[j];
                    flag[0] = false;


                    var job = new PolygonPolygonOverlap(p1, p2, flag);
                    var handle = job.Schedule(p2.Verts.Length, 1);

                    handle.Complete();

                    if (flag[0])
                    {
                        Debug.Log("True");
                        result.Add(new int2(i, j)); // these 2 polys overlap
                        Debug.Log(new int2(i, j));
                    }
                }
            }
#

@solemn hollow are you saying this is basically going to be on the main thread all the time ?

rotund token
#

yes that will be main thread

muted field
#

how can i take full advantage of it then ?

#

poll complete in update?

rotund token
#

thats the general way for doing it in monobehaviours

#

if(!dependecy.IsComplete)
return;
dependency.Complete(); // this is still required to finalize

muted field
#

ah okay. is there a way to collect all jobs and schedule at once aswell im fairly sure i saw an example of that at one point

rotund token
#

you should schedule individually

#

but you can collect all handles and merge the handles into one

#

JobHandle.CombineDependencies()

muted field
#

doesnt that only apply if jobs depend on others, in my case they are all stand alone and dont rely on others

rotund token
#

JobHandle.CombineDependencies()
doesn't add them dependencies as each other

#

it just combines all the handles in to 1

#

so that you can wait on them all to complete

muted field
#

oh i see

#

okay thanks for the help ๐Ÿ™‚

rustic rain
#

bruh

#

did Hybrid Renderer learn how to render objects without Companion GO?

#

looks like it did

#

omg, feels so bad

#

I need some kind of a way to draw lines. Gizmos for player, to see where characters are going.

#

Without Aline it feels like such a pain

#

since I need game objects, which I hate at this point

rotund token
#

its never rendered game objects

rustic rain
#

oh

rotund token
#

are your lines just for debugging?

#

you can just use Debug.DrawLine()

rustic rain
#

no, it's player gizmos

#

shows direction of where ship is flying to

rotund token
#

oh well

#

that seems like something you'd have to code yourself

#

also not very hard

rustic rain
#

Is there a way to use built in Companion GO Tranform system?

#

I guess there's not

rustic rain
#

Ahem, very weird situation

#

So, basically I instantiate new GameObject() in my authoring component

#

aaaaand, this game object for some reason only exists when I open subsystem in edit mode

#

So, I launched game, no game objects

#

I turned on edit mode and they suddenly exist

#

How do I avoid it?

rotund token
#

what component is on it

rustic rain
#

empty

#

I use it so I can add other game objects with components on it

#

through prefabs

#
            dstManager.AddComponentObject(entity,
                new CompanionGameObjectComp() {Companion = new GameObject()});
rotund token
#

well i dont know what part you think is setting up a companion object

rustic rain
#

looks like this

rotund token
#

that gameobject ain't going to exist

muted field
#

does any of these native containers have a wrapper for readonly ? like normal collections have IReadOnlyList etc?

rustic rain
rotund token
#

companion objects are created when unity finds one of these components

        {
            typeof(Light),
            typeof(LightProbeProxyVolume),
            typeof(ReflectionProbe),
            typeof(TextMesh),
            typeof(MeshRenderer),
            typeof(SpriteRenderer),
            typeof(VisualEffect),
#if PARTICLE_SYSTEM_MODULE
            typeof(ParticleSystem),
            typeof(ParticleSystemRenderer),
#endif
#if SRP_7_0_0_OR_NEWER
            typeof(Volume),
            typeof(SphereCollider),
            typeof(BoxCollider),
            typeof(CapsuleCollider),
            typeof(MeshCollider),
#endif
#if HDRP_7_0_0_OR_NEWER
            typeof(HDAdditionalLightData),
            typeof(HDAdditionalReflectionData),
            typeof(DecalProjector),
            typeof(PlanarReflectionProbe),
            typeof(DensityVolume),
#if PROBEVOLUME_CONVERSION
            typeof(ProbeVolume),
#endif
#endif
#if URP_7_0_0_OR_NEWER
            typeof(UniversalAdditionalLightData),
#endif
#if HYBRID_ENTITIES_CAMERA_CONVERSION
            typeof(Camera),
#if HDRP_7_0_0_OR_NEWER
            typeof(HDAdditionalCameraData),
#endif
#if URP_7_0_0_OR_NEWER
            typeof(UniversalAdditionalCameraData),
#endif
#endif
        };```
#

in the subscene

#

if you want a gameobject to put something on, just create it at runtime

rustic rain
rotund token
#

so what?

#

soon as you close your subscene this game object is delete

                new CompanionGameObjectComp() {Companion = new GameObject()});```
solemn hollow
rotund token
#

you haven't converted it to anything

#

so it's deleted

rustic rain
#

how can I create it outside of subscene then?

rotund token
#

just have a system create it

rustic rain
#

oh

#

not through authoring component, I see

solemn hollow
#

sry earlier i assumed you are already doing it in a system since you asked how to query it

rustic rain
#

well, I kinda did in a mixed way kek

#

I add prefab through authoring

#

and then convert it to other GO through system

rotund token
#
    var go = Object.Instantiate(create.Prefab);
    EntityManager.AddCompnentObject(entity, go);
}).WithStructuralChanges().Run();```
rustic rain
#

but all that assumed I have companion game object to attach to

#

yeah, I get the idea

#

I just didn't realise

#

that detail regarding GO being deleted in subscene

solemn hollow
#

yes hybrid workflow with subscenes is not really intuitive atm

rustic rain
#

I hope I won't need hybrid at all

muted field
#

why do i suddenly not have access to Schedule function ?

rustic rain
#

what is T?

muted field
#

public void Add<T>(in T job, Action<IJob> callback = null) where T : IJob

rotund token
#

add struct

#

requirement

muted field
#

still nothing

#

thats weird right ?

rotund token
#

works fine

#

remove the in

#

wait no that doesnt change anything still works

muted field
#

oh there we go now it shows

#

that was odd

rustic rain
#

hmmm
I create game objects in systembase now

#

still they are inside subscene

#
    public partial class CompanionGameObjectAddSystem : SystemBase
    {
        protected override void OnUpdate()
        {
            var em = World.EntityManager;
            Entities.WithStructuralChanges().ForEach((Entity e, in AddCompanionTag tag) =>
            {
                GameObject go = new GameObject();
                em.AddComponentObject(e, new CompanionGameObjectComp() {Companion = go});
                #if UNITY_EDITOR
                go.name = tag.Name.ToString();
                #endif

                em.RemoveComponent<AddCompanionTag>(e);
            }).Run();
        }
    }
pulsar jay
rustic rain
#

I just learnt that game objects can belong to subscene

#

I have little to no idea how to assign them to one xD

rustic rain
#

I thought there is no scene differentiation

#

oh

solemn hollow
#

didnt u say u want to add your gameobject as a child to the companion? i dont think its a good idea to move the companion out of the subscene. why do u need to do this anyway?

rustic rain
#

empty as base

rustic rain
#

in this case

#

it's Line Renderer

#

nah, moving away GO outside didn't help

#

hmm

solemn hollow
#

make a prefab with a linerenderer and spawn that instead of an empty GO

rustic rain
#

I do have that

solemn hollow
#

and in your query get CompanionLink

rustic rain
#

but in order to have vesatile system

#

I need game object to hook into

solemn hollow
#

then you have access to the transform of the comapnion. add your spawned GO as a child

rustic rain
#

with all other prefabs like this

rustic rain
#

there's no CompanionLink

#

kek

solemn hollow
#

huh

rustic rain
#

It's not created for my entities

#

which is exactly why I try to create my own here

#
            var em = World.EntityManager;
            Entities.WithStructuralChanges().ForEach((Entity e, in AddCompanionTag tag) =>
            {
                GameObject go = new GameObject();
                em.AddComponentObject(e, new CompanionGameObjectComp() {Companion = go});
                #if UNITY_EDITOR
                go.name = tag.Name.ToString();
                #endif

                var currentScene = SceneManager.GetActiveScene();
                SceneManager.MoveGameObjectToScene(go, currentScene);

                em.RemoveComponent<AddCompanionTag>(e);
            }).Run();

This also didn't help

solemn hollow
#

CompanionUpdateTransformSystem

#

check in there

#

maybe you just didnt reference the assembly?

rustic rain
#

?

#

wdym

solemn hollow
#

or is it internal now :S

rustic rain
#

I do have access to it

#

I used tertles trick

#

with internal

#

point is, it's not created at all

#

Hybrid Renderer renders mesh directly

#

without creating GO

solemn hollow
#

ah yes you need to trigger the creation with one of the hybrid components i guess...

rustic rain
#

which I don't have

#

and don't need

solemn hollow
#

you could add an empty spriterenderer to trigger it and later delete it. until you find a better solution

#

or you write the transform sync system yourself

rustic rain
#

my GO are being deleted/or not created

#

I'm not even sure

solemn hollow
#

thats strange. i do spawn gameobjects too cause i need stuff from the 2D animations package. no problems there

rustic rain
#

it only works if subscene is in edit mode

#

without

solemn hollow
#

here my game is running with the gameobjects spawned without the subscene beeing in edit mode

rustic rain
#

how do you create them?

solemn hollow
#

huh why cant i post code? 0.o

#

sry new to this discord

#

what are the code tags here?

rustic rain
#

3 symbols of these

#

at start and at end

#

they are on ~ button

solemn hollow
#

im on a mac keyboard. need to search a bit ๐Ÿ˜„

#
Entities.WithNone<IsBootsTrapped>().ForEach((Entity entity, HybridArtManaged hybridArtAComp,in HybridArt hybridArt) =>
        {
            hybridArtAComp.artInstance = MonoBehaviour.Instantiate(hybridArtAComp.artPrefab);
            hybridArtAComp.artInstance.name =
                "(" + hybridArt.rootEntity.Index + "," + hybridArt.rootEntity.Version + ")" + hybridArtAComp.artInstance.name;

            ecb.AddComponent(hybridArt.rootEntity, new HybridArtChild
            {
                childEntity = entity
            });

            if (hybridArtAComp.artInstance.GetComponent<Animator>())
            {
                hybridArtAComp.animator = hybridArtAComp.artInstance.GetComponent<Animator>();
            }
            
            ecb.AddComponent(entity, new IsBootsTrapped());
            
        }).WithoutBurst().Run();```
glacial bolt
solemn hollow
#

thanks!

#

Dont be confused by the extra stuff in there. i just split up the component into a slow managed and fast unmanaged one

rustic rain
#

wha

#

now it works

solemn hollow
#

the managed component contains the prefab and the reference to the instanciatedGo

rustic rain
#

I don't understand anything

#

I literally did nothing to code

solemn hollow
#

maybe the subscene had to be reconverted

rustic rain
#

maybe

uncut rover
#

Hello, do anyone know how to make the CopyTransformToGameObject system ??

rotund token
#

Can't you just look at the existing system and copy that?

#

(what are you trying to achieve?)

rustic rain
#

oh man, feels good that it works
feels bad that I spent almost hour on it

uncut rover
rotund token
#

add CopyTransformToGameObject component

#

add Transform to entity - EntityManager.AddComponentObject(entity, gameobject.transform)

#

that's all you really need + LocalToWorld

#

main thing is just add the Transform so it can be accessed by TransformAccessArray

uncut rover
#

Thanks, I was just adding Transform component, not the gameobject's transform...

rotund token
#

i thought you were trying to re-implement the bahaviour or something which is why i suggested looking at system

rustic rain
#

Is there a way to run code only during frame/tick of adding component?
Basically, I want system to only run whenever X component is added.
And another system only to run whenever X component is removed.
And either must only run once per entity.

#

I do have an idea how to do it through adding another component Tag, but I wonder if there's built in way

uncut rover
#

that would be a reactive system which is what your are think about. the only difference is that the tag component is supposed to be a private ISystemStateComponentData in the system.

rustic rain
#

hm

uncut rover
#

Unity is also not supposed to destroy entities that have remaining ISystemStatemComponent so that the system has a chance to do it's clean up when the entity is destroyed.

rustic rain
#

nah, I don't really need this one

#

I just need to be able to react of add or remove

#

so I can clean up LineRenderer points

#

or create them back

#

So I assume this is ready solution by you?

uncut rover
#

yes, but don't take the first post, there are some improvement done later (like detecting tag components) and also other people wit their own implementation.

rustic rain
#

this is lowest message

#

I found

uncut rover
#

should be good then but was not done in entities 0.50 so maybe some adjustments needed.

rustic rain
#

xD

rustic rain
#

Sooooo
I want to make such game, where there would be some X amount of rooms.
And every character can travel freely between them, depending on some rules.

On screenshot you can see how it kind of supposed to look like.
Basically star systems. In order to travel between them, character must get to the edge of a system (which doesn't limit character from going further btw), that points into another system, to which character wants to travel.

What I'm asking for?
How can it be done through code?

Do I just make those rooms in world space?
Or maybe some other tricky way? Which hopefully will be simple enough in order to keep AI travelling between systems freely.

#

In the end all rooms (systems) are same:
Star in the middle. Planets around it.

solemn hollow
#

You could make a world per room. whenever an entity enters a portal you send it to the other world.

rustic rain
#

Is it efficient though?
Goal will be around 100 rooms

astral parrot
#

Hello there, I really need a help, why does the render mesh not working? it doesn't render a mesh and it's material after I spawn randomly on that area.

solemn hollow
# rustic rain Is it efficient though? Goal will be around 100 rooms

I dont know your needs but id imagine you only want to simulate the room where the player is with the highest level of detail. The other rooms could probably run on a lower framerate? thats why i think worlds could be a good fit since you could update them in diffrent rates.

rustic rain
#

Whole world must be simulated fully

pliant pike
#

isn't that what subscenes are supposed to be used for

rustic rain
#

huh, maybe

#

I just can't imagine yet

#

how it even supposed to work

pliant pike
#

that's what the whole megacity, I think I can't remember

#

I don't know, it must be pretty easy to load and unload and manipulate subscenes because thats the whole point

rustic rain
#

well, loading/unloading yes

#

but here the thing

#

I want world to be simulated fully

#

every tick

#

if player is in system 0
System 100 should be simulated in same detail

pliant pike
#

not to be a party pooper but that may not be always be possible

rustic rain
#

that's why it might require smth else

#

not subscenes

pliant pike
#

it depends on what your doing if its just data then I don't see why you couldn't(depending on how much data)

#

you don't need to render all the system, and calculate phsysics etc

#

just separate the data you need from the data you don't

#

and then have that as a background sim that's running all the time

solemn hollow
pliant pike
#

yeah then load the systems when the player enters them using the data from that background sim

rotund token
#

out of interest, in your use case why does a 'background' world help here

#

you can't run worlds in separate threads

#

to me all it sounds like is you're adding overhead

rustic rain
pliant pike
#

well its probably best just to use a thread or several in the current world then, I just meant it as something you calculate all the time in the background

rustic rain
#

I can imagine how to do all that

#

in case where I literally just create rooms in world space

#

in huge distance from each other

#

but I worry about float precision

#

which will quickly degrade, if I try to follow space physics regarding distance between systems

pliant pike
#

well there are tricks for floating point precision

solemn hollow
pliant pike
#

but do you even need to bother with that if the systems are so far apart then just treat them as separate solar systems

rustic rain
#

This game is about living in space.
So in order to jump between systems, you use some kind of FTL drive or smth, which makes big jumps from star to star.
Meanwhile if you simply try to fly from star to star without that drive, you should spend hundreds of years.
Which I'm not sure if it will work out if I simply drop those rooms in world space

pliant pike
#

if your not using things like physics etc, if your talking about things like trade you just abstract and simulate things

rustic rain
pliant pike
#

you don't need to literally be travelling between the systems, you just need to pretend the player is

rustic rain
#

yeah, I know

#

but I don't know how

#

one thing is to simply teleport player changing his trasform from 0,0,0 to 100mil,0,0

#

the other is to change his subscene or smth

pliant pike
#

like you can calculate the distance, and how long it would take to travel etc and create the environment around the player according to that

rustic rain
#

that's not what I'm asking about rn

#

how can I put it clearly...

pliant pike
#

I'm pretty sure thats how No Mans Sky does it

rustic rain
#

hmm

#

How to treat those systems

#

so all AI in them

#

can interact with each other

#

no matter in what system they are

#

so AI in system 0, which is furthest from system 100. Can always know there's another AI in system 100. And if required, will get the idea, how to get there.

#

first solution: rooms are literally apart from each other in same world space.

pliant pike
#

well if your talking about space which I'm presuming is really really big, you also have to deal with the time lag of information travelling from systems

rustic rain
#

nnnah, it's all just details
Which I don't need atm

#

I need base

#

for this all

#

the way I can create those system in the first place

#

on which everything else will be put step by step

rotund token
#

so you say you have 100 rooms

#

but how big is each room

#

and how much is in each of them

pliant pike
#

personally I think you try should start with one system first and simulate that, seeing what data that has then try adding another

pliant pike
#

ok cool, if you can simulate one you can simulate two

rustic rain
#

you know, like how certain stars have 10 planets
while other just 2 planets

#

that's irrelevant

rotund token
#

well it matters a lot

#

if they're 1k x 1k vs 100x100m

#

you can store a lot more in an area

#

before floats become an issue

rustic rain
#

well, it's more like distance between them which is issue

#

room itself is not that huge

pliant pike
#

how do you deal with the distance between planets

remote crater
rotund token
#

need to check

remote crater
#

ty ty, tertle is a boss

pliant pike
#

there's an exclude thing in the entityquery None = new ComponentType[]{ typeof(Frozen) },

rotund token
#

yeah but he's not using a query

#

it's a physics event job

pliant pike
#

doh

rustic rain
#

well, I counted
On average those system are kinda 150x150 in size

#

but again, it's distance betweem them that is supposed to be huge

pliant pike
#

but like I said the distance doesn't need to actually exist the solar systems could exist as tables in a data base

rustic rain
#

well yeah player also should be able to fly indefinetely in one direction

#

or at least, have illusion of that infinite travel

#

ok, it's irrelevant detail

#

I still don't get, how can I make it work

#

one should not be able to fly from one system to another without portal

#

so if I put 2 systems in same world space

#

it kinda will be possible

#

WAIT A SECOND

#

what if I use Z axis

pliant pike
#

yeah that's pretty easy to do, I know one game moves the solar system around the player instead of player moving around the objects

rustic rain
#

for it

#

hmmm

pliant pike
#

anyway who will really fly for the years it takes to fly between the systems

rustic rain
#

and whether there's simply a better solution

#

than just dropping systems in world space far apart from each other

pliant pike
#

yeah you have to stay within a limit for that

#

you can delete objects that are to far and reset the player to zero

#

I've seen lots of ways of dealing with the floating point errors

rustic rain
pliant pike
#

the objects that you see don't need to be the objects that are simulated though

astral parrot
#

Hello There! So, I'm trying to make an entity but it doesn't render (doesn't show in Scene Window and in Game Window) the mesh with material by using RenderMesh and RenderBounds. I'm trying to create using pure ECS which is EntityManager.CreateEntity(), and I made it with EntityArchetype.

// This is running on Start Method in MonoBehaviour Script
entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
minionArchetype = entityManager.CreateArchetype(typeof(LocalToWorld), typeof(Translation), typeof(Rotation), typeof(Scale), typeof(RenderMesh), typeof(RenderBounds));
// Followed with instantiating

I'm using 2020.3.30f1, Latest Hybrid Renderer, Standard Built-In Unity (Not URP/HDRP), I'm stuck at this point.

remote crater
#

I'm trying to find out why on death, some entities drop multiple loot drops. 1) Has anyone experienced something similar? 2) Is there a way to print the name of an entity's to specify which one it is in relation to similar types (maybe an index)? If so, I could see which one is the offender to get close to the source of the bug. (Oh I can just entitycomponent data to get a specific index. Still warming up. I think I got this dots now.)

remote crater
rotund token
astral parrot
#

Ah ok, I'll try with different method then

solemn hollow
#

@astral parrot But as GoodNewsJim already said the built in pipeline is not supported

pulsar jay
#

I am trying to do a simple "random" rotation for an entity like this:

float3 axis = new float3((float)math.sin(time), (float) (1d - math.sin(time)), 0f);
rotation.Value = math.mul(rotation.Value, quaternion.AxisAngle(axis, deltaTime * rotationSpeed));

But the rotation does seem to effect the scaling of the entity as if it was non uniformly scaled. Is this a bug?

remote crater
#

I know slow and arduous ways to do random numbers in DOTS, but is there a fast function?

astral parrot
#

but still is it necessary that Hybrid Renderer along with ECS will be requiring URP/HDRP pipeline in the future

remote crater
#

Turbo makes games has a 15 minute video on making randoms, so it ain't easy, so I won't useit for now: https://www.youtube.com/watch?v=s-nr9EMmhfo

๐Ÿ“Œ Download the project files from this video: https://tmg.dev/ECSRandom ๐Ÿ“Œ
๐Ÿ‘จโ€๐Ÿ’ป Code featured in this video: https://tmg.dev/ECSRandomCode ๐Ÿ‘จโ€๐Ÿ’ป
๐Ÿ’ป My Game Development Setup: https://tmg.dev/GameDevPC ๐Ÿ’ป
๐Ÿ‘‡ See below for time stamps ๐Ÿ‘‡

  • 0:00 - Random in Unity ECS
  • 1:15 - Basic Use of ECS Random
  • 3:28 - How ECS Random Works Behind the Scenes
  • 4:08 -...
โ–ถ Play video
pulsar jay
#

This is a simple default cube rotated by 1.3 around the X axis. The Transformation system seems to be broken ๐Ÿค”

rustic rain
#

Can I somehow disable drawing of certain entities?
Or maybe exclude them from being used by certain systems?

pulsar jay
rustic rain
#

no, I don't want to disable them

#

I only want to disable them for certain systems

#

primarily drawing

pulsar jay
#

Afaik you can only do this by changing their components so the stop matching the systems queries

rustic rain
#

feels bad

#

I need disable/enable components desperately then

#

kek

pulsar jay
#

If you wrote the system yourself you can have a IgnoreBySystemX component which you add to the entity and exclude in the query

karmic basin
#

There's a disable for rendering also

rustic rain
#

I know, but this one is for hybrid renderer

#

in other words

#

I have entities

#

in same space

#

but on different levels

#

and when I switch from one to another

#

I need to stop drawing entities

#

that don't belong to level I switched to

pulsar jay
#

maybe this can be handled by scene culling mask and multiple cameras?

rustic rain
#

I thought about it

#

as in using Z axis

#

but I'm not certain

#

whether this is a way

pulsar jay
#

Is there a way to "normalize" a quaternion?

rustic rain
#

how exactly are you rotating it?

pulsar jay
#

Thats the rotation code

rustic rain
#

ahem

#

why is your axis so weird

#

you rotate cube by using some dynamic axis xD

pulsar jay
#

its because I want a random looking rotation

#

I first tried rotating it by assigning some random sin, cos values to all 3 axis via EulerXYZ

rustic rain
#

well

pulsar jay
#

But randomly shifting the axis and rotating around it leads to a smoother result

rustic rain
#

maybe you should normalize axis first?

pulsar jay
solemn hollow
#

How can i inspect the generated code for IJobEntityBatch jobs?

#

Im interested in how the LimitToEntityArray overload works

solemn hollow
#

nvm found the codegen but it seems like IJobEntityBatch doesnt generate code

remote crater
#

This is more of a design question with dots... If I wanted to add an indexing number on stuff dropped in a parallel job... I was thinking of throwing in a huge random variable and when indexing them later... But there's always the outlying chance of a conflict...

#

Say you had 3 parallel processes and you wanted to add indicies to them... How is that done? Is it something DOTS/ECS applies to every entity: A Unique qualifier identifier?

#

Right now if I make 3 lasers, they're all named laser, how do I know they're different? Like a memory address or anything would be good. Can someone help?

solemn hollow
#

entityindex is just that. unique to every entity

remote crater
#

thank you

solemn hollow
#

Well i need to correct myself. The index could in theory not be unique

rustic rain
#

Index + Version

#

no?

solemn hollow
#

because you could create a new entity which gets a recycled index

#

yes with version it is unique

remote crater
#

You solved a problem I had for about a year lol

solemn hollow
#

so Entity itself is the identifier u need

remote crater
#

Sometimes my lasers will hit a ship at the same exact frame, triggering a multi destroy event. I want to only drop its items one time, and not multiple times. It is tricky though... I tried complicated lists to make sure the same thing doesn't drop twice, but once again, that is done in a parallel environment so statics can't be used... Its a weird situation to think about. It's like a software architecture puzzle: https://youtu.be/895VPFsumKM Maybe when dropping the loot, I could verify in a special non parallel processing .for each?

Proof of Achievements no other gamer has: #1 world ladder Starcraft #1 World ladder Broodwar, #1 World ladder Warcraft3 at 200-0, first to 1500 wins Warcraft3, #1 World Diablo2 Hardcore experience ladder, #1 score Pittsburgh without Turtle Tip 1989 Nintendo World Championships, #1 world C&C3, #1 World SC2v2/l https://www.crystalfighter.com/achie...

โ–ถ Play video
viral sonnet
#

you have a race condition. try to linearize it some way. you can write which ships are destroyed to a native container that can handle it and then process the destroy events elsewhere in a single thread or in parallel with a fitting native container like NativeHashMap where the destoryed entity is the key.

remote crater
#

The multi destroy happens because my laser arrays are side by side like a dual or quad cannon and hit at the same time. Multi trigger events are not the bug.

#

I have a trigger event that adds a componenttag<bastian> to it.

solemn hollow
#

easy way to do it:
tag the ship that gets destroyed by adding a component. let a system run on all entities with that component that is handling the drop of loot.

remote crater
#

Then later I run a SystemDestroy

solemn hollow
#

yes. or you combine those systems

remote crater
#

Yes, correct, I too thought that would be the proper way to do it, but each has their own problems that would not allow it to work.

#

I can drop an excess amount of items or none at all. I have a lead, but it's very weird.

#

DOTS/ECS makes you think weirdly, and since it is non standard, you start even second guessing what you do know.

#

Cuz if you can't be sure what the issue is... You get a bit open minded about solutions and such.

solemn hollow
#

i assume your issue is that you handle damage events right away in a TriggerEventJob and drop loot then and there which gives u a race condition. Marking all entities that should die this frame and then looping over them once gets rid of that problem

#

you just need to make sure the order of your systems is right

remote crater
#

I think my Issue was using Remove instead of RemoveAt lol

#

Like I said, you can trip over stuff you should know when you're so busy stretching your mind to understand parallel processing.

viral sonnet
#

tagging entities requires a structural change so -> not good

remote crater
#

It is common since lasers are aligned exactly next to each other as a space ship shot.

solemn hollow
#

an entity cannot be tagged multiple times with the same component so that cant happen.

solemn hollow
remote crater
#

You can indeed add many of the same component to an Entity

viral sonnet
#

no that's not possible

remote crater
#

ok, then the(3rd party) documentation I read online was sketch

#

Thank you

solemn hollow
#

maybe you are confusing it with DynamicBuffers

viral sonnet
remote crater
#

I think you guys gave me enough info to solve this.

viral sonnet
#

tagging is not needed. just write it to a NativeList.ParallelWriter or smth

solemn hollow
#

Adding Components to trigger Logic on Systems is considered hacky 0.o

remote crater
#
  1. Since Triggers and Obsticle collision does not happen in parallel... I can have an array list of things hit this frame.
viral sonnet
#

the solution to this specific problem is hacky

remote crater
#
  1. I will populate this list in my main Singleton global file of statics.
solemn hollow
#

i prefer tagging as a quick solution because i dont want to pass nativeArrays between system boundaries

remote crater
#
  1. On init of the frame, trigger will will init List triggerlistEntitiesDead=new List<int>(). Obsticle the same.. And when issuing a destroy, will cycle through those...
#

Now this assumes Trigger/obsticle run synchronous themselves and non asycnrhonously parallel.

viral sonnet
#

tagging during runtime is considered malpractice and it's abused or encouraged way too much

remote crater
#

To be honest I don't even have any solution at the moment

solemn hollow
#

well tagging is the only way to not have to poll with systems atm. so for infrequent events thats what i am using until disable/enable components is out

remote crater
#

I tried Manarz way already months ago... It has one problem to the next...

#

I may be closing in on tying up the loose ends tho

#

I don't mind if the first iteration of my game is tied together with duct tape and bubble gum as long as the design is refactor friendly.

viral sonnet
#

as mentioned above. write destroyed entities to a NativeList.ParallelWriter, NativeQueue.ParallelWriter or NativeHashMap.ParallelWriter when you don't want to deal with handling multiple entities in a list and then process them in a single thread. If you want to have good refatoring split logics because your ITrigger is doing way too much at once.

remote crater
#

Thank you enzi. I will study those.

viral sonnet
#

the faster you get comfortable with this the better your code and architecture will be

remote crater
#

Are there more memory things that can be changed in the parallel environment?

#

I remember catching wind of those about 8 months ago...

viral sonnet
#

what do you mean with memory things?

remote crater
#

Like if I have a parallel thread

#

and I'm writing to anything...

#

other than a parallel EntityCommandbuffer

#

I didn't know I had anything I could write to

viral sonnet
#

well, any NativeContainer that has a ParallelWriter. NativeStream is also great

#

fastest writer there is in parallel out of the box

#

can also read in parallel because of the logic how it splits writes

remote crater
#

Could it do a running total?

#

I'd be excited if I had a counter anywhere.

#

2 questions: If it can write across multi threads, and when it reads... is it using lock / unlock? Or could maybe I miss data mid process because though it was safe, I was writing an index of something that got destroyed while checking it someplace else?

viral sonnet
remote crater
#

kk ty

viral sonnet
#

parallel writers for queue, list and hashmap use Interlocked. NativeStream has its own memory block for every thread

#

so no, nothing can be missed

remote crater
#

Well I have a lot of reading material and things to try out. I am very much appreciating this. If I ever make bank, find me and you get to withdraw lol.

viral sonnet
#

hehe, that's nice of you but you're welcome without any money ๐Ÿ™‚

remote crater
#

You say that til I'm making World of Wacraft money ๐Ÿ˜‰ Then you'll be like,"Thanks doesn't cut it buddy! If you a real funk soul brother, then cut me a check right about now!"

viral sonnet
#

haha, well, when your swimming pool is overflowing with money I'm open for donations ๐Ÿ˜„

safe lintel
#

just dont scrooge mcduck dive into a big pit of coins ๐Ÿ˜‰

solemn hollow
#

Got a broad question concerning some AI problem:
Let's say i have an EntityQuery and a DynamicBuffer on each AI.
Each Agent now wants to read Data from all Entities contained in the Query and the DynamicBuffer (the intersection of them). If the DynamicBuffer is empty the query alone defines the targets to read from.
Should i loop over all Entities in the query and check if the DynamicBuffer contains the Entity or should i loop over the DynamicBuffer and check if the Entity Matches the chunk (/ archetype). Looping over DynamicBuffer gives me random memory access while looping over the chunks potentially loads alot of unnecassary data if the DynBuffer is small...
It feels like i should implement both methods and schedule the diffrent variants depending on the size of the DynBuffer. I am overthinking it right? ๐Ÿ˜„

viral sonnet
#

It feels like i should implement both methods and schedule the diffrent variants

#

^ This ๐Ÿ™‚

#

Although I would bet that looping over the chunks is a lot faster

#

also depends on how big the DB is and if it's a chunk based DB or heap based one

#

sounds like you don't know the internalCapacity of the DB so I guess it's a heap based one

solemn hollow
#

For example you could let your AI evaluate all coverpoints. Or you could restrict it to only see Coverpoints in a certain range (where the DynamicBuffer comes in)

viral sonnet
#

hm, some hash based pre-processing could speed the process up

#

iterating brute force is not good if there are no limits

solemn hollow
#

creating a HashSet out of the DynBuffer on worker threads is expensive too though

viral sonnet
#

well, do you really need a DB?

solemn hollow
#

yes. its a bit hard to explain but i got a hierarchical Utility AI that writes intermediate considerations into DBs to later use them in higher up considerations

#

those consideration results are what is used as a filter

#

basically i need arrays upon arrays on entities

viral sonnet
#

Are decisions spatial based? If you mention cover point then they are

solemn hollow
#

alot of them are in the end.

#

often its just a direct vectorization of the distance. sometimes its a Overlapsphere gathering targets

viral sonnet
#

ah so there is already physics involved? and those results are written back to a DB and later evaluated?

solemn hollow
#

yep in some rare cases

#

i try to avoid physics

#

atm im really not happy with the physics package performance

rotund token
#

Interesting

#

What part is slow for you?

viral sonnet
#

you can write your own quantisation and spatial lookup, especially when it's on a grid. doesn't need to be a full blown BVH ๐Ÿ˜„

rotund token
#

Make sure you turn off physics validity checks

viral sonnet
#

physics is quite fast though so I don't really understand that part

solemn hollow
#

sadly not a grid and im not experienced with physicsengines

rotund token
#

That thing slows it down 10x

solemn hollow
#

yes i know it should be fast but somehow it takes 7ms in my frame

rotund token
#

How many collisions?

solemn hollow
#

and i tried to reduce potential collisions

#

where can i actually see the collisions that are happening? didnt find a debugger for it yet

viral sonnet
#

huh, yeah, that's too much but I think that can be optimised

#

tertle, you mean the integrity checks for physics, right?

solemn hollow
#

the whole AI takes little over 2ms on mainthread and its basically all the gamelogic i have. 100s of agents possible... the physics is the main bottleneck atm ^

rotund token
#

Yeah that's the one

#

Sorry in bed and can never remember names

viral sonnet
#

np ๐Ÿ™‚

solemn hollow
#

ah i have those on

viral sonnet
#

also make sure that leak detection and safety checks are off

solemn hollow
#

yep those settings i knew

rotund token
#

Jobs debugger + integrity checks nuke physics performance

#

Integrity checks add a bunch of extra stages it's super slow

solemn hollow
#

is physics integrity setting new?

#

another problem i have with physics is that it basicly enters a performance death spiral since the lower frames i have the more often physicsstepsystem runs in a frame...

#

i rly need to get back to 60fps

rotund token
#

Well that's just fixed update in general

solemn hollow
#

yes but i guess that is why it takes a whole 7 ms

rotund token
#

Can always run it at a different tick

muted field
#

they really need to have IJob and IJobFor inherit from another base interface so i can use callbacks ๐Ÿ˜ฆ

#

my fancy idea of using call backs on complete now wont work ๐Ÿ˜ฆ

solemn hollow
#

Are your compile times really bad too? My iteration speed sucks

#

i did split everything into assemblies. no idea what else i can do

muted field
#

whats the difference between IJobFor and IJobParallelFor ? they seem similar to me

rotund token
#

I job parallel for is the legacy version

viral sonnet
#

yeah, they merged this. so IJobFor can now Schedule and ScheduleParallel. pretty confusing, not sure why it's still there

rotund token
#

Not sure why they didn't remove parallel for yet

#

Basically they standardised schedule naming

#

And couldn't automate upgrade

viral sonnet
#

if a newcomer queries IJob, the list is just overwhelming when it's not that bad actually

muted field
#

oh so dont use parallelfor then since it'll be deprecated eventually?

viral sonnet
#

yes

muted field
#

so is JobFor.ScheduleParallel the new version of IJobParallelFor or JobFor.Schedule? Not sure why it has both schedules, the parallel version requires dependency even though i dont have a dependency for the job., so currently i just put default but makes me wonder if im using the function wrong

#
var jobHandle = jobFor.ScheduleParallel(arrayLength, batchLoopSize, default);
var jobHandle = jobFor.Schedule(arrayLength, default);

what does the second Schedule method do with a IJobFor ?

solemn hollow
#

Schedule makes it run on a single worker thread as opposed to multiple

muted field
#

oh i see

muted field
#

yay got call backs working \o/

muted field
#

by any chance is this related to some disposal issue with my collections:

#

im not sure of the origin of this error, its happening when im not even in play mode which is odd

#

but it just started happening since implementing and playing around with the job system

rotund token
#

never seen it

muted field
#

i have found the culprit it related to [BurstCompatible]

#

but not sure why. removing it from my job fixed the error

viral sonnet
#

did you mean [BurstCompile]?

muted field
#

no i have [BurstCompatible] on the Execute method

#

according to the description it goes on public methods

rotund token
#

yeah thats only used for unity collections auto documentation and unit tests

#

you dont need to worry about that on jobs

muted field
#

oh okay

#

hmm not sure whats causing the error then but it only started happening once i got my jobs working havent been working on any thing else for over a week in the project

coarse turtle
#

anyone ran into an issue with platform's build asset configuration where if you define the Scripting Defines that you need in a build, the build will take all of the Editor's Player Settings Scripting defines instead? Not sure if this was a recent thing with the latest DOTS 50 upgrade... ๐Ÿค”

rotund token
#

you mean the edit -> project settings -> player defines?

#

because yeah it will use those

#

the ones in build config are additional defines on top of the player ones

#

so you can specify a server or client build etc

coarse turtle
#

so it's not supposed to replace the scripting defines in a build? ๐Ÿค”

rotund token
#

as far as i'm aware no because it'd break a lot of things

coarse turtle
#

huh seems kinda counter intuitive cause that means it sounds like regardless I need to edit the scripting defines on the editor for the build :/

rotund token
#

i've never encountered a situation where i'd want to take defines out of a build

#

what is the use case?

coarse turtle
#

so in the editor right now I define SERVER and CLIENT so i can launch both a server and client and do quick testing in the editor. But in a build I only want to build a headless server so I have a build configuration that only defines SERVER

For the client I have a build config that only defines CLIENT and I have a build pipeline that builds them out separately

#

ideally, I'd like for each build to not have both server and client defined so I could just have 2 separate builds, but if that wasn't the use case then I guess I need a different solution ๐Ÿค”

rotund token
#

netcode does this by having UNITY_SERVER, UNITY_CLIENT and if neither are defined do both

#

so you just add your define to your specific build config

coarse turtle
#

yea I think the build config isn't respecting that and is building both with CLIENT & SERVER

rotund token
#

well it is

coarse turtle
#

oh ๐Ÿค”

#

i guess I should follow what netcode is doing then :/

rotund token
#

but thats what i mean by netcode
you don't specify UNITY_SERVER, UNITY_CLIENT in editor

#

so if none are specified it sets up both

coarse turtle
#

damn, yea I guess I need another solution lol

#

ah cool...I guess i was lucky enough that i mainly use those scripting defines in the world boostrapper, much thanks @rotund token

viral sonnet
safe lintel
#

wonder if these verbose naming scheme will survive 1.0

molten flame
#

@rotund token you said you are using or planning to use rayfire.
Are you using netcode in your game as well?
I've been struggling to think of a way to handle high detail destruction in a networked environment.
Having 100+ ghosts per destructible object isn't really feasible.

rotund token
#

yeah i use rayfire just to precompute some fractures - nothing at runtime though

#

and i use netcode

#

i put a demo here a couple of months ago

molten flame
#

very interesting

rotund token
#

we have preproduction project that is heavily going to rely on destruction (cant say anything more than that) so this was mostly just a proof of concept in my own time of how i was considering tackling it

#

apart from that it'll have a layer of particles etc on top

#

and probably shader based superficial layer

molten flame
#

Do you "spawn" each fragment as its own ghost when it becomes dynamic?

#

It's very interesting that you have some simulation on the server and some on the client

rotund token
#

only the red ones

#

the red ones are ghost, the rest are client only

#

each whole piece has a bit field on it

#

and any number of those bits can either be ghost or client only piece

molten flame
#

Interesting... so are the client pieces visual only?

#

If so, that's a pretty reasonable optimization.
For me the physics of the destruction is more about removing collision geometry.
Altering collision geometry at runtime is always a massive pain.

rotund token
#

i don't think from a rendering performance i can leave huge amounts of debris around

#

let alone a gameplay perspective of it blocking players

#

so i leave X pieces that are the ghosts around for player to collect or whatever, and the rest will be client only in the same physics sim but disappear after Y

#

anyway that was basically how i did it in the proof of concept. was trying to limit rendering + network costs.

astral parrot
#

Hi, me wanna ask, is there a way to run a script when the GameObject is converting to entity?

#

What I mean is that run a script before or after converting to entity

rotund token
#

You can use GameObjectConversionSystems in different update groups

#

There's groups like
GameObjectBeforeConversionGroup
GameObjectAfterConversionGroup

#

the actual loop looks like

                {
                    DeclareReferencedObjects(conversionWorld, conversion.MappingSystem);

                    conversion.MappingSystem.CreatePrimaryEntities();

                    conversionWorld.GetExistingSystem<GameObjectBeforeConversionGroup>().Update();
                    conversionWorld.GetExistingSystem<GameObjectConversionGroup>().Update();
                    conversionWorld.GetExistingSystem<GameObjectAfterConversionGroup>().Update();
                }```
#

where the system that executes IConvertGameObjectToEntity, called ConvertGameObjectToEntitySystem, runs in GameObjectConversionGroup

solemn hollow
#

@rotund token yesterday we briefly talked about physics. disabling integrity checks helped a bit but its still not great considering it barely has to do anything. I suspect there are some physics interactions i am not aware of. Is there some kind of debugger i can use to show collisions etc? I know there is one for havok but is there for unity physics?

rotund token
#

yeah theres a debugger for physics

#

PhysicsDebugDisplayAuthoring

#
        public int DrawColliderEdges;
        public int DrawColliderAabbs;
        public int DrawBroadphase;
        public int DrawMassProperties;
        public int DrawContacts;
        public int DrawCollisionEvents;
        public int DrawTriggerEvents;
        public int DrawJoints;```
#

chunk a gameobject with that component in a subscene

#

creates PhysicsDebugDisplayData

solemn hollow
#

Thank you! I havent found it mentioned in the Documentation last time i looked.

astral parrot
solemn hollow
#

After looking at the physics debug im more confused than before. it seems like everything works as expected and i barely have any contacts that register. So my limited understanding of the physics engine is that the buildphysicsworldsystem is the broadphase looking for potential contacts. the Stepphysicssystem (narrowphase) then resolves those contacts. Why is StepPhysicsSystem taking 1.4ms when no contacts are to be resolved? Or does the Collisionfiltering only happen in the StepphysicsSystem so the broadphase is actually finding alot of potential contacts?

muted field
#

so i added this to my job: [BurstCompile]

But when i ran it through profiler the jobs take around 2ms which is identical to what it was doing before i added the attribute, so doesn't seem like its working? I'm using the mathematics library none of the mathf stuff so what am i missing here?

#

do i need to enable something some where aswell

solemn hollow
#

yes you need to enable burst compilation

#

jobs->burst->enable compilation

muted field
#

you mean this ?

#

already got that enabled

solemn hollow
#

yes

#

check in profiler if the job says its run with burst

muted field
#

not sure where it would say?

#

its safe to say its not using burst if it takes 2ms for such a small job aswell

solemn hollow
#

it woulde be a greenish color and it would say (burst) behind the jobname

muted field
#

yeh no green to be seen

solemn hollow
#

thats the "burst green"

muted field
#

what can cause burst not to be used even with the attribute

solemn hollow
#

i've never had the case where burst wouldn't work without throwing errors. sry.

#

where did you add the burstcompile attribute?

muted field
#
    [BurstCompile]
    public struct PolygonPolygonOverlap : IJobFor```
#

above my struct

solemn hollow
#

do you use rider by chance?

muted field
#

nah vs 2022

solemn hollow
#

hm k. Rider shows when a function is burstcompiled:

muted field
#

oh thats kind've cool

#

i dont think i have any thing in job that would make it non burst compatible

solemn hollow
#

well if you get any testjob running with burst first then atleast you can see burst is working at all. then it must be sth in your real job that is not compatible

muted field
#

ive had it work on very basic jobs before

#

but it was very basic

solemn hollow
#

Cant promise i spot the mistake but can you share the code?

muted field
#

sure

rotund token
#

are you getting warnings in your log

muted field
#

it seems to show my job in the burst inspector if that means anything

rotund token
#

how are you scheduling your job

muted field
#

no warnings

solemn hollow
#

is your polygon struct blittable?

#

seems like it has a list of Verts inside

muted field
#

im scheduling them like this:

            for (int i = 0; i < _polygons.Length; i++)
            {
                for (int j = 0; j < _polygons.Length; j++)
                {
                    if (i == j) continue;
                    var p1 = _polygons[i];
                    var p2 = _polygons[j];
                    var arr = new NativeArray<bool>(1, Allocator.TempJob);
                    var job = new PolygonPolygonOverlap(p1, p2, arr);
                    var jh = job.ScheduleParallel(p2.Verts.Length, 1, default);
                   

                }
            }

#

i call complete in my job controller which is just some boiler plate stuff

muted field
#

is that why it wont burst?

rotund token
#

no

muted field
#

i get this in console by the way

rotund token
#

o_O

muted field
#

just appears randomly some time later

rotund token
#

ive never seen that

#

im pretty sure you've turned on burst timings

#

which is interesting

#

(its an option)

muted field
#

yeah i enabled it thinking it might show how long my jobs took using burst if they used it

#

but i dunno what that timing represents

#

my polygon struct also has an unsafehashset

#

could that be non burstable ?

uncut rover
#

I think it the time it took to compile the brust code

rotund token
#

if burst can't compile it will error

#

it won't just not compile

muted field
#

oh

#

so it must be compatible then its just choosing not to use burst

uncut rover
#

do you have the burst option enabled in the inspector ?

#

synchronous compilation ? sometimes it start the play mode with the non burst version because it's not compiled yet.

muted field
#

this time it did use burst

#

i didnt even change anything

rotund token
#

burst compiles asychronously

#

it could take a few frames before it switches over if you don't force synchronous compilation

solemn hollow
#

oh wow i thought it just hangs when burst isnt finished yet

uncut rover
#

it does if you have synchronous compilation enabled

solemn hollow
#

for me its probably the same thing since without burst my game wouldnt run at all ๐Ÿ˜„

muted field
#

confused why it worked now but not last time

solemn hollow
#

So in the game we play a bunch of zombies which have Colliders. But they are all set to not collide with each other

#

Would that incur costs in the StepphysicsSys anyways?

#

The debugger shows no Contacts.

muted field
#

why do you suspect setting them to not collide would incur costs?

solemn hollow
#

Somewhere this CollisionFilter setting has to be checked for Overlaps that happen. I thought it is checked in the BroadPhase (BuildPhysicsSystem) and the not valid collisions are never passed to and processed by the StepPhysicsSystem. So i dont know what my StepPhysicsSystem is doing for 1.4ms when there is no valid overlap it could process

muted field
#

does the deep profiler work for the physics stuff to see what it might be ?

#

ive not used the new physics tools yet but i imagine the profiler might highlight some info

solemn hollow
#

Let me check if i can get it working now. there currently is a bug with M1 chips that makes the profiler not work because of too much memory usage (normal profiler works after unity restart, deep didnt at all last time i tried)... only fixed in later unity versions i cant use because of entities... so annoying

#

nope... cant run deep profiler...

muted field
#

wait doesnt entities work on latest LTS 2021.3 now ?

solemn hollow
#

0.51 is out???

muted field
#

oh i thought 0.51 came with the LTS of 2021.3 but turns out its still in progress

solemn hollow
#

atm we are at 0.50.1

pliant pike
#

basic question but when converting GO to Entity is it best to just not use physics shape and physics body and use rigidbody and collider?

#

they seem to convert the same both ways but physics body is missing some of the options of the rigidbody like freezing axes and making iskinematic

solemn hollow
rustic rain
#

I have a feeling options like freezing axes aren't converted kek

solemn hollow
#

but i have to say the more detailed options for filtering collisions are great in the new components

pliant pike
#

thanks yeah I just noticed they have setting where you can just use it as a a trigger which I presume is the alternative

whole gyro
# pliant pike they seem to convert the same both ways but physics body is missing some of the ...

The Physics Body component has a "Motion Type" field that can be set to Kinematic. This is the same as isKinematic on a Rigidbody. There isn't a way to specify axis constraints on a Physics Body, but you can do this with joints. There is an example of this here: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/PhysicsSamples/Assets/Demos/4. Joints/Scripts/Creators/Joints/LimitDOFJoint.cs

GitHub

Contribute to Unity-Technologies/EntityComponentSystemSamples development by creating an account on GitHub.

#

I uses this simplified version in my own game to keep my character upright:

public class LimitDOFJoint : MonoBehaviour
{
    public bool3 LockLinearAxes;
    public bool3 LockAngularAxes;
}

[UpdateAfter(typeof(PhysicsBodyConversionSystem))]
public class LimitDOFJointConversionSystem : GameObjectConversionSystem
{
    protected override void OnUpdate()
    {
        Entities.ForEach(
            (LimitDOFJoint joint) =>
            {
                // Get the destination world entity associated with the authoring GameObject
                Entity entity = GetPrimaryEntity(joint);

                var bodyPair = new PhysicsConstrainedBodyPair(entity, Entity.Null, false);
                var physicsJoint = PhysicsJoint.CreateLimitedDOF(
                    RigidTransform.identity,
                    joint.LockLinearAxes,
                    joint.LockAngularAxes
                );
                World.GetOrCreateSystem<EndJointConversionSystem>().CreateJointEntity(joint, bodyPair, physicsJoint);
            }
        );
    }
}
#

The usage is similar to the Rigidbody constraints:

drowsy pagoda
#

Is DOTS supported in Editor 2021+ ?

safe lintel
#

entities and packages depending on it arent

drowsy pagoda
#

So recommended to stick only with 2020?

pliant pike
#

Thanks @whole gyro I did eventually find that, I should prob read the docs and look at the samples

whole gyro
safe lintel
#

yeah, they are intending to release something to make it compatible with 2021 maybe around june(but you know how they are with estimates)

drowsy pagoda
#

lol, unfortunately I do.

#

thx for the quick reply

rustic rain
#

Any idea whether Unity mentioned when they plan on enable/disable component feature?

solemn hollow
#

entities 1.0...

rustic rain
#

๐Ÿ‘ด

#

oh man, it's so crucial to my ideas

#

feels bad man

solemn hollow
#

literally everbody is waiting for it for years now ๐Ÿ˜„

safe lintel
#

@rustic rain posted 18mins ago

rustic rain
#

huh

#

well, my use case: enable/disable rendering of entity

#

Maybe there's any other option to achieve same?

safe lintel
#

you do know about the DisableRendering tag right?

rustic rain
#

๐Ÿคก

#

No I don't

#

I feel so bad, I swear

shut pewter
#

Hey all, I've been wondering, is there something akin to hot reloading for entities etc.. ?
I currently have a fairly long startup time, and it negatively impacts productivity

rotund token
low tangle
#

Yeah, only 5 more years till 1.0 drops ๐Ÿ™ƒ

#

finally revive my unity ecs games

tranquil jay
rotund token
#

You may be tempted to locally flip these methods to public to start playing with this feature in your own projects prior to its official release. I want to advise you in the strongest, most sympathetic terms: please, for your own sake, don't do that.

#

yeah his warning came too late for me

#

already played around with this last week

muted field
#

if we have a native array for a struct. can those structs use interfaces or will that mean they are reference types and not allowed for jobs

#

struggling to understand how to setup my data =/

molten flame
muted field
#

well i have a graph class and need nodes/segments where they have info about the segments and nodes they connect to, on top of that my segment needs to be generic since they take a spline type which governs the curviness of the segment

#

at most i can restrict the segment generic to struct but not an interface

#

since my spline type is not an interface

#

its confusing how i link it all together

rotund token
#

you can have interfaces on structs

#

and you can avoid boxing by using generics

#

that said, most of the time this line of thought is misguided for entities/jobs

#

it's an OOP not DOD mindset

muted field
#

how would you setup a simple graph of nodes/segments in a DOD way ? my brain is so used to the OOP way

#

i cant use a list of a generic struct for my segments so i dont know how to give it a spline data field

molten flame
#

You wanna think about it in terms of packing data as dense as possible. Its essentially a matrix right.

muted field
#

so the segment should have all the spline data rather than a field to another struct defined as a spline?

molten flame
#

Yeah, thats more like it imo

muted field
#

i guess i could store the end points and end tangents which is what i need to calculate my spline, then calculate the spline when needed rather than store all that data in the segment

molten flame
#

I would set this up as Node tag on entity

  • Connection component struct with "to" / "from" Entity references to nodes
  • Spline component struct as either buffer of float3 or a reference to some shared data if its a lot of points (but this is advanced for me)
#

I'm pretty Entity oriented though. A lot of people pack their data into jobs and store it differently for these kinds of structures

muted field
#

this is what i currently have but without the spline data:

        private readonly struct Segment
        {
            private readonly int _nodeA;
            private readonly int _nodeB;

            public Segment(in int nodeA, in int nodeB)
            {
                _nodeA = nodeA;
                _nodeB = nodeB;
            }
            public int Other(int node) => _nodeA == node ? _nodeB : _nodeA;
        }

        private readonly struct Node
        {
            private readonly float2 _position;
            public float2 Position => _position;

            private readonly UnsafeList<Segment> _connections;
            public readonly UnsafeList<Segment> Connections;
        }
#

i use index in graph array for nodes

#

in the segment rather than an actual node type to avoid copying

molten flame
#

I think your private readonly UnsafeList<Segment> _connections; connections list there should really be a list of indexes in DOD.

muted field
#

oh good idea

molten flame
#

DOD is sorta like every struct lives in a flat list of contiguous memory and you wanna just index into it

muted field
#

so generally speaking a struct with a struct inside of it is best avoided

molten flame
#

Just like verts and tris in a mesh

muted field
#

except the basic types of course

molten flame
#

well struct with list of struct inside is what you want to avoid

#

yep

muted field
#

hm only issue here is. if i remove a segment from my graph

#

all the indices change in the graph's list of segments

#

so now all my node data is wrong

molten flame
#

This is the big pain with DOD. You need to manage which indexes are free and which are not if your data structure is large.

muted field
#

can i not use pointers directly to the segment instead no matter where in the list some how

#

something like int *ptr = &_segments[index];

#

then store ptr

molten flame
#

I think that's probably fine (I have little experience with pointers).
As long as the data is stored contiguously it should cache local when you are looking it up

#

indexes are just pointers anyway

muted field
#

yeh ive not touched pointers before either but maybe it'll work =/

#

i'll give it a try and see if it crashes lol

molten flame
#

I'm about at my limit of reliability for this kind of advice XD If I say anymore I'd be guessing and there are some very smart people on this discord that'll be shaking their heads.
I try to use the maintstream Unity sanctioned methods as much as possible because I don't have the C/C++ background to delve too deep into unmanaged memory stuff.

muted field
#

im getting this with just a regular native list =/

rotund token
#

contains requires you to implement IEquatable<U>

#

you really should look at the source to figure out why you have issues!

#

public static bool Contains<T, U>(this NativeList<T> list, U value) where T : unmanaged, IEquatable<U>

muted field
#

oh i used the wrong comparer interface ๐Ÿคฆโ€โ™‚๏ธ

#

though wouldnt that make my structs reference types if i implement these interfaces

rotund token
#

no?

muted field
#

C# specification specifically defines reference-type as comprising class types, interface types, array types and delegate types.

#

so that would make my struct a reference type no ?

rotund token
#

yes if you pass something by interface its boxed

muted field
#

oh so if its the type Node then it remains a struct

rotund token
#

where T : unmanaged, IEquatable<U>
if you put a generic constraint unmanaged/struct it will not be boxed

muted field
#

ah i see

#

ive not seen the unmanaged keyword before - will go read up on it

rotund token
#

tldr:
struct can have reference types on it
unmanaged can not

safe lintel
#

@rotund token did it actually work (enable disable)?

rotund token
#

on my very very very small tiny sample yes

#

but i was mostly just exploring what was available by writing theoretical code rather than running the actual code

viral sonnet
#

cort_of_unity has blessed us with useful posts! ๐Ÿ™

deft stump
#

oooooh. so enable -disable is almsot here

viral sonnet
#

VS confuses me so much. At the beginning I could see decompiled source code of entities, then I could only see the signatures, now I don't see anything at all. Go to definition just makes an error sound

viral sonnet
#

I take a break, come back and now it works again. This is ridiculous ... lol

muted field
#

it confuses me how it took them this long to support 64 bit in vs lol

viral sonnet
#

I heard a total rewrite of VS is coming. Not sure about the details but it's way overdue.

worldly isle
#

How do I say I want to foreach all the entities that are missing any of a set of components? For example if I have Component A, B, C, and D

and there is a a component set

ABC
ABCD
ABD
BD

and I have say

Without B, C, D
With A

I would expect only

ABC
ABD

I hope this make sense...

viral sonnet
#

Are you using EntityQuery or Entities.ForEach?

astral parrot
#

Hi, me wanna ask about the Physics Velocity, when I start my game, at one moment the physics starts slowing down. Even thought I made a system to maintain the Linear velocity by assigning it on job entity batch. What is actually happening? how to solve it?

I used Havok Configuration and set Physics Step to Havok Physics.

molten flame
molten flame
#

And what do you mean by " at one moment the physics starts slowing down"?
Do you mean that the velocity of the entity decreases?

astral parrot
#

There's nothing wrong with it actually, but the simulation of the physics at some moment is slowing down

#

Eh I just play the unity again and the physics running normal again...

#

What...

molten flame
#

๐Ÿ™‚ ez fix then

muted field
#

how do you enable full stack ?

#

console log tells me to but already got full stack error reporting on in the player settings unless it means something else

solemn hollow
#

@muted field Doesnt it say enable full stack traces and disable burst?

muted field
#

i assume it means in project settings -> player

#

but i have that set to full stack so unless theres some other location to enable it i dunno how to get the full strack trace

solemn hollow
muted field
#

why is yours different to mine

#

๐Ÿค”

solemn hollow
#

hmm maybe this only comes with entities? or collections package?

muted field
#

yeh i dont have entities

#

not available in 2021.3

#

bit strange leak detection is only for entities tho

solemn hollow
#

sry i cannot help with the setting.
but it shouldnt be too hard to find the array you are not disposing

muted field
#

yeh i think i found it

#

i had mispelt OnDestroy method so it wasn't disposing when i exited play mode

solemn hollow
#

With the new Debugging stuff that will replace the EntityDebugger I miss the option to find entities by Filtering for specific components. maybe i just havent found it yet?

void girder
#

Can anyone explain why JobHandle.Complete() is blocking for so long when none of the threads are being utilized?

rotund token
#

the main thread is completing the job

astral parrot
#

Hi, me wanna ask, how to lock physics constraints like the same in rigidbody component?

rustic rain
#

it's in first pinned message

#

link that directs to github

#

How do I differentiate between subscenes?

#

Let's say I have 2 subscenes

#

I want to add certain tag to all entities in Subscene 1

#

and another tag to all entities in Subscene 2

#

I can see those scene related tags

#

but I don't get the idea behind what they mean

pulsar jay
#

The SceneTag is a SharedComponent so all entities in that scene will reference exactly the same SceneTag

rustic rain
#

huh

#

hm

#

any tip on how I can quickly differentiate between them then?

#

I have 2 entities

#

I want to know

#

to which subscene each belongs

pulsar jay
#

depends on what you need from the scene? the name?

rustic rain
#

Some kind of ID

#

rn I am trying to make a system that will swap my player entity

#

from scene 1 to scene 2

#

and vice versa

#

and all meanwhile

#

will add DisableRendering tag to all entities in system player leaves

#

while removing those tags from entities of system to which player goes

pulsar jay
#

I guess you would have to change the sceneTag and sceneSection on the player then

rustic rain
#

Yeah, I get that part

#

but first I also need to somehow know to which I should change it

pulsar jay
#

maybe you could use the SceneEntity referenced in the SceneTag to add some kind of ActiveSceneTag to it?

astral parrot
pulsar jay
#

then you could use EntityManager.GetAllUniqueSharedComponentData<SceneTag> to get all scenes and check their referenced entities if they are the active one

#

then you can just remove all the DisableRenderingTags on the active one and add to the other one

rustic rain
#

ok, first I should begin with simply disabling rendering on all entities from X scene

pulsar jay
#

should be easy to get the scene the player is in. Just query for your PlayerTag and SceneTag

rustic rain
#

yeah

#

but rn it's more of question

#

how to query smth that is not hardcoded

#

Maybe you know how to do it?
rn I have 2 buttons
I simply want to query with button 1 through one scene
and with button 2 another scene

#

I just need an example, hopefully I'll catch on everything else myself

#

kek

#
            List<SceneTag> sceneTags = new List<SceneTag>();
            World.EntityManager.GetAllUniqueSharedComponentData<SceneTag>(sceneTags);         

Here I have my list of sceneTags in a list

#

I want to query only through entities of SceneTag in index 0 of list

rotund token
#

yeah so there's really 2 parts to subscenes

#

each subscene can actually be broken into a bunch of subscenesections

#

and each section can be loaded/closed separately

#

if you look at RequestSceneLoaded this is actually applied to the subsections not the actual subscene entity

#

but in general you will also only have 1 subsection unless you've setup more

rustic rain
#

What would be required appraoch if I want dynamically created subscene/sections?

#

For those "rooms" I have been talking about

rotund token
#

well technically if you're talking runtime that really doesn't make sense

#

since subscenes are pre converted chunks of data

#

it sounds like you more want to partition your world into separate rooms?

rustic rain
#

well yeah

#

each planet system = each room

#

player directly can only intereact with one he exists in

#

but player can also travel to others

#

I guess my solution would be to pre-create all systems

#

AT least in that case I can make them beautiful kek

rotund token
#

well i guess the first thing to know is are these planets created in the editor and baked in a subscene

#

or created at runtime dynamically/by the player

rustic rain
#

I could use a bit of both

#

for example

#

Solar system, with planets like earth, mars and etc should be exactly same through every playthrough

#

while some fictional systems

#

can be randomly generated

rotund token
#

i would probably just define my own 'Room' shared component

#

and use that

#

make each subscene define a new room component

#

and then you can also create rooms at runtime

rustic rain
#

how do I query through individual rooms though?

#

let's say rn

#

I have 2 subscenes

rotund token
#

this.query.SetSharedFilter(new Room {ID = 1});

rustic rain
#

oh

rotund token
#

will only return entities from room 1

rustic rain
#

huh

#

so that requires me to define query

#

ok

rotund token
#

alternatively different worlds (some complexities here if you want rooms to interact)

#

or just simply poll it on the entity

#

or keep a list of every entity in each room in a buffer

#

theres a few ideas

rustic rain
#

no, should be only one world

#

so I don't have to invent information bridges between them

#

SharedComponent seems like enough, for now

rotund token
#

i agree if they need to a communicate that's a huge pain

rustic rain
#

I just need to learn more about it

#
        private void DisableRendering(int ind)
        {
            var em = World.EntityManager;
            var query = new EntityQuery();

            List<SceneTag> sceneTags = new List<SceneTag>();
            em.GetAllUniqueSharedComponentData<SceneTag>(sceneTags);


            Entities.SetSharedComponentFilterOnQuery(sceneTags[ind], query).WithStructuralChanges()
                .WithNone<DisableRendering>().ForEach((Entity e) => { em.AddComponentData(e, new DisableRendering()); })
                .Run();
            Entities.SetSharedComponentFilterOnQuery(sceneTags[ind], query).WithStructuralChanges()
                .WithAll<DisableRendering>().ForEach((Entity e) => { em.RemoveComponent<DisableRendering>(e); }).Run();
        }

For now I have this idea

#

I'll try it rn

#

hmm, doesn't seem to work

#

ooor

#

oh wait, me dum dum

#

I don't think it works

#

I think my query options are faulty

#

WithSharedComponentFilter(sceneTags[add])
This works
Buuuuut
Some entities are unaffected

muted field
#

for parallel jobs is there way to give each index in the execute function its own native collection so not to interfere with another ? i need each one to keep track of where they came from like a pathfinder so i need to write to a hashset as i go

rustic rain
rotund token
#

GetAllUniqueSharedComponentData