#archived-dots

1 messages ยท Page 221 of 1

jaunty herald
#

Is there no IJobParallelFor version of Job.WithCode()?

#

Entities supports it under ScheduleParallel(), but it doesn't seem to exist for lambda jobs...

#

I can't seem to ever get an error by letting sequentially scheduled jobs access the same nativelist via reference, even if it has no starting size...

#

e.g., one job writes 10000 values to it, the second job can read it just fine

#

I wish there was some actual documentation on this stuff...

dense crypt
jaunty herald
#

Yeah, it's just all very awkward I guess. Since that would mean I can't use SystemBase.Dependency for automatic dependencies

drowsy pagoda
#

Using DOTS with ASMDEFs. I am using a class called BlobAssetStore, DOTS docs say that the class belongs to namespace: Unity.Entities.
I am referencing that assembly...but it's still giving me this error:
The type or namespace name 'BlobAssetStore' could not be found (are you missing a using directive or an assembly reference?)
Why?

#

According to IDE, the BlobAssetStore actually belongs to assembly Unity.Entities.Hybrid. However, it creates a conflict because if I add that to the ASMDEF, it will no longer error the BlobAssetStore, but it will begin to error for Translation. Is this a bug?

untold night
#

that sounds like a bug, I'd go ahead and report it

dense crypt
gusty comet
#

i am kinda struggling with disabling spawned entities

#

i go through childbuffer of converted prefab, and then i go through their childbuffer

#

and add disabled component accordingly

#

it works in 30% of cases

dense crypt
gusty comet
#

Fake 0 may have prefab tag but its children dont

#

Ok I understand now, some entities have even 3 layers of parents

#

so i replaced childbuffer loop with linkedentitygroup loop and it works now

crude sierra
#

is anyone familiar with Convert And Inject Game Object on ConverToEntity.cs ?
I am using hybrid ECS and this conversion type is neccesary for me, however, it only makes the parent gameobject an entity whereas I need the children to be entities as well. how can I achieve this without directly editing the package scripts?

gusty comet
#

you can add localtoworld it should update automatically

#

or add convertandinjectGO to every child

crude sierra
crude sierra
#

only the parent comes in as entity, no traces of children whatsoever

gusty comet
#

in entityDebugger your parent entity has no children?

#

no childbuffer/no linkedgroup

#

convertToEntity usually converts whole tree

low tangle
#

getting caught up on dots, whats exactly going on?

#

still on 0.17? 0.18?

#

ah the follow ups are good

drowsy pagoda
safe lintel
#

@crude sierra use conversionSystem.CreateAdditionalEntity(gameObject)

#

and then just manually make child entities with your needed components and also make a child buffer to store them

#

@low tangle yeah its annoying especially with regards to urp / uitk compatibility

#

two months ago: "0.18 is on the way" id really like to be a fly on the wall because seriously what is taking so long with these releases

low tangle
#

yeah skimmed a few threads, seems like things are happening behind closed doors at least

#

I'm still perpetually stuck in a place where I cant use any SRP's

#

so I'm stuck on 2019 forever

low tangle
#

ah nvrm

#

UI toolkit

#

still used to calling it ui elements

safe lintel
#

yeah not sure if you know of it but subscenes dont work with uitk in 2020(but they are fixed in 2020.1&2), part of the recent announcement pain

drowsy pagoda
#

I have a new project I'm working on and I decided I want to wrap my head around DOTS. So far, I like it, the concept. I know that since there is no convention set yet, that it's pretty much make your own way at this point. Is it right to assume the following?
For singleton (or very little quantity) of GameObjects, I will just use the regular OOP (MonoBehaviour) approach. But for objects that are going to be vast in quantity, where I might need to utilize an Object Pool and GPU Instancing for, I would then utilize the DOTS pattern.

gusty comet
#

can you activate system manually?

#

instead of running it from frame one

dense crypt
slow iron
#

anyone know a way of going about joints (hinges/etc) in unity physics?

#

Im looking at the demos but it looks like quite a bit of code and Im really not understanding after a few days of fiddling with it

gusty comet
distant summit
#

Hey everyone submissions are now open for the first game jam that you need to sleep at least 8 hours and show your game dev skills!

Is this not enough for you ^^ then we are inviting you to challenge the creator of Latios Framework (https://github.com/Dreaming381/Latios-Framework) with your own Unity DOTS Game!

Join the game jam this weekend: https://itch.io/jam/48-8-jam-2 and weโ€™ll see you there !!

worthy rampart
#

Anyone know if there's a good way to call extern functions inside a job

pliant pike
#

you could make them into structs

worthy rampart
#

I can turn an external function into a struct?

#

I've got data structure implemented in compiled native code

#

All the types associated with it are fully blittable

pliant pike
#

well that is if you can do it

worthy rampart
#

But I read that you can't call native functions from a job

pliant pike
#

its all by data no refs

worthy rampart
#

So you think I won't have any issues calling an extern function

#

From inside the job

pliant pike
#

well a job is like a closed box

#

everything you put into has to be declared in the scope that it is created in

worthy rampart
#

That doesn't have anything to do with whether you can call functions from another dll

#

Guess I'll just have to give it a go for science

#

If anyone has done this I'd appreciate a ping

light mason
#

Anyone know how I can do a UnityWebRequest in SystemBase

north bay
worthy rampart
#

It was in the docs I was looking at

#

Example

#

Maybe it's old

#

I haven't tried it yet in 2021

north bay
#

I had a DLL that exposed some file writing stuff almost a year ago which I used from Burst/Jobs if I remember correctly

#

Otherwise FunctionPointers will definitely work. I don't think they are required tho

worthy rampart
#

Ok cool

#

Well hopefully it just works

#

I have to do some unsafe memory pinning

#

Hopefully that doesn't mess with it

#

Otherwise I guess I'll just parallel.for

north bay
#

Memory pinning works just fine with burst and jobs

worthy rampart
#

Sweet

north bay
#

I just tested it myself and I get a error when directly calling the native function.
Passing it through a function pointer works fine tho

[BurstCompile]
public class Externs
{
    public delegate bool AnyPopupDelegate( );

    [BurstCompile]
    [MonoPInvokeCallbackAttribute(typeof(AnyPopupDelegate))]
    [DllImport("user32.dll")]
    public static extern bool AnyPopup();
}
    
[BurstCompile]
struct PopUpTest: IJob
{
    public FunctionPointer<Externs.AnyPopupDelegate> AnyPopupPtr;
            
    public void Execute( )
    {
        var result = AnyPopupPtr.Invoke( );
        Debug.Log( $"{result}" );
    }
}
    
var externBurstTest = new PopUpTest
{
    AnyPopupPtr = BurstCompiler.CompileFunctionPointer<Externs.AnyPopupDelegate>( Externs.AnyPopup )
};
            
externBurstTest.Schedule( ).Complete( );
worthy rampart
#

Ah ok

#

Yea I read something about this but it wasn't super clear

#

That helps alot

#

Ty @north bay

drowsy pagoda
#

Can I use a traditional MonoBehaviour Rigidbody physics to interact with ECS physics? Even things like raycasting?

drowsy pagoda
#

Is there a really comprehensive resource/guide/tutorial about DOTS pattern? Something that dives deeper than just the basic Data, Entity, System explanation. Something that explains how ECS Physics works as well as how to interact MonoBehaviour with ECS, etc?

gusty comet
#

i interact mono with dots via ecb

deft stump
#

I interact mono via go.find oncreate and do stuff in onupdate w/o burst

gusty comet
#

BTW ive been getting this error A LOT (even after fixing it) in last few days, does anyone know what it could be... fixing this is really random and takes lot of time
maybe its related to crunch compression idk...

#

or addressables or burst

jaunty herald
#

Is there a way to have a list / array of native collections in a job?

mint iron
#

you could Unsafe versions of the collections UnsafeNativeDictionary, UnsafeNativeList etc.

jaunty herald
#

do Linq statements work in jobs / burst on nativecollections?

#

nvm, you need a lambda function after all...

jaunty herald
slim nebula
jaunty herald
#

But nativearrays don't directly contain memory

#

just pointers

slim nebula
#

yeah it doesn't make sense to me either. I havn't heard a good explaination for it

jaunty herald
#

There's a way to use them in jobs, but it wouldn't be burst-able

#

(e.g. NativeArray<int>[])

slim nebula
#

but I havn't tried it

#

but I guess that's for components, not jobs

#

it's still managed... hmmm I dunno sorry

jaunty herald
#

no worries

#

If I run into any managed issues I just don't use burst, I feel like the automatic scheduling and dependencies are still useful

solid rock
#

I'm having an issue where they don't seem to be... accepting my data properly.. I'm wondering if it's an endianness problem or something?

#

Nvm it's probably just the usual terribleness of the Visual Studio debugger not supporting them ๐Ÿ˜ฆ

gusty comet
#

Hey i have a question regarding archetypes
are they like arrays containing arrays of components

drowsy pagoda
#

Has anyone experienced Gimbal Snapping when setting PhysicsVelocity.Angular?
Here is my code

velocity.Angular = Vector3.up * -(lookDelta * player.LookSensitivity * 0.05f);

And it works, but when it gets close to +X or -X (look direction), it kind of slows downs and then all of a sudden SNAPs to the other side. It's still rotating properly, but that snapping makes it feel tacky.
I constrained the physics rotation on X and Z axis, so only Y is affected. Is that why? If so, or not, how do I make for a smooth rotation while updating velocity.Angular value?

unreal wraith
#

i have a question
if i want to implement threading using i jobs on my infinite terrain
on my struct that generates the mesh datat
do i add the ijobs interface
or
the ijobsparellelfor interface

safe lintel
#

IJob is one thread, IJobParallelFor is multiple threads. If you have a really heavy workload, the latter will be more useful

unreal wraith
#

is their such thing as a native list

unreal wraith
#

but when i add using unity.collections

#

it doesnt show up

drowsy pagoda
#

Unity.Collections doesn't show up as a namespace?

unreal wraith
#

no

#

what i mean is

#

i can add using unity.collections

#

but

#

i cant add a native list

#

only a native array

safe lintel
#

did you add the collections package?

unreal wraith
#

no

safe lintel
#

try that, i think list is only in the package

unreal wraith
#

i cant find the package in unity registry

drowsy pagoda
#

Oh, you will need to add it in the UPM

#

it's a hidden package

#

Go to Package Manager, and click the plus dropdown

#

Select add from git URL

#

and just type com.unity.collections

#

๐Ÿ˜‰

unreal wraith
#

now its just stuck on this loading screen

drowsy pagoda
#

just wait, it takes a while

unreal wraith
#

ok

drowsy pagoda
#

it means it found it, it's downloading and installing

unreal wraith
drowsy pagoda
#

You need to be logged in to your account

unreal wraith
#

how do i do that inside unity

drowsy pagoda
#

In the Package Manager if you select the Packages dropdown and choose My Assets it should ask you to log in if you're not logged in.

unreal wraith
#

looks logged in to me

#

so whats the deal then

safe lintel
#

just check your packages to see if it installed. sometimes theres glitchiness, sometimes you need to restart the editor after installing a package

drowsy pagoda
#

Sorry for the delay. Ok, so here is my situation. I am using DOTS/ECS with Physics, Mathematics and all that good stuff. Currently I have a player (capsule mesh, rigidbody, convertToEntity, PhysicsShape). I have a cube as a child to that authoring player gameobject called eyes (CopyTransformToGameObject, ConvertToEntity [ConversionMode: Convert and InjectGameObject].
Then I attached a camera as a child to the eyes cube.

When I press play, the player capsule gets converted to the Entities world as well as the eyes. The Player capsule gameobject gets deleted, but the eyes and the camera stay intact. The CopyTransformToGameObject works in copying the translation and rotation to the authoring gameobject.

However! If you see the image, there is an issue I can't figure how to approach. During play mode, the eyes are selected in the Scene view (you the location gizmos shows the eyes local orientation) and the yellow arrow shows the orientation of the player capsule.

As you can see, the rotation of the player happens smoothly without any snapping. However, the eyes snap, and they snap on the 90/-90 degree points for some reason. I have a feeling it has something to do with gimbal locking? Anyways, it's horrible! How can I fix this issue?

#

I can show you code if you need for the rotation.

safe lintel
#

is the eyes just a child of the capsule entity?

drowsy pagoda
#

Yes

safe lintel
#

tbh im not really great at math, so you can post the rotation code but not sure how much help ill be

unreal wraith
#

how long does it usually take to install a git package

#

i feel like its taking too long

drowsy pagoda
#

Ok. Rotation code is super simple. One line. Iโ€™ll post it when I get a moment. Away from pc right now.

#

But basically us PhysicsVelocity.Angular.y = lookDelta

#

velocity.Angular.y = math.abs(lookDelta) > 0 ? -lookDelta * player.LookSensitivity * 0.1f : 0;

safe lintel
#

shouldnt take more than a few minutes and the collections package is small in size @unreal wraith try restarting your unity editor if you havent already

#

so i cant really say that I can mentally work through that ๐Ÿ˜… but id check in the entity debugger to see if the values are snapping. for a very simple test id change the code to a constant value and make sure the snapping is something to do with that rotation code and not the physics step.

drowsy pagoda
#

Thx. Iโ€™ll try that out.

karmic basin
drowsy pagoda
# safe lintel so i cant really say that I can mentally work through that ๐Ÿ˜… but id check in t...

So I tried a couple more things. I let the eyes just convert to entity and watched it with the rotation as an ECS entity. It rotates as desired (no snapping). When I changed it back to how it was, I realized that it renders BOTH the ECS entity AND the authored game object. And if you look at the screen, you can see them both...except that the authored object orients incorrectly.
Perhaps this is a bug in the CopyTransformToGameObject script? Wonder if anyone else had issues with this.
Probably might have to write my own version of it...

safe lintel
#

hm weird. I would def try setting the transform directly and not use the CopyTransformToGameObject, should be simple enough to test out if it is the culprit.

drowsy pagoda
#

found the code they execute:

struct CopyTransforms : IJobParallelForTransform
        {
            [DeallocateOnJobCompletion]
            [ReadOnly] public NativeArray<LocalToWorld> LocalToWorlds;

            public void Execute(int index, TransformAccess transform)
            {
                var value = LocalToWorlds[index];
                transform.position = value.Position;
                transform.rotation = new quaternion(value.Value);
            }
        }
#

Seems the new quaternion(value.Value); is the culprit! I think the mathematics quaternion interprets Euler angles in a different manner than the UnityEngine Quaternion.

unreal wraith
#

when using jobs am i supposed to put in allocator.TempJob like this?

#

NativeList<float3> positions = new NativeList<float3>(Allocator.TempJob);

drowsy pagoda
unreal wraith
#

does can i use vector3's with jobs

pliant pike
#

not if you want burst(which you do), use float3 instead

drowsy pagoda
#

So I'm having quaternion issues with CopyTransformToGameObject component. In my search I found out about Hybrid Components. I wrote a simple one and got it to work. The Hybrid component fires the Update and the unity events during ECS runtime. My question would be, how can I write code in my Hybrid component (MonoBehaviour) that can read/write to ECS components of that related entity?

coarse turtle
#

well hybrid components have a sort of strict binding which tie the component's lifetime/control to entities

#

so updating the MonoBehaviour from a SystemBase would generally be ideal @drowsy pagoda

Entities.ForEach((HybridComponentA a) => { a.DoSomething(); }).WithoutBurst().Run();
drowsy pagoda
#

ah, simple. Let me try ๐Ÿ™‚

drowsy pagoda
#

Sick! It works! Awesome! Thanks man!

drowsy pagoda
# safe lintel hm weird. I would def try setting the transform directly and not use the CopyTra...

Ok. I finally came up with a solution. I did some digging around, and as I mentioned, the culprit was indeed the conversion between Unity.Mathematics.quaternion and UnityEngine.Quaternion they don't play well in certain cases, like my situation I mentioned here: #archived-dots message

Anyways, I found out about Hybrid Components (yeah this is my first time learning DOTS, I'm 4 days into it). And I created a SyncEntityTransform that would do exactly the same thing as CopyTransformToGameObject. I set it up, and just did:

trans.position = ltw.Position;
trans.rotation = ltw.Rotation;

And BAM! It gave me the SAME behavior as the CopyTransformToGameObject. And no matter how I converted the quaternions, (to eulers and back), it always gave me the same result. So then I gave up changing the rotation and simply did this:
trans.forward = ltw.Forward and BAM! it worked!

I think Unity should address this.

drowsy pagoda
#

Damn. Next issue is that with this approach there is a slight delay for that object to update it's pos and rot ๐Ÿ˜ฆ

unreal wraith
#

how do i assign the length of a native array

drowsy pagoda
#

I believe it's the first parameter when you instantiate it, followed by allocation

unreal wraith
#

what about after i declare it

#

@drowsy pagoda

drowsy pagoda
#

dunno

drowsy pagoda
#

Say I have an entity that has nested children. Is there a way to filter for a child entity that has a ComponentData along with it's parent that has certain ComponentData items?

#

I know how to filter for ComponentData on a single entity, but is there a way to traverse the tree to look for a combination of ComponentData?

karmic basin
#

I dont think that's implemented. You'd have to write the iteration and search yourself

#

Though the way to go would be more along the lines of an EntityQuery

amber flicker
amber flicker
scenic oak
jaunty herald
#

How is the remap info from SerializeUtility.SerializeWorld intended to be used?

#

Do I need to serialize the remap info too and then use it when deserializing?

#

iirc in my last testing SerializeUtility handled remapping automatically, but I'm not sure what the remap info would be for then

frosty siren
#

Guys, where should i report a bug?
Error message:
Assets\Source\Simulation\Systems\AccessToSystem.cs(135,4): error Assets\Source\Simulation\Systems\AccessToSystem.cs(135,4): error DCICE007: Could not find field for local captured variable for argument of WithReadOnly. Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! โค๏ธ

karmic basin
#

Or the forum

#

In any case you should try to reproduce it in a simple project, helps the team

frosty siren
#

Ok, thank you. I'm just a bit confused with this 'About - report a bug`

karmic basin
#

Yeah forum is good enough, include any detail that can help

pliant pike
#

that might not be a bug though, it might just be you haven't set variables to readonly

frosty siren
pulsar jay
#

How can a type have a TypeManager conflict with itself? ArgumentException: MM.Events.EventTag and MM.Events.EventTag have a conflict in the stable type hash. Use the [TypeVersion(...)] attribute to force a different stable type hash for one of them.

#

Does the TypeManager have problems with namespaces or assebly definitions?

frosty siren
#

I have many asmdefs and all goes well

pulsar jay
drowsy pagoda
#

How can I reference another entity? Like in editor, attach another game object/component to an inspector field, and then get the reference to that converted entity on the ECS side?

frosty siren
frosty siren
# drowsy pagoda How can I reference another entity? Like in editor, attach another game object/c...

When you use [GenerateAuthoringComponent] your Entity field will be GameObject field in authoring component. So to refer another entity just refer authoring gameobject of that entity, and convertion logic will remap it automatically.
If you want manually write authoring for your component, you can define GameObject fields as well and then just use GameObjectConversionSystem.GetPrimaryEntity(_referencedGameObject) inside your public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)

pulsar jay
frosty siren
#

@pulsar jay do you have <AsmdefName>.Player asmdefs in rider?

#

i have this for all my asmdefs

pulsar jay
frosty siren
pulsar jay
#

Thats weird. Well I will have a look if this happens for me too

#

Btw I was creating the asmdefs in order to write tests. Are there any good resources on unit tests with dots?

frosty siren
#

I think generally you should manually create world and then update it inside test and then dispose

#

for systems testing i mean

pulsar jay
#

I reference Unity.Entities.Tests but cannot acces the namespace of the same name

pulsar jay
robust scaffold
#

Yet another week. Yet another absolutely no news about DOTS. Fun.

drowsy pagoda
#

I noticed that JobComponentSystem does not support ScheduleParallel is this something I need to worry about? I have a situation where I would use ScheduleParallel if it was SystemBase, should I change JobComponentSystem to SystemBase? What are the do's and don'ts with this now?

untold night
#

You shouldn't use JobComponentSystem anymore, it's deprecated and will be removed eventually. SystemBase can now do everything it could and more

safe lintel
#

yep SystemBase also replaces ComponentSystem

drowsy pagoda
#

Ah! Ok thanks!

drowsy pagoda
#

How can I reference another authored gameobject which will turn into entity?
Say I have a IComponentData that will hold a reference to another GameObject that I can assign via inspector.
Then I want that assigned GameObject to be converted to an entity and the reference with it. So that way I can access and modify it's component(s) via SystemBase

#

Or is that the wrong approach? Is there another way?

coarse turtle
drowsy pagoda
#

Thanks, I'm very new to DOTS/ECS. Where would I place the Convert method? Do I create a legacy Component and attach IConvertGameObjectToEntity to it? @coarse turtle

coarse turtle
# drowsy pagoda Thanks, I'm very new to DOTS/ECS. Where would I place the Convert method? Do I c...

So the IConvertGameObjectToEntity would be implemented in a MonoBehaviour

public class SomeAuthoring : MonoBehaviour, IConvertGameObjectToEntity {
  public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) {
    // Add your conversion logic here
  }
}

Make sure that the GameObject has a ConvertToEntity attached or it lives in a subscene for conversion to happen.

drowsy pagoda
#

Another question, when writing Systems and using filtering, is there a way to filter with OR functionality? Say I want a system to run only if (DataA AND DataB) OR (DataC AND DataD)

#

Or do I need to write two separate systems?

coarse turtle
#

You can use a WithAny in a lambda or define an EntityQuery with the right descriptors.

Entities.WithAny<A, B, C>().ForEach((Entity e) => { /* Some logic */ }).Run();

// Alternatively...
var entityQuery = GetEntityQuery(new EntityQueryDesc { 
  Any = new ComponentType[] { typeof(A), typeof(B), typeof(C) }
});

In this case any entities that have either A, B, C components would be queried and iterated

#

But otherwise, you'd have to do 2 jobs for those specific queries (A and B) or (C and D) since you want a specific combination versus at least 1

drowsy pagoda
#

I see. Thanks again man.

drowsy pagoda
#

I didn't know about SubScenes so I created objects and attached convert to entity on them. Because of this, I was able to create objects that had camera attached to them and did Convert and Inject and CopyTransformToGameObject and it worked, it actually moved the object with the camera around.
But now with SubScene, I can't achieve the same thing. How would I go about attaching a camera to a gameobject and syncing the transform of that gameobject between it's entity counterpart?

coarse turtle
#

Use Hybrid Components for your camera - unity should create an instance of the camera with the correct hide flags and render everything

drowsy pagoda
coarse turtle
#

Well add the Camera as your hybrid component - have a system to update the Translation, camera should move

drowsy pagoda
coarse turtle
#

You can do it in a GameObjectConversionSystem or use IConvertGameObjectToEntity - either way works

#

so you can do this if you want, but the equivalent would be conversionSystem.AddHybridComponent in an IConvertGameObjectToEntity.

drowsy pagoda
#

Wow. Yeah thanks, that's exactly what I did. The transform get's updated automatically I didn't need to write system to update it! Amaznig!

#

So why does that work with Camera and not other components? Is it because the Camera script itself does a Transform update?

coarse turtle
#

Like why does the camera's position gets updated?

drowsy pagoda
#

Yeah

coarse turtle
#

When you add a Hybrid component, Unity also adds things like CompanionLink

#

which is a 1 way link from Entity -> Component Object

#

There's a specific system which reads the Translation of the entity and then copies it to the Component Object's transform

#

I forget the exact name of the system - but that system is pretty much responsible for updating the Camera's position

drowsy pagoda
#

Ok. I have the following heirarchy. Player->Eyes->Camera Anchor->Camera
I also have a VirtualCamera setup that has target set to Camera Anchor (empty GO).
I can't get the Camera Anchor to sync between entity position so that the virtual camera can update itself on the mono side.

#

I tried attaching an empty hybrid component to the Camera Anchor to get it to sync, and it did create a companion link, but it did not update the transform.

#

I tried attaching a CopyTransformToGameObject on it, and no avail.

coarse turtle
#

Well hybrid components are pretty strict to being updated via the Entities, not the other way around - so there are limitations

drowsy pagoda
#

ok

pulsar jay
#

Is there any way to use Job.WithCode outside of systems or does it just not work with the code generation? I was trying to use it in tests but it does not seem to be replaced by codegen

quiet swallow
#

Has anyone succeeded building il2cpp **release ** build on android without having a crash on game start?

I'm using
Entities Version 0.17.0-preview.42
Unity Physics Version 0.6.0-preview.3

My guess is that the problem is related to this thread: https://forum.unity.com/threads/case-1315723-il2cpp-physics-netcode-entities-android-build-crash.1060103/?_gl=1*y83k07*_ga*OTE1NDc1NDU3LjE1NzY4MzkzMTA.*_ga_1S78EFL1W5*MTYyMzE3NDU2Mi42Ny4xLjE2MjMxNzkwMDYuNTQ.&_ga=2.196188652.1771243602.1622451325-915475457.1576839310

jaunty herald
#

Is it possible to manually modify the ComponentSystemGroup a SystemBase runs in during runtime?

#

Or is that only possible via the UpdateInGroup attribute

#

I'm assuming it's ComponentSystemGroup.AddSystemToUpdateList

pulsar jay
jaunty herald
pulsar jay
jaunty herald
#

Yeah, it makes sense. I just wanted to mention that this isn't an automatic process

pulsar jay
#

Is it somehow possible to run a job only if a previous job succeeded? I know they can depend on each other but this will only make the second job waiting for the first to be finished

jaunty herald
#

I mean that's kind of the point of dependencies (wait until the previous dependency is finished)

#

You can early out the dependency and signal the job if it succeded or not

#

Also, how would the depending job know if the previous job succeeded or not, without waiting until it is finished?

pulsar jay
#

The job itself wouldnt even have to know if the other job succeded. Only the scheduler needs to know

jaunty herald
#

Let the next running job know if it's dependency was successful or not, otherwise just don't do the computation

pulsar jay
jaunty herald
#

Yeah, or just using something like a NativeArray<bool>(1)

pulsar jay
#

Yeah I just thought there might be an easy way to just stop the dependency chain and cancel all following jobs as this could come in handy in a lot of situations

#

Atm I am building a simple entity based event system and it would be great to poll for events with a query and depending on that either run or dont run another Entity.ForEach query

karmic basin
#

Maybe the first job puts a tag that allows the second job to run. But sync-point blahblahblah

pulsar jay
#

It works already but I have to do the query for the event entity on the main thread and can then decide whether to schedule the ForEach

#

Would be great if a jobHandle could just have some kind of success flag ๐Ÿค”

karmic basin
#

What is wrong with having the second job always run, even if zero elements to work with ? Schedule overhead I assume ?

pulsar jay
#

I could use @jaunty heralds approach to early out in the second job. That wouldnt work well with Entities.ForEach though

jaunty herald
#

When I worked on an event system, I always just spawned an entity, which was then processed by a system, which could then create more entities, etc

pulsar jay
karmic basin
#

Yeah same spirit with network commands

pulsar jay
#

If the reaction to the event was spawning new entities it would only need one ForEach to iterate over the event entities and fill an ECB

#

but if I have an event that should change multiple entities of another archetype it gets tricky

#

E.g. EnemyHealthBuffedEvent (which is a bad example as its more a command than an event) that should double the value of any enemy health component

gusty comet
#

unity is still working on ECS?

#

i just looking at versions and aka its stopped

gusty comet
#

unity netcode is aka rip? but ecs is still in WIP

dense crypt
dense crypt
#

Yeah that one is in development.

gusty comet
#

yes but still, seeing no changes by x time is uhm

bright sentinel
#

Since NetCode depends on Entities, then that's the reason

pulsar jay
#

Is there any way to get component data via Type (e.g. via DynamicComponentTypeHandle)?

bright sentinel
#

@pulsar jay Multiple ways, what's the context here? SystemBase Entities.ForEach, job, something else?

#

And what are you trying to achieve?

pulsar jay
#

they all have an EventTag and e.g. an event specific EnemyKilledEvent component

bright sentinel
#

You could use an EntityQuery or ComponentDataFromEntity

pulsar jay
#

yeah but they both require a specific component type

#

I am trying to do: Give me the other component data of each entity with an EventTag

#

where the other component can be any component type (unknown at build time)

#

I can get the typeId of the other component and I can also get a DynamicComponentTypeHandle from the typeIndex but all public methods require a generic type T to acces component data

bright sentinel
#

Oh, no idea then

pulsar jay
# bright sentinel Oh, no idea then

Thanks anyway. It should be possible because the entitymanager itself uses typeIndex internally. Its just a matter of how deep to dig I guess ๐Ÿคทโ€โ™‚๏ธ

gusty comet
#

minecraft mmk idk if its possible to speedup map generation with dots

worthy rampart
#

@north bay idk if you remember helping me the other day with calling external code from a job, but I ended up finding out that as long as you use primitives or raw pointers for the external functions you don't even need to do the function pointer stuff

#

now I've got a job that can do ~100k raycasts in 0.75ms

jaunty herald
#

Anyone have an idea how I can check if a system has been destroyed? Null check does not seem to work...

north bay
north bay
worthy rampart
#

Right now it's stress testing

#

But I'll be using the bvh to cull physics queries for projectiles

#

And most projectiles are rays or capsules

north bay
#

That sounds fun. Are you embedding a native physics engine?

worthy rampart
#

not yet

#

using physx

#

I need 64 bit precision tho

#

so I have some jobs that do syncing

#

and chop things up

karmic basin
jaunty herald
#

The error is being thrown when manually changing state in ComponentSystemGroup.OnUpdate. It has a Systems property which is a list of all the systems it should update. If you access this list before calling base.OnUpdate, a destroyed system will throw an exception

#

So I don't have a type I want to check for, but a reference

karmic basin
#

Uhm i see. I'm not in front of computer to do some tests.

#

Surely if you are the one removing them you could keep track somewhere but I never tried

drowsy pagoda
#

I noticed PhysicsMass does not contain the actual mass (or weight w/gravity) from the Rigidbody. Is this stored somewhere else or it's not included at all?

#

I see InverseMass, but I don't know how to extract mass from that...

safe lintel
#

its inversemass,

#

i think zero is for static things? cant remember how it works but it was explained on the forums somewhere, its more efficient supposedly to calculate things this way

#

if you poke around in the conversion code it will show how its calculated cant remember where exactly

#

RigidbodyConversionSystem or something

drowsy pagoda
#

Ok i'll see what I can find. Thanks

#

Found it => InverseMass = math.rcp(mass),
Wtf is math.rcp?

#

reciprocal? (however you spell that lol)

#

Do I just rcp the inversemass? Or is there another method I need to use?

#

Just confirmed. Yes, it works! float mass = math.rcp(physicsMass.InverseMass);

verbal leaf
#

Hello I am doing well making a lot of progress

#

I am wondering how you go about replacing an Index in a ForEach as such?

#

Im grabbing everything that is movable and putting them into a grid, haha what fun testing of capabilities :)

#

We would struggle with this otherwise

dense crypt
verbal leaf
#

If I layed out all movables 1...2...n

#

so I can take index and figure out row and column

dense crypt
#

int entityInQueryIndex

#

Put it before your ref Translation translation

#

The value is unique for each entity your job executes on. 0..n

verbal leaf
#

hmm

#

Where do I put it?

#

What what do I assign it?

dense crypt
#

Right before the Translation in your query. Unity will assign it for you

verbal leaf
#

.ForEach((ref int entityInQueryIndex, Translation translation)

#

?

#

Oh I was missing a ref

dense crypt
#

No ref/in on entityInQueryIndex. Ref on Translation if you want to modify it

verbal leaf
#

Riiight, ref for write

#

We want read onlys for cache line

#

No ref automatically read only?

drowsy pagoda
#

Everything was running smoothly without issue. I have the latest DOTS setup with HDRP setup. Didn't have any problems creating objects with HDRP/Lit shaders.
Now, all of a sudden I'm getting this error:
A Hybrid Renderer V2 batch is using a pass from the shader "HDRP/Lit", which is not SRP batcher compatible. Only SRP batcher compatible passes are supported with the Hybrid Renderer. Why is it coming up all of a sudden? And how can I fix this?

dense crypt
#

And it's picky in that all ref components have to come before in

verbal leaf
#

OK

#

I recalled from lectures + reading but I am just hitting code now after 5 days of study

craggy orbit
#

is there an easy way to check if an entity is visible in the active camera, like the old Renderer.isVisible?

coarse turtle
#

the first thing that comes to mind is doing a quick cull check with the camera frustum - dunno if there is any convenience in hybrid renderer v2

craggy orbit
#

mm okay, thanks!

drowsy pagoda
verbal leaf
#

Success

#

Thanks!

#

I guess they are entities not game objects haha

#

Its like, why did I spend 5 days in the books, what am I doing XD

safe lintel
#

im not sure, i actually get that error in a build now but not in editor so also looking for a way to narrow things down, though im using urp

drowsy pagoda
safe lintel
#

nah hybrid renderer requires the srp batcher to work

#

well V2 does anyway

drowsy pagoda
#

Yeah, I just saw that error ๐Ÿ˜ฆ

#

This sucks man!

drowsy pagoda
safe lintel
#

well depends, is stuff not rendering that should?

#

for me nothing appears different so im not too worried, just annoying to see at the start

drowsy pagoda
#

Dang, yeah it is.

#

Do we know if Unity is working on this? Like there is already a reproducible bug for them to fix?

safe lintel
#

for the most part its just an error message saying a shader is incompatible, its not too helpful because it doesnt say which one. if you can reproduce it in a small project and you know every shader should be srp batcher compatible, then should report it

drowsy pagoda
#

On mine it does, it says that "HDRP/Lit" is not compatible. But that's like the most common one, I don't see why that woudln't be. And where is a list of all compatible shaders? There is no direction on how to deal with this.

#

And why was it working just fine, rendering and everything, for like 4 days straight. I was working on ti, adding items and new materials. And nothing. But then all of a sudden, bam!

drowsy pagoda
drowsy pagoda
#

@safe lintel check it out. Unity 2020.2.0 Beta 14 actually has this in their Release Notes.
Virtual Texturing: Fixed an issue where VT with hybrid v2 renderer gave "A Hybrid Renderer V2 batch is using a pass from the shader, which is not SRP batcher compatible" error. (1252572)
Take note of Virtual Texturing part. I don't think I have Virtual Texturing in my project, I just started it, gonna see if anything is enabled by default.
I'm running 2020.3.11 so upgrading won't work for me ๐Ÿ˜ฆ

#

WTF? Look!
According to the 2020.3 Docs Under SRP Batcher compatibility

For the SRP Batcher code path to render an object:

    o The rendered object must be a mesh or skinned mesh. It cannot be a particle.
    o The shader must be compatible with the SRP Batcher. All Lit and Unlit Shaders in HDRP and URP fit this requirement (except for the Particles versions of these shaders).
    o The rendered object must not use MaterialPropertyBlocks.

"All Lit and Unlit Shaders in HDRP and URP fit this requirement". And I found the HDRP Lit Runtime shader, and take a look at what it shows! At the bottom! It says that it's not compatible.

verbal leaf
#

Is there equivalent to Mathf.CeilToInt in Unity.Mathemetics.math?

#

It returns the smallest integer greater than or equal to x

drowsy pagoda
#

hmm...so I tried an experiment and found some strange behavior. I examined the HDRP/LitTessellation shader in the default HDRP package. And it said it was compatible. I then took one of my materials and switched it to that shader. After it compiled, it then started giving me the same Hybrid error about incompatibility. I went back to the shader, and now it says not compatible it's as if the Hybrid system is changing the shader to become incompatible...

verbal leaf
#

The library doesnt have intellicense commants to help what these functions

drowsy pagoda
# safe lintel for the most part its just an error message saying a shader is incompatible, its...

Alright, I think I got it to work. So because of the discrepancy of the docs and the shader compatibility on my inspector reading, I decided to Reimport the Lit shader that it was having an issue with. And when it reimported, it said it was compatible, confirming my suspicions that something was altering the shader or the way it was being read.
The errors went away. But after some time they returned. I then suspected that something happened (because I did import and delete libraries) and I had a couple crashes due to experimenting with code that might have corrupted something somewhere. So I closed unity, trashed my entire library, and opened it and let it rebuild...toook FOORORREEVER. But now it feels clean, no errors, the shader stays compatible, and I'm all giddy about it.
So, TL;DR, but you did anyway, if you know the problem shader, find it in project folder, right-click and reimport. If that doesn't work or you don't know it, trash the library, and let unity rebuild it.
Hopefully this will solve your issue as well!

dense crypt
crude sierra
#

is there a way to parallel write to NativeArray without using Nativelist?

worthy rampart
#

are you doing it in a way that you know you won't be writing to the same index

#

from multiple threads

#

[NativeDisableContainerSafetyRestriction]

#

on the NativeArray in the job declaration

#

will let you write to it

#

but obviously then it's entirely on you to make sure you aren't doing anything you shouldn't

#

@crude sierra

unreal wraith
#

when using completall() how would i get the output from each individual job?

dense crypt
unreal wraith
#

but im doing this for multiple jobs

#

completeall(); means it runs multiple jobs

solid rock
#

The only way to get output from a job AFAIK is from a NativeContainer

#

so you just... read whatever NativeContainer(s) represent the output(s) of your jobs

unreal wraith
#

how do i make each job output to a seperate native container

karmic basin
#

You feed them a different native container as input

dense crypt
#

I.E How many jobs are there? What are they outputting? Do they run parallel?

unreal wraith
#

basically im scheduling a bunch of jobs that generate meshdata (array of verts) and then using CompleteAll(), the only problem is idk how to retrieve the array of verts from each job that is completed

dense crypt
#

It allows for multiple values for each key

amber flicker
#

it doesn't change any of this but just a reminder that NativeReference exists for getting single outputs out instead of a single length array

worthy rampart
#

if you haven't seen this

#

it might be useful to you

#

I am also in the process of jobifying some mesh generation code that I have

pulsar jay
#

I am still struggeling to figure out how to get the data of an unknown (at compile time) component. I can acquire the typeId which in turn gives me the Type, ComponentType and ComponentTypeHandle but the only way to access component data seems to be through generic methods

#

I basically just need
EntityManager.GetComponentData(Type type) or
EntityManager.GetComponentData(TypeIndex int)

dense crypt
pulsar jay
drowsy pagoda
#

Hey guys, someone here told me that the JobComponentSystem is being deprecated soon. This is my first time dealing with ECS Physics colliders. I have no idea how to get started on collision/trigger events.
I saw a resource that show how to handle them like this, and here is my boilerplate code: https://pastebin.com/NB4jCGZD

Can I get some feedback on this? If JobComponentSystem is getting thrown out in the future, how can I convert this logic to SystemBase? And maybe there is a better way of this?

In my case, for starters, I want to be able to trigger event when the GroundSensor trigger collides ONLY with other colliders that are NOT triggers. How would I poll for that?
Thanks guys in advance for all your help ๐Ÿ™‚

pulsar jay
#

Its what GetComponentData<T> uses internally but I am unsure if I should mess with the usafe stuff

twilit coral
#

Can I somehow run RaycastCommand multithreaded? I did the same thing as documentation and it is same or worse than just using loop of Physics.Raycast. In Profiler it shows each batch on mainThread running one after another, and all my cores are Idle.

hollow sorrel
#

@twilit coral scroll down in profiler to job worker threads and you should see a bunch of commands executed in parallel there

twilit coral
#

They are just Idle

hollow sorrel
#

hmm

#

basically if you call handle.Complete() right after scheduling unity might decide to just run those jobs on main thread because it is a blocking call so main thread might as well help out
and i'm guessing it only schedules 1 job because you set the minimum to same amount as commands

#

so might be that's why it's running that one job on main thread

coarse turtle
#

You can try scheduling it at the end of the frame and fetching the data at the start of the next frame

hollow sorrel
#

yeah or if you really need the result right away for whatever reason you can try reducing the 15 you pass in so it's spread across more jobs

twilit coral
#

I tried to put it at 1 to see if it spreads onto 15 cores, but it still is on MainThread and just takes 70 more ms to calculate

#

15 per job

#

1 per Job

#

It splits it into multiple jobs but schedules then on Main Thread, am I missing some part of JobSystem hmm

hollow sorrel
#

@twilit coral try doing what itsjustblank said, schedule and then check results the next frame

drowsy pagoda
#

When using ITriggerEventsJob, how can I find out if triggerEvent.EntityA is a collider of type Collider or Trigger? Or any other information about it?

#

I tried getting the PhysicsCollider from the entity, but I don't see properties that show if it is a trigger or not.

worthy rampart
twilit coral
#

No, its around 11700 raycasts

worthy rampart
#

ah I was gonna say

#

that makes absolutely no sense

twilit coral
#

I am just trying to jobifie this part, but it does not want to do on other threads

twilit coral
crude sierra
#

i'm doing something as simple as changing transforms, but without ECS so putting the correct values into a NativeArray<Vector3> then consuming this array every frame elsewhere on the main thread

worthy rampart
#

and it's much faster

#

but you have to use the TransformAccessors

crude sierra
worthy rampart
#

IJobParallelForTransformExtensions

crude sierra
#

I will look into it, great thanks!

worthy rampart
#

if you can I would recommend caching the transform accessors

crude sierra
#

is it really faster than entity command buffer when using ECS? just for general knowledge

worthy rampart
#

ah this is for game object transforms

#

you don't want to do this if you are fully DOT

crude sierra
#

oh yeah

#

maybe in hybrid tho

worthy rampart
#

in hybrid gameobjects are converted to entities

#

and they do this for you

#

part of the implementation of the conversion

#

is setting up a system that utilizes these

#

to sync transforms from entities to GO's

crude sierra
#

I think in hybrid ecs if you have both entities and gameobjects you have to sync positions yourself

#

there's a special interface for that afaik

worthy rampart
#

I'm preetty sure

#

that if you converted the gameobject

#

using the conversion workflow

#

it's transform gets synced automagically

crude sierra
#

it does, when you use Convert and Destroy

#

if you use Convert and Inject syncing the two is completely up to you

worthy rampart
#

no that deletes the game object

verbal leaf
#

Documentation lead me to an out of date Job implementation, and I am clueless where to head from here uwu

verbal leaf
#

If I can learn to do it once....

#

I can do it again :D

#

I just need some assistance with the first one (This one grabs everything and arranges them in a grid)

crude sierra
#
OnUpdate()
{
    Dependency = new Job {}.Schedule(Dependency)
}
verbal leaf
#

The type or namespace Job cannot be found

#

It wants IJob

crude sierra
#

yes

#

ofc

#

put ur job there

verbal leaf
#

Ok so far so good

#

Now that IJobForEach that was deprectiated from between the tutorial to now

crude sierra
#

yeah, use Entities.ForEach with EntityCommandBuffer

verbal leaf
#

uwu

#

neither of those are interfaces

#

No interface needed?

crude sierra
#

or evne just Entities.ForEach with ScheduleParallel

#
Entities
            .ForEach(
                (ref Translation position) =>
                {
                   position.Value = newValue
                }
            )
            .ScheduleParallel();
#

there u go

#

that's the general template

verbal leaf
#

Thats a job?

crude sierra
#

that goes into your OnUpdate

#

jobs are not needed when using ECS

#

(some special occasions apply)

verbal leaf
#

This is a sussing out of the tech

#

Are you saying Jobs are no longer supported?

crude sierra
#

the whole premise of the DOTS API is to give devs an API that does the jobs for them, behind the scenes

#

thats what Entities.ForEach is for. it's an API that implements IJobParallelFor behind the scenes

verbal leaf
#

How are we to test HPC# without job or?

crude sierra
#

hence why that job interface is deperecated

verbal leaf
#

Is the High Performance C# No longer supported?

crude sierra
#

like I said, it's implemented for you

verbal leaf
#

This approach will not Vectorize without a job, in the console

crude sierra
#

the DOTS API wraps it up into pretty lambda functions

verbal leaf
#

Have you vectorized code with this new approach?

#

Whats your process?

#

Right now I am to test running multiples of 100K particle systems, simple entities, and complex entities

#

Right now I am just provisioning and placing multiples of 100K and hitting sluggish

#

So I need to vectorize

hollow sorrel
unreal wraith
#

how can i use AllocateWritableMeshData to generate multiple meshes at once

coarse turtle
#

you pass in the # of meshes to the AllocateWriteableMeshData, pass the MeshDataArray to a job and for each index you can create a mesh

unreal wraith
#

can you show me an example in some basic psuedocode

#

"for each index you can create a mesh" each index of what? the allocatewiteablemeshdata or meshdataarray

coarse turtle
#

AllocateWriteableMeshData returns a MeshDataArray, so you can iterate through each index and set the data/vertex descriptors

for (int i = 0; i < meshDataArray.Length; i++) {
  var data = meshDataArray[i];
  // Set the vertex descriptors
  // Set the vertex data
  // Set the index format for the mesh
  // Set the indices for said mesh
}
unreal wraith
#

thank you, but the part that i think confuses me is when i reach here Mesh.ApplyAndDisposeWritableMeshData(dataArray, mesh). it seems that entire dataArray is used to only generate one mesh, does this mean if i want to generate multiple meshes on jobs i have to make multiple meshdataArrays with one element?

coarse turtle
#

why cant you pass n meshes instead of 1?

unreal wraith
#

oh i see

#

thank you

verbal leaf
#

Aha I get it now

#

Its not what they taught but I get the lambda thing now with System Base

unreal wraith
#

just one more thing

#

what do those parts do

#

also where would i apply the traingles to data

coarse turtle
#

VertexAttributeDescriptors defines the structure of the vertex data (remember you can have vertex colors, texcoord0, texcoords1, position data, etc)

data.GetIndexData gets you a native array to the data you can write to - so when you set the values in the nativearray it sets the triangle data

unreal wraith
#

so if i just want normal terrain is should leave this part like this?

#

actually, im just gonna assume i dont need that

#

atleast for basic terrain

coarse turtle
unreal wraith
#

wont that just be done automatically when i do recalculateNormals()

twilit coral
coarse turtle
verbal leaf
#

oooooohhhh

#

Neat

#

Lambdas are neat

#

You come in expecting database jobs lol

#

mind = blown

unreal wraith
#

what should i do if i dont know how much of my allocateWritableMeshdata i want to allocate? should i create a list of chunks, and then allocate the list lenght? or is there a more efficent way of doing that

twilit coral
hollow sorrel
#

daaymn that's some nice improvement

twilit coral
#

yeah, I love it, even more optimization will come as this time I didnt implemented occlusion so probes inside of geometry are still being traced, those I can skip later

#

23 cores are doing their work ๐Ÿ˜„

#

15ms on 50x12x50

unreal wraith
#

when putting in an array as an argument, is it pass by reference or pass by value by default

#

pass by reference is a copy right?

#

um i forgot which one is the copy

slim nebula
#

value is a copy

#

arrays are references

#

@unreal wraith

#

class == reference, struct == value

unreal wraith
#

what about when i pass an array as an argument for a function

#

oh wait

#

nvm

#

so your saying

#

anything thats a class will be passed by reference by default when used as an argument for a function?

slim nebula
#

yes

#

not just functions but any assignment

#

but yes what you said is correct

unreal wraith
#

@coarse turtle would something like this work?

coarse turtle
#

seems right - idk how you're setting the VertexAttributesDescriptors though

unreal wraith
#

is it ok that with ib im doing data.getindexdata<int> instead of ushort

craggy orbit
#

what's the easiest way to create a "companion" entity for a gameobject? i've got a GO with some IK code that i've had trouble converting to DOTS code (needs parenting and world space transforms), so im thinking that maybe i could have the GO handle the IK, and the companion entity handle DOTS physics interactions.

or, ideally, is there a good way to handle world space transforms with parenting?

coarse turtle
#

Why can't you just set the VertexAttributeDescriptors/IndexFormat again or is that not the case in this screenshot?

unreal wraith
#

what is VertexAttributeDescriptors?

coarse turtle
unreal wraith
#

i thought i dont need to do that since im just doing recalculate normals

#

also i got an error when trying to run the code

#

line 272

coarse turtle
#

the problem is you cant grab any kind of vertex data if you never define the structure of how the mesh is supposed to be.

unreal wraith
#

it doesnt talk about VertexAttributeDescriptors in there

coarse turtle
#

okay, maybe we should roll back a bit since this part ins't necessarily dots related - let's dm this

unreal wraith
#

ok

worthy rampart
#

Anyone have issues with native multi hashmap

#

I'm trying to iterate over it after putting a bunch of things in, and it's exceedingly slow to tell me if a key was inserted multiple times

#

I can do like 80k insertions in under 1 ms

#

But then I spend tens of Ms in the count keys calls

unreal wraith
#

how does the schedule function work

#

in this tutorial im watching he passes in a list as the first argument and then 100 as the second. why?

unreal wraith
#

why am i getting this error

#

heres the line it bring me to

drowsy pagoda
#

In my ITriggerEventsJob I want to scan the entity's parents to see if they match the other entity. What's the best approach?
I assume that doing [ReadOnly] public ComponentDataFromEntity<Parent> Parents; would be too taxing?

#

Say something like this in the job:

private bool IsParentEntity(ref Entity entity, ref Entity queryEntity,  ref ComponentDataFromEntity<Parent> parents)
            {
                if (parents.HasComponent(entity))
                {
                    var parent = parents[entity].Value;
                    return parent == queryEntity || IsParentEntity(ref parent, ref queryEntity, ref parents);
                }

                return false;
            }
unreal wraith
#

aaaaa i need help

drowsy pagoda
#

helps @unreal wraith

drowsy pagoda
unreal wraith
#

ive tried to add multithreading to my game every way i could, nothing works!

#

@drowsy pagoda

#

i have to finish this project in 3 dyas

drowsy pagoda
#

oof, sounds complex

unreal wraith
#

its my infinite terrain i need to add multithreading to

#

using jobs

#

can i atleast have a clue on how to do it?

#

there are no tuturoials online

#

and ive already tried doing it multiple times

drowsy pagoda
#

I'm diving into this my first time, so I'm no expert here ๐Ÿ™‚

unreal wraith
#

if i complete a list of jobs

#

will that run anydifferently than usin ijobsparrallelfor?

deft stump
#

nope.
They'll prolly run one after the other.
which is different than ijobparallelfor.

unreal wraith
#

welp

#

than im fucked

dense crypt
# unreal wraith can i atleast have a clue on how to do it?

Not sure what you need? IJobParallelFor allows you do schedule multithreaded work. You usually fill it with arrays of stuff you want to perform work on, then you tell it how many iterations each job should do, and it will automatically thread it out. So if you have 600 things you want to perform operations on and schedule it using 100 as the batch count, you'll have 6 jobs running in parallel (assuming there's enough cores).

IJobParallelFor isn't neccesarily DOTS though, it's just a core unity job type.

unreal wraith
#

peppej help

#

idk what to do

#

how can i generate meshdata for multiple meshes using ijobsparrallelfor?

dense crypt
#

In DOTS or just using normal Unity Jobs?

unreal wraith
#

whats the difference

dense crypt
#

Very simplified it's programming data oriented instead of object oriented. But since you asked I'm assuming you don't use DOTS.

unreal wraith
#

which ever one will give me faster results ill use

dense crypt
#

Faster as in better performance or faster as in it's faster to write the code?

unreal wraith
#

faster as in perform better

dense crypt
#

Then DOTS is most likely to give you better performance, however it takes quite some time to get in to and it's complicated to add mid-development

unreal wraith
#

ill do the dots

dense crypt
unreal wraith
#

ok i think i get the just of it

#

now how is making a job different using ecs

#

or dots

#

or wahtever

dense crypt
#

Well in DOTS you'd have to structure your code to use Entities, Components and Systems. If you're just using the Jobs you can keep on using MonoBehaviour etc without any real issues. DOTS uses jobs for everything.

unreal wraith
#

but these are for single meshes

#

also do you think using dots will make a huge impact

#

or should i be fine with normal jobs

dense crypt
#

You'll be just fine with normal jobs, if you start using DOTS the easiest way would literally be to start from the ground up.

unreal wraith
#

so it seems like the only way for me to retreive meshdata for each chunk would be to use a nativearray of nativarrays

#

with ijobsparallefor

#

is that a good approach? someone else told me thats no good but im not sure if i should trust him, plus that seems to be the only way

dense crypt
#

You can't nest a NativeCollection inside another NativeCollection (native array in native array) In this case you have to use NativeMultiHashMap. But yes it sounds like a good idea.

unreal wraith
#

so this is the best way to go about it right?

#

i mean i cant think of anyway else

#

the nativehasmap

dense crypt
#

In your job you would figure out all the Vertex & Triangle data, then when all jobs are finished you construct your meshes on your main thread. You can use the new MeshAPI specifically made for Jobs but it's probably best to just get it working normally first.

unreal wraith
#

i already did get it working normal on a single thread

#

whats the way you would do it with the meshapi

dense crypt
#

I still haven't figured out the new API fully yet personally ๐Ÿ˜› Haven't had time to try it out properly yet.

unreal wraith
#

do you know anyone who has?

#

im kinda desperate

#

and in a rush

#

i have to get this project done in 2 days

#

for my school

#

๐Ÿ˜ญ

dense crypt
unreal wraith
#

i actually already generated my infinite terrain using that before

#

just on a single thread

dense crypt
#

What was stopping you from ParallelJobs-ing it?

unreal wraith
#

you cant send the meshdataarray to ijobs

#

atleast it didnt work for me

dense crypt
#

Maybe you just tried sending it wrong or misunderstood it? Let me check the code I was working on.

unreal wraith
#

maybe

dense crypt
#

MeshDataArray is a struct so you should be able to send it just fine to the jobs

#

Do note that this is written for DOTS.

#

So I'm pretty sure it would be just fine on a normal IJobParallelFor

#

Also keep in mind that the code I just sent is still work in progress, and doesn't actually work yet.

#

But I'd imagine the final solution is very similar to what I already have.

unreal wraith
#

hold on let me revert my code back to where it was before

#

back when i was using the mesharraydata

#

@dense crypt

#

heres my code

#

and those are my errors

dense crypt
#

What does the first error say?

unreal wraith
dense crypt
#

CreateVerts returns a float3[] you can't have normal C# arrays in jobs. In this case you need to return a NativeArray<float3> instead

unreal wraith
#

oooh

#

ok

dense crypt
#

Same for CreateTris

unreal wraith
#

what do i put in as the allocator

#

allocator.tempjob?

dense crypt
#

Since it's being allocated INSIDE a job you can only use Temp

unreal wraith
#

ok

dense crypt
#

If you allocated it outside the job and wanted to send it in, then you would use TempJob.

unreal wraith
#

alright so i fixed those

#

but i still got these errors

dense crypt
#

That seems more like issues with your logic for generating the verts & tris

unreal wraith
#

my verts and tris logic should be fine

#

whats wrong with it?

dense crypt
#

That's honestly very hard to say. But as a test I'd hard code a quad and try using that to see if it works at all.

unreal wraith
dense crypt
#

Also, keep in mind: meshjob.Schedule(chunksToGenerate.Count, 100); This practially means generate 100 meshes per thread. So if the work takes a long while you may want a lower number

unreal wraith
#

it prints wohoo!

#

yay

#

so its something below the jobhandle.complete()

#

@dense crypt you dont have to test it on a qaud beacuse thats not the issue

dense crypt
#

Okay, yeah the other issue I'm not sure what it could be. Sounds like you have invalid data somehow though. I haven't actually gotten that far yet personally so I can't say for sure.

#

My own generation isn't working too well either ๐Ÿ˜†

unreal wraith
#

i think its this

#

this code was causing me issues when i placed it more above the job.complete(). so i put it after the job completes hoping that would make it work

#

but idk if it does

#

nvm its not that

#

i put a print statement after it and it printed

dense crypt
#

I mean it could execute properly but still supply invalid data, which breaks in the rendering step.

unreal wraith
#

oh

dense crypt
#

As you can see in the image I linked I have correct data (red outlines) but I'm probably supplying it wrong, hence the broken mesh. I need to research this more but I don't have the time atm.

unreal wraith
#

ok

#

well i should probably go to bed since its 5:36 am

unreal wraith
#

so i finally got it to work

#

and it is like 100x slower with jobs

dense crypt
pliant pike
#

Do you guys think this is a bad idea?

#
protected override void OnUpdate()
    {
        var numbofRobots = OP.GetAllPooledObjects(0);

        var activeobjsnumb = 0;
        for (int i = 0; i < numbofRobots.Count; i++)
        {
            if (numbofRobots[i].activeSelf)
            {
                var agents = numbofRobots[i].GetComponent<NavMeshAgent>();
                if (agents.isOnNavMesh)
                {
                    var currROBID = numbofRobots[i].GetInstanceID();
                    Entities.WithReadOnly(currROBID).ForEach((ref RobotCompState curbobstat, in UniqueObjectID currobjID) =>
                    {
                        if (currROBID == currobjID.IntVal)
                        {
                            if (curbobstat.currrobstat == RobotState.JustSpawned)
                            {                                curbobstat.currrobstat = RobotState.EnteringStore;

                                agents.SetDestination(entrancenavpoint[0].Value);
                            }
                           
                        }
                    }).WithoutBurst().Run();  
                }
                activeobjsnumb++;
            }
        }
    }```
#

I'm creating a job for each loop, would it be better to replace that with a simple for loop

worthy rampart
#

lmao

#

everyone is working on mesh generation

worn stag
#

any insiders? when next dots update planned?

deft stump
#

No one knows

#

New info will always come from the DOTS team that seems to give it in small drops once every few months or so

unreal wraith
#

@dense crypt the issues was i had some of the code run in an unneccesary forloop, its alot faster now

drowsy pagoda
#

I have a trigger collider nested in a gameobject that has a physics body. The trigger events display the entity as the parent body instead of the actual entity that contains the trigger collider. I understand this is due to compound colliders, but is there a way for me to quickly identify the exact entity that triggered that event, even though it's part of compound collider body?

drowsy pagoda
#

How does ECS store the PhysicsShape->Material->Friction value? I need this value during runtime. I can't find it in the PhysicsCollider, PhysicsDamping, PhysicsMass data. Or is this just kept internally somewhere?

#

When using [GenerateAuthoringComponent] tag, is there a way to get it on the MonoBehavior side (i.e. GetComponent<YourDataAuthoring>) without having to create your own custom version of it?
When I have unity cycle through all components of a gameobject via GetComponents, it actually does list your [GenerateAuthoringComponent] class name with "Authoring" attached, It even says it's in the same namespace. But intellisense disagrees. Does anyone know where unity stores the actual generated authoring component? Or I absolutely need to create my own for this?

scenic oak
dense crypt
drowsy pagoda
drowsy pagoda
karmic basin
drowsy pagoda
# karmic basin Friction is in `Material` https://hatebin.com/cqwthrbbqc

Oh of that I have no doubt. The issue wasn't that, the issue was that I couldn't find Material anywhere in the ComponentDatas exposed on the entity. After triple checking, I assumed that it did exist (otherwise physics wouldn't be able to calculate accurately), just exists internally somewhere. So maybe this is something Unity will address, but for now I need to make my own copy of it.

#

Unless I'm overlooking something, I'm all ears ๐Ÿ™‚

drowsy pagoda
#

I made a build to test it outside editor, but when it loads it just hangs after splash screen. The logs show that it throws an exception that says this: Cannot find TypeIndex for type hash 7923319918563069127. Ensure your runtime depends on all assemblies defining the Component types your data uses.
This is thrown by Unity.Entities.Serialization

How can I diagnose this issue? I am using asmdefs in my project, and they all have their correct dependencies, everything runs smoothly in editor.

gusty comet
#

what's the state of Dots?

agile dome
#

Burst and Jobs seem to be fine. ECS seems to be a lot more WIP, but it's a tool if you really need it

dense crypt
drowsy pagoda
#

In editor, everything is working fine, no errors. But when I build, the scene loads, it responds to input, my camera moves around, but none of the objects render. I'm using latest DOTS/ECS setup with HDRP. All my materials are just a simple "HDRP/Lit".
And I am getting this error in the log:
A Hybrid Renderer V2 batch is using the shader "HDRP/Lit", but the shader is either not compatible with Hybrid Renderer V2, is missing the DOTS_INSTANCING_ON variant, or there is a problem with the DOTS_INSTANCING_ON variant.
I went to the actual HDRP/Lit shader and inspected it. And it says that SRP Bathing: compatible and Keywords has DOTS_INSTANCING_ON. What's wrong? Please help!

bright sentinel
#

@drowsy pagoda Are you on all the latest versions of the packages?

karmic basin
#

Oh my god I dont even remember how it's called

#

Look around the PhysicsCollider, should be referenced there

drowsy pagoda
drowsy pagoda
drowsy pagoda
#

Is there a Command Buffer system that would allow me to execute code not related to the entity manager, but allow me to write my own function?
I would like to execute main thread code from a scheduled job using such a buffer. If there is something like that, please let me know! Otherwise, this is something Unity should add.
Ecb.AddCallback(MyMainThreadMethod) ๐Ÿ™‚

frosty siren
#

You can create additional entities and system which will react for them and do logic on main thread

#

This approach will produce one system per action but will work ๐Ÿ™‚

drowsy pagoda
#

Is the only proper way to setup an entity query in the ITriggerJobSystem approach is to just check components against triggerEvent.Entity[AB] inside Execute?

karmic basin
#

Lemme do a test scene

drowsy pagoda
#

When I checked, I couldn't find a Material, that was the issue.

karmic basin
#

Left cube is friction 0 , right one is friction 1, middle one is exact copy of left, but dynamically dampened

fluid kiln
#

Anyone can enlighten me on this? A Hybrid Renderer V2 batch is using the shader "Shader Graphs/Health Bar", but the shader is either not compatible with Hybrid Renderer V2, is missing the DOTS_INSTANCING_ON variant, or there is a problem with the DOTS_INSTANCING_ON variant. I'm trying to make a quad shader graph for floating health bars, it used to work too o.o

karmic basin
#

Or increased should I say

#

@drowsy pagoda Works for me because I'm using cubes. Which Collider you're using ?

#

BoxCollider I mean.

#

Could be the reason why. gtg eat, hope that helped

drowsy pagoda
drowsy pagoda
grim plinth
#

is ECS still avaiable I cannot find it on my package manager

drowsy pagoda
drowsy pagoda
#

If inside a ForEach job, there is a condition that would require use of syntax that is not Burst compatible, is there a way to split those up?
Say I would have a system that would dish out 100 entities burst compatible container, but 1 of them would trigger a condition that would make the container not burst compatible. What's a good way to weed that out? Would I have to write another ForEach container under it and schedule without burst for that condition? Or is there a way split it inside the original one?

drowsy pagoda
drowsy pagoda
#

In SystemBase.OnUpdate Before the ForEach I would declare something like this: var rotations = GetComponentDataFromEntity<Rotation>(true);
It only needs to be readonly in my case. But if I do that, I will get an error saying that IJobsomething or IParallelJobsomething (I can't recall exactly) needs to have that marked as [ReadOnly]. I don't have access to that, so I can't. In turn I have to omit the true for reaonly and then it all works.

Does this clog up a little because of write access? If so, how can I get around this safely?

unreal wraith
#

im getting erros that a native array is not being disposed of

karmic basin
# drowsy pagoda I've never used Pointers before, so this is definitely new for me. Thanks for th...

I've used pointers because I retrieve the previous values and the colliders are serialized to blobs which are immutable data. So yeah you have to rebuild and reallocate every frame. I'm not sure why they went that way. They followed a few design principles like stateless simulation and such, I guess it's for performance.
But if yo only have a handful of values your Material can be set to, you might want to cache them and swap when needed at runtime, might be simpler. I could have also cached the friction only I suppose ๐Ÿ˜…

#

And yes need to activate an option for the unsafe code

gusty comet
#

how to do entities.foreach INCLUDING disabled entities?

amber flicker
#

WithAll<Disabled> (I believe)

gusty comet
#

does it not exclude enabled ones?

amber flicker
# gusty comet does it not exclude enabled ones?

Good point, yes I'd expect it to - what happens if you add it to WithAny? Obviously you'd then have to use WithAll<SomeOtherStuff> otherwise you'd end up with any disabled entity. Worst case, you might have to write an IJEB or use two lambdas.

gusty comet
#

idk yet

drowsy pagoda
gusty comet
#

does anyone here know how to set up Occlusion Culling? im using a ConvertToEntity script on my object renderers but not sure how to add occlusion culling to that.....ECS used to have components for it but cant seem to find anything under culling anymore....

karmic basin
drowsy pagoda
gusty comet
#

Umm ive never used entity query

amber flicker
karmic basin
#

It's easy, just a more verbose syntax

gusty comet
#

is there any docs for .WithAny

drowsy pagoda
#

Is there a way to perform raycasts on a scheduled burst? Or is it only on main thread and non-burstable?

karmic basin
#

You might be able to pass directly the options to the lambda without building thรฉ Entity Query if I trust this docs link :p

hollow sorrel
karmic basin
#

I'm on mobile I let you find it

gusty comet
#
    Entities.WithEntityQueryOptions(EntityQueryOptions.IncludeDisabled)
                .ForEach((ref Entity modelEntity, ref RenderBounds modelBounds, ref ModelData2 modelData) =>
                {
karmic basin
#

You can also read the page on the Entity Queries, concept of with all/any/none is the same

gusty comet
#

why people do entity queries?

#

isnt it faster and with less code too

#

to do entities.Foreach

karmic basin
#

There's a few cases

#

Like accessing it before the lambda, to retrieve the Entity count

#

You also dont have thรฉ foreach filters

#

... things like that

gusty comet
#

oh

#

but theyre helpful

drowsy pagoda
hollow sorrel
#

are you using ECS physics or monobehaviour physics

karmic basin
#
  • you can have jobs with ZERO foreach lambda if you want ^^ though they are nice and easy to work with
hollow sorrel
#

ECS physics should already support bursted/scheduled raycasts by default

drowsy pagoda
hollow sorrel
#

physics samples in there should have some raycasting examples

gusty comet
#

is there any fast and elegant way to add eg a tag to hundreds of entities?

#

so i can do a clean .ForEach

#

you get what I mean

#

i think doing AddComponent 500 times is ugly

#

but maybe not

drowsy pagoda
drowsy pagoda
ionic sierra
#

For displaying many things at once on the screen ....is that the entities package?

amber flicker
gusty comet
#

well rip seems i cant use camera.WorldToViewportPoint inside scheduled jobs

drowsy pagoda
#

When using SystemBase, when should you end it with Dependency.Complete()? I noticed sometimes itโ€™s used and other times itโ€™s not.

frosty siren
#

when you want to complete your jobs immediately, but good code schedules all jobs without .Complete() (when we talking about using ECS)

gusty comet
#

i wonder why disabling rendermesh (that are outside frustrum culling) helps me so much with FPS

#

maybe frustrum culling is disabled in editor

solar ridge
#

So something like buffer.AddComponent<SomeTag>(query)

#

Or the newer method that is a capture

#

Still unclear which is better performance for mass adding tags in that regard

pliant pike
#

I feel like just using Entitymananger.addcomponent() is just quicker there's no delay from the playback at least

#

I use entityquery's quite a lot

#

in monoboheviours specifically and jobs sometimes require more data

karmic basin
#

When you add a component you're inducing a structural change, thus forcing a sync point.

pliant pike
#

yeah I'm more confused why you might use the ECB to add a component, because when you add a component you surely want it to happen immediately, I'm sure there are cases though where its better to use ECB, but I haven't personally found one

karmic basin
#

ECBs are known sync points in the frame. So you know you can do your structural changes there without disturbing your Jobs much

pliant pike
#

I guess I prefer a more chaotic program flow ๐Ÿ˜›

solar ridge
#

So basically, the goal is to schedule as much as possible with 0 completion on my end. Set things up correctly and you shouldnt need the component added immediately. Some added benefit: Ecb can be bursted.

#

The completion is handled by the scheduler in this case in the ECB system and normal schedule workflow

drowsy pagoda
#

I am getting the following error:
: IJobEntityBatch error: job reflection data has not been initialized for this job. Generic jobs must either be fully qualified in normal code or be registered with [assembly:RegisterGenericJobType(typeof(...))]. See https://docs.unity3d.com/Packages/com.unity.entities@latest?subfolder=/manual/ecs_generic_jobs.html
I didn't change or add anything to my code. It was working just fine.
The error shows up if subscene is loaded and livelink is enabled. It just spams the console. If I open the subscene, the error spams once, but all the subscene items don't render. If I close the scene, they render and I get spammed.
The last thing I did was add an asmdef to a system, which btw has nothing to do with the items in the subscene!

#

I tried Reimporting the scene, I tried restarting the editor too. The error still shows up. Help!

#

Confirmed. I removed the asmdef that I added, and now it all works. Is this a bug? Or do I need to add something specific to the asmdef?
I put a system inside a folder Editor and threw an ASMDEFs for editor only inside there, attached all the dependencies that I was using and the code compiled, but no subscene would work. Why?

drowsy pagoda
#

I just hit a snag. It appears that EntityManager.GetName is Editor only code. Is there a runtime equivalent? Or I need to write my own component for name tracking?

gusty comet
drowsy pagoda
gusty comet
#

actually unity names are not very useful during runtime

#

string comparison is slow too

drowsy pagoda
#

I have a UI that shows what the player is looking at.

torpid mulch
#
var projectile = commandBufferParallel.Instantiate(turret.index, turret.LoadedWeapon.Projectile);
barrelTransform = GetComponent<LocalToWorld>(children[0].Value);
commandBufferParallel.SetComponent(turret.index, projectile, new Rotation()
                    {
                        Value = barrelTransform.Rotation
                    });

                    commandBufferParallel.SetComponent(turret.index, projectile, new Translation()
                    {
                        Value = barrelTransform.Position
                    });

I assign a projectile I spawn the same rotation and position of the barrel but it spawns with incorrect values the further the barrel is away from 0/180 degrees. Any idea what I could've done wrong?

#

barrelTransform.forward shows me the correct direction so its position and rotation values can't be wrong.

gusty comet
#

is that ok to pass turrent.index? in examples for parralel ecb there was int entityInQueryIndex argument

#

maybe its same thing

torpid mulch
#

No idea, but that's what I've been doing everywhere and never had issues so far

#

Rotation is indeed being assigned barrelTransform.rotation, but it doesn't align with the actual barrel

pulsar jay
torpid mulch
#

even then shouldn't the shell have the rotation of the barrel from the previous frame?

gusty comet
#

how do you use native array with .scheduleparralel?
I get this error

Index {0} is out of restricted IJobParallelFor range [{1}...{2}] in ReadWriteBuffer.
so i googled and i need to add tag [NativeDisableParallelForRestriction] in front of nativearray
But that tag works only with class variables, and it asks me to create method variable instead

#

Entities.ForEach Lambda expression uses field 'planeDatas in a reference type'. Either assign the field to a local outside of the lambda expression and use that instead, or use .WithoutBurst() and .Run()

north bay
torpid mulch
#

My barrel is in a scaled entity, I guess that's why

north bay
#

I think this is the conclusion of the thread to get the correct rotation math.LookRotationSafe(ltw.Forward, ltw.Up)

torpid mulch
#

I'll take a look in a bit.
That works, thanks ๐Ÿ™‚

gusty comet
#

btw .rotation and translation

#

are local

#

so theyre depending on parent entity

crude sierra
#

hey guys, anyone have a reference for entities and UI canvases? I need UI elements relative to the entitites, where if I was dealing with regular GOs I would attach a canvas to the object as child

torpid mulch
torpid mulch
crude sierra
#

i'm trying to avoid having many canvases in my scene, it causes lag

torpid mulch
#

I have them in the same canvas, they can be instantiated with a parent

crude sierra
#

hmmm interesting

amber flicker
#
We are currently reevaluating our options to find a way to accelerate the availability of new Audio development to all Unity users. Stay tuned!``` ๐Ÿ˜ฌ
safe lintel
#

im genuinely curious if when its finally released will dots audio be a sparkling 1.0 version given the development time or if it will be released as 0.1 super rough like animation

hollow sorrel
#

i think you know the answer

safe lintel
#

maybe this new directive will change things! ๐Ÿ˜…

drowsy pagoda
# crude sierra hey guys, anyone have a reference for entities and UI canvases? I need UI elemen...

The way I do it is I have a system that runs on schedule and updates values to an unmanaged component data. Then I have a managed component data that holds UnityEngine.UI elements like text and image etc. And I create a system w/o burst and run on main thread, and it reads from unmanaged data and writes to the elements stored in managed data. Works very clean no issues. If this is confusing let me know, I can post some examples when I get to computer.

crude sierra
crude sierra
drowsy pagoda
crude sierra
drowsy pagoda
#

As to making the UI elements follow your character in world space, you'd simply just add in your player's LocalToWorld in the ForEach of PlayerUiSystem and there you can calculate the Camera ScreenToWorld blah blah blah, and just do a transform.position + offset to the UnityEngine.UI directly and it will work.

crude sierra
drowsy pagoda
#

So I'm thinking of creating a NameData IComponentData that will hold a FixedString64 and simply copy the GO name at conversion. My question will be about performance. If I have this on hundreds of entities, will this give me a performance ding or is this ok? If it isn't optimal, is there an optimal pattern I can use? Any suggestions?

gusty comet
#

oh wow, at least my DOTS frustrum culling works (and yes, i needed to do my own cause i had noticably higher fps with my own culling)

#

i will try to move as much code to dots as possible though its probably not much ๐Ÿ˜›

drowsy pagoda
#

Why when I finish building it keeps showing me a warning about System.Windows.Forms.dll assembly? I am building for Standalone Win_x64 but forms? Where is it getting this from? I just started this project too, only got like 6 or 7 items in my scene lol. Anyone know what this is about?

slim nebula
#

are you maybe using a message box somewhere or something else subtle in that namespace?

#

also strings are just bad for performance in general. better to use an int or something as a unique id instead of a string name

drowsy pagoda
gusty comet
#

do you usually check for HasComponent or skip it? (before eg add component or remove component)

drowsy pagoda
#

using DOTS/HDRP setup, latest everything. I noticed that if you object is in the Subscene, when mutating the material properties, it doesn't always update in scene/game view. If you take the object out of SubScene and put it in master scene, it updates realtime.
Is there an option for this? Or just a bug for now?

drowsy pagoda
#

Is having entities check for ComponentDataInEntity<SomeData>() each update costly? Should it be standard practice to cache that reference to prevent such a search each frame?

keen root
drowsy pagoda
slow hatch
#

Is it already possible to use the DOTS for performant realtime graphs plotting? If yes - any legit starting point resource in the topic? Pls tag me/DM me if you have any hints. Thank you very much in advance ๐Ÿ™‚

drowsy pagoda
#

When I parent an entity to another, it automatically inherits and sets the scale. In traditional unity, if you set a parent for a gameobject that has a different scale, the gameobject that switched parents automatically gets compensated for it's scale in order to keep it the same size in world space.
However with ECS it is not so, there is no compensation, it rescales it to match the scale of the parent. How can I change the scale of the entity once it jumped parents?
I didn't see any Scale components on it, I tried adding Scale component to it, but nothing happened. Only thing I was able to do was add a CompositeScale, but that gives me a float4x4 and I have no idea how to read that. Can someone help me out here?

whole gyro
drowsy pagoda
whole gyro
drowsy pagoda
#

I tried adding it at authoring level: dstManager.AddComponentData(entity, new Scale {Value = 1f}); and nothing shows up. I can confirm that it indeed does have ltw, rot, and trans attached.

#

No it doesn't, that's why I wrote the question ๐Ÿ˜‰

#

Took me a minute to figure out how to parent it. Because just by adding parent component and setting a value isn't enough ๐Ÿ˜›

whole gyro
#

Is the Scale component just missing in the entities window? Maybe it removes it automatically if it has a value of 1?

drowsy pagoda
#

Maybe, let me try setting it to 0.5f;

#

Nope. Same result. Btw, no default component "auto-removes" itself. I thought this was a behavior for other situations, and when I did some reading, someone from Unity says that no components do that. Just FYI

#

Well, looks like I will stick to CompositeScale and mess with float4x4

#

I just found out that float4x4 has a method called float4x4.Scale() and it will convert it from human-readable float3 to float4x4 ๐Ÿ˜‰

#

dstManager.AddComponentData(entity, new CompositeScale { Value = float4x4.Scale(transform.lossyScale) });
This worked! The composite scale shows up and the object retains it's scale! ๐Ÿ™‚

#

๐Ÿ™Œ

#

It's a shame, it feels like Scale would be a lot easier to work with because I don't have any nonuniform scaling going on right now

whole gyro
#

No idea what CompositeScale is but I'm glad it worked for you! How are you doing the conversion and parenting? If you are converting a gameobject hierarchy, it should automatically add the correct Scale if the child's transform is scaled

drowsy pagoda
#

Yea it does. But this parenting occurs during runtime.

#

Player picks up an item and it attaches to his hand.

#

instead of syncing transform, I just parent it and let the ecs engine do it for me.

#

Crap. I don't know how to extract the scale from a float4x4 :S

whole gyro
#

Okay, I just tried this myself and my understanding was completely wrong. Even without parenting, when I set a non-unit scale on a gameobject, after conversion it gets a CompositeScale added to it. So no Scale component at all

#

And same for a non-uniform scale

drowsy pagoda
#

Yup. It seems that it directly correlates the scale from float3 to float4x4 like this:
X = float4x4.c0.x
Y = float4x4.c1.y
Z = float4x4.c2.z

#

So I'll try messing with them like that and see if it works. But I'm pretty sure there is a method somewhere that can convert it for you...just don't know where to look.

drowsy pagoda
#

Yeah that just returns the float4x4.

#

I want the other way around

#

how can I get a float3 from a float4x4 ๐Ÿ˜‰

whole gyro
#

Oh righto, sorry. Found this when digging through the code in CompositeScale.cs so might be other stuff in there.

drowsy pagoda
#

I dind't find anything. I thought maybe math might have something...nothing either. ๐Ÿ˜ฆ

#

Hmm...the scale remains the same, even after parenting, but the item visually does change scale. It seems it is storing this relationship somewhere else ๐Ÿ˜ฎโ€๐Ÿ’จ

whole gyro
#

LocalToParent maybe?

drowsy pagoda
#

LocalToParnet shows the same values as composite scale!

#

Ok. I think I get how to approach this. I think you're on the right track. So looking at the hierarchy, the LocalToParent shows it's LOCAL scale in relation to parent. All I need to do is traverse the tree until I get to the root parent, and then I will get it's scale in relation to the world. From there I can perform my compensation and change the composite scale on the actual item...

#

Or is there an easier way? ๐Ÿ˜›

whole gyro
drowsy pagoda
whole gyro
#

Just wrote it

drowsy pagoda
#

Thanks, I'll take a look at it

#

so scaleOut gives you the same result as scaleIn right?

#

multiplying the float4(1,1,1,0) tells it the relationship between the two right?

whole gyro
#

yeah, the matrix can be multiplied with any float4 to get a scaled version of it. In this case, float4(1,1,1,0) represents the unit scale vector

drowsy pagoda
whole gyro
drowsy pagoda
#

Btw, this is exactly how Unity does it:

public static float4x4 Scale(float x, float y, float z)
        {
            return float4x4(x,    0.0f, 0.0f, 0.0f,
                            0.0f, y,    0.0f, 0.0f,
                            0.0f, 0.0f, z,    0.0f,
                            0.0f, 0.0f, 0.0f, 1.0f);
        }
gusty comet
#

guys

#

i need to efficiently check (inside ForEach) if at least one children is active

#

i have one idea:
on each chidlren, (i already have children foreach anyway) i will perform the check, then update the nativeArray on parent entity. it can be as simple as bool native array, each children has its index, so i would just set it to false and true

AND then inside another ForEach
id for loop through that native array and check if at least one value is acctive

#

SECOND approach to same problem:

  • skip creation of native array
  • instead simply loop through ChildBuffer and check for HasComponent each time
#

but Second approach may be slower idk

#

cause first one doesnt do HasCopmonent check

drowsy pagoda
gusty comet
#

seems i can use array on ICopmonentDatas, and access them from parrarel jobs?

pliant pike
#

I don't suppose any knows the correct way to check if an entityquery is null or empty or not valid?

#

I keep getting an error object reference not set to an instance of an object

#

I've tried entityquery.IsEmpty and .IsEmptyNofilter they dont't seem to work

karmic basin
#

IsEmpty is about the results

pliant pike
#

same as CalculatEntityCount() I guess

#

is there not a way to check if the entityquery exists, I know why I'm getting the error because the entityquery does not exist yet

hollow sorrel
#

@pliant pike entityquery can't be null

#

sounds like maybe you are trying to use an entityquery that doesn't search for anything?

pliant pike
#

I just did a null check and it seemed to work ๐Ÿ˜•

hollow sorrel
#

and your IDE doesn't give you a warning that it'll always be non-null?

#

that's weird since entityquery is a struct

#

C# lets you check structs for null but IDE should catch that it won't do anything

slim nebula
#

what dots version u using @pliant pike

#

entities package version i mean

pliant pike
#

0.16.0-preview.21

slim nebula
#

looks like in 0.9 it was a class but since then it's a struct

#

0.16 should be a struct

#

struct can't be null

pliant pike
#

surely an entityquery can still be null though

slim nebula
#

structs can't be null in c#