#archived-dots

1 messages · Page 227 of 1

karmic basin
#

Will explain a lot the ECS pattern

languid axle
#

thank you

karmic basin
#

👌 have fun

zenith wyvern
#

Also you can't use a managed list in your component if it's a struct. Only class components can contain managed data which would mean it's not burst compatible

#

You should read up on dynamic buffers

pliant pike
#

similar to those lines

public struct CalcMaxQueueSize
{ 
    public int Execute(float distance, BezierBlobsRef currentBezier)
    {
        while(!endofsplinereached)
        {   

            var positsonSpline = CalcdistOnBezier(currentBezier, distance, tempSplinepos, out tempSplinepos);....```
#

is that just not possible I get the error specified cast is not valid for the BezierBlobsRef

sour atlas
#

hrm. the blue block is when im far away from everything thats drawn (a couple meters) and the red block is when im close to everything being drawn.

karmic basin
pliant pike
#

no I'm just passing in Blobassetref first into the struct and then into a method

digital kestrel
#

how do i attach VS debugger to my debug build made using the windows configuration builder

karmic basin
digital kestrel
#

I attached to my build's exe process ID, but my breakpoint wont hit

pliant pike
#

no prob, I probably found the one obscure way something doesn't work

pliant pike
#

it should come up automatically when you do the attach to unity and run stuff

#

to be honest I don't use it that often because it doesn't seem to always work that well, like you say it doesn't always hit the breakpoints, or it cycles through the unity back end stuff that I don't want

coarse turtle
#

You'll probably want to pass the blob asset by reference

karmic basin
digital kestrel
pliant pike
#

I tried by reference several different ways

#

ref var booked = ref currentBezier.BlobrefVal.Value; thats how I'm getting it by ref in the method

coarse turtle
#

And it doesn't work?

pliant pike
#

nope, it works if I pull the BezierBlobref into the main execute method, but not into the other method

#

its like one layer to many

digital kestrel
#

ok nvm, if you use attach to process, it wont work

#

you have to hit attach Unity Debugger and then make sure it can detect the type "Player"

zenith wyvern
coarse turtle
pliant pike
#

and it didn't work

#

I'm just getting must be passed by ref type errors

coarse turtle
#

oh, is tillqueueesBezzyQuery a ComponentDataFromEntity?

#

or just a NativeArray?

pliant pike
#
public struct BezierBlobsRef : IComponentData
{
    public BlobAssetReference<Beziernode> BlobrefVal;
}```
#

that's basically what it is

coarse turtle
#

Calcmaxqueuesoize.Execute(DistbetweenBots, blobbezzy); should be Calcmaxqueuesoize.Execute(DistbetweenBots, ref blobbezzy);

pliant pike
#

I get this error then error MayOnlyLiveInBlobStorageViolation: Beziernode may only live in blob storage. Access it by (non-readonly) ref instead:ref Beziernode yourVariable = ref ...`

coarse turtle
#

sorry don't do ref on the value, just do ref on the BlobAsset itself

#

so ref var blobbezzy = ref tillqueuesBezzyquery[0].BlobrefVal;, no .Value here

#

then you take the entire reference to the blobasset into your method

pliant pike
#

compiler doesn't allow me to do that cannot modifier the return value etc because it is not a variable

coarse turtle
#

yea what's the accessor [0] to? NativeArray or something else?

pliant pike
#

this tillqueuesBezzyquery = BezierGraph_Query.ToComponentDataArray<BezierBlobsRef>(Allocator.Persistent);

coarse turtle
#

Cause if it's a native array you may want to do this in unsafe territory and access the pointer

unsafe {
  ref var blobbezzy = ref *tillqueuesBezzyquery.Ptr;
}
pliant pike
#

yeah maybe I'll try that, thanks @coarse turtle

#

its just weird how difficult the blob is to access

coarse turtle
#

yea lol

#

I think its just the bracket operator from a native array which messes things up

sour atlas
#

Anyone here who has experience with the BatchRendererGroup API ?

#

I'm trying to figure out what the associatedSceneObject is supposed to be

#

not sure if this is strictly DOTS related but it does seem to use the hybrid renderers so I figured this is the appropriate place to ask

digital kestrel
#

Anyone use CommandBuffer to instantiate and set Translation of an entity, and it looks like they're just teleporting into position

safe lintel
#

no planned release for dots audio this year, beginning to doubt it exists

sour atlas
#

Huh. it definitely seems to be some weird issue with drawing indirect or procedural. drawing using DrawMeshInstanced pretty much doesnt have any issues except for the size limit but DMII and DMIP both just eat up resources like crazy

#

using the same mesh count that is

#

really strange.

left oak
#

That's kinda hard to believe, as DMII can be used to easily draw up to a million instances within reasonable FPS on most machines I've tested

sour atlas
#

I'm going to try to repro in an empty project tomorrow

#

but my initial impression was disbelief too. started struggling immensely after just 500 instances

sour atlas
#

both.

#

Editor is far worse though

fossil obsidian
#

Hello, does anyone know an equivalent for IJobParallelForTransform on the Jobs package, version Preview 0.8.0 ?

languid axle
#

how could i go about a double foreach entity loop?

left oak
#

I would generally avoid that kind of everything-references-everything-else nested foreach. However, if you really needed to apply the contents of some inner loop to an entire query individually, I would store the contents of the inner loop in a native container and pass it into the job

sour atlas
#

seems that whenever one of the SRP callbacks is used DMII slows down a lot

#

i can easily draw 100k cubes if DMII is called in a gameobjects update method, if I do the same for any of the SRP callbacks, i can barely handle 1k.

#
public class DMII_TEST : MonoBehaviour
{
    public Mesh mesh;

    public Material material;

    public uint count;

    public ComputeBuffer argsBuffer;
    void Start()
    {
        uint[] args = new uint[5];
        args[0] = mesh.GetIndexCount(0);
        args[1] = count;
        args[2] = mesh.GetIndexStart(0);
        args[3] = mesh.GetBaseVertex(0);
        args[4] = 0; //offset

        argsBuffer = new ComputeBuffer(1, 5 * sizeof(uint), ComputeBufferType.IndirectArguments);
        argsBuffer.SetData(args);

        RenderPipelineManager.beginCameraRendering += Draw;
    }

    // Update is called once per frame
    void Draw(ScriptableRenderContext context, Camera cam)
    {
        Graphics.DrawMeshInstancedIndirect(mesh, 0, material, new Bounds(Vector3.zero, Vector3.one * 1000.0f), argsBuffer);
    }
}

#

for context this is how the whole thing is set up.

#

while this seems like a bug to me i have a hunch im missing something in the larger context.

remote crater
sour atlas
#

Im pretty sure you can just reconstruct the local to world matrix using Matrix.TRS and using some of the built in quarternion methods to look at a point

remote crater
#

I tried

#

Quaternion is the math I don't even have a clue how to read the data... I know all math but matrix math. I am not Neo yet.

#

So I can't even low level debug it. I'll show you what I got, but it is ugly.

sour atlas
#

I'd recommend you learn both of it, its actually quite straightforward.

remote crater
#

If I have this, I'll get 100,000 entities

#

Dude, I took a uni course on it

#

I know diffeyQ

#

I know all upper level advanced math

#

but Matrix Algebra I cant get

#

I tried hundreds of hours already

sour atlas
#

ah lol thats unlucky

#

translation matrices are easy though 😛

remote crater
#

This is literally the last problem I have

#

Then please halp!

#

If easy for you, hard for me, help a brother out man

sour atlas
#

share your code, ill take a look in a sec

remote crater
#

playerPos is the point I am trying to look at, aka have drones look at me

sour atlas
#

well the first thing is you’re using quarternion.xzy but passing values in xyz

remote crater
#

If I can look at player, then I can incrementally look at it slowly, add some thrust, boom AI done in under 10 minutes, We could have 100-500 thousand enemy drones after me 🙂

#

cool

sour atlas
#

im gonna brb, maybe that fixed it already though

remote crater
#

I tried every permutation...

#

I'll go back to the one which looks cromulent

#

Okay, double checked, the mesh alignment is same as my other properly facing ships, forward is z direction in editor.

#

So I am not sure why it doesn't look right at me... Is this due to Local to World rotation or something?

zenith wyvern
remote crater
#

If someone helps my LOOK AT problem, I will 1) Make a DOTS/ECS video tutorial on how to make DOTS/ECS easy and implementable in any GameObject PlayerController game, 2) Make a video with max drones, maybe 100,000 to 1,000,000!!!! 3) You can ask me for money if I make it big: https://forum.unity.com/threads/how-do-i-have-an-entity-lookat-a-worldspace-point.1164212/ & https://old.reddit.com/r/Unity3D/comments/pf5hpv/dots_ecs_question_in_a_systembaseforeach_how_do_i/

stone osprey
#

There different Allocator types as far as i know... is there any allocator type which does dispose automatic without me needing to call .Dispose() ?

remote crater
#

This is a problem that stumped be for days, but people who know quaternians and look at and local to world could do it in less than 1 minute.

safe lintel
#

@stone osprey temp is automatically disposed

stone osprey
# safe lintel <@!507208990300569600> temp is automatically disposed

Hmmm... what about the following case...

Theres a component with a UnsafeList... like this MyCMP{ UnsafeList<int> ints... }
And at some point i replace/set that component... with a new MyCMP and a new list of ints

But the UnsafeList never gets disposed... And the code for replacement is auto generated... so i cant really implement a automatic disposal in there before being replaced.

How should we deal with that ? Current using Persistent allocation but Temp wouldnt help either...

sour atlas
#

@remote crater ltw.Value = float4x4.LookAt(pos, target, math.up);

try this

#

im thinking that the issue might be related to the mathematics library implementing certain methods differently which might cause some issue. not sure though your code looks like it should work to me.

zenith wyvern
# stone osprey Hmmm... what about the following case... Theres a component with a UnsafeList.....

With unsafe containers on components it's up to you to dispose the container before your component goes out of scope. If you don't it's a memory leak. That's why it's unsafe. You can use https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/system_state_components.html to respond to when a component is being destroyed - keep a reference to your unsafe container on the state component and destroy your unsafe container when your original component gets removed

#

Also if your unsafe container is just a list of ints it would make a lot more sense for that to just be a dynamic buffer so unity would manage it for you

stone osprey
remote crater
#

error

sour atlas
#

oh yeah it needs to be math.up()

#

my bad

remote crater
#

ty

sour atlas
#

though i dont think thatll solve the issue

remote crater
#

Solution was this: rotation.Value = quaternion.LookRotation(pos - pos2, math.up());

#

A guy stopped on my stream named RonCutty ! shweet

digital kestrel
#

any good way to dispose Native contrainers after you schedule a job without forcing a sync point?

#

nvm got it. You can use "WithDisposeOnCompletion()" method in your foreach loop

remote crater
#

I have some cool videos of 50,000 drones being rendered, but I need to figure out how to have them face me, and how to thrust slowly in their forward facing vector: https://youtu.be/0mCvEnO7agE & https://youtu.be/SkplehSS0PA

I was wrong, 60,000 says no, 50,000 was 12 fps aka 60 fps in normal game.

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Kore...

▶ Play video

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a spam email, and only 32 tickets sold for pro event War3)

#1 World S...

▶ Play video
#

Thanks to RonCutty for helping me do correct "Object pooling" in Entity DOTS cuz... its not the same.

remote crater
#

If I get that, I have 50,000 drones chasing me 🙂

sour atlas
#

well having them move towards you should be relatively easy, just apply forward force along the local forward facing axis (usually the Z axis)

#

maybe this can help you with it

remote crater
#

ty

remote crater
remote crater
#

This is getting good.

#

Question: How do I slerp a lowercase quaternion of DOTS/ECS?

safe lintel
#

math.slerp

remote crater
#

ooooh

#

Thelebaron coming up clutch, ty bro

languid axle
#

how do i make a double for loop?
previously my game used a for loop in each gameobject in a list
each object used a static list
how do i make it in dots?
it says list cant be used

safe lintel
#

you can use a native collections in place of old managed collections

#

so NativeArray for arrays, NativeList for lists

#

there are also unsafe collections but I havent messed around with them personally

remote crater
#

Math.slerp works

#

its creepy watching em all look at me

languid axle
#

thank you

remote crater
#

This should look super cool bros. Give me 20 minutes and I'll have a bad ass video clip of 50,000 droids chasing me

languid axle
#

i'll wait

remote crater
#

Oh I think I just set the velocity

#

Looks like velocity can't be passed a scalar, but a vector. So I need a Euler to multiply my scalar against the rotation... I see that I can pass a Euler to a quat, but can't get a Euler from a quat.

safe lintel
#

you can use the RotationEulerXYZ component and variations of it(zyx etc) instead of rotation

remote crater
#

Last question for day, promise! How do I get the forward movement vector of an entity in foreach?

languid axle
#

what is the best way to iterate for each entity

#

Previously each gameobject had a loop that iterated from a list of other game objects

#

whats a way to do it in ecs?

#

native lists are complicating with errors

safe lintel
#

@remote crater fwd = math.forward(rotation.Value);

#

@languid axle use an Entities.ForEach loop? not really sure what you're attempting to do

languid axle
safe lintel
#

just another loop? whats wrong with using a for loop with a nativelist?

#

cant remember if dots supports foreach yet, but I never use foreach

languid axle
#

commanagetdata is my struct

#
[GenerateAuthoringComponent]
public struct ComManagedData : IComponentData
{
  public static NativeList<ComManagedData> Lcom = new     NativeList<ComManagedData>();
    public float M, D, V;
    public RigidBody rb;
    public PhysicsVelocity vel;
    public PhysicsMass mass;
    public LocalToWorld l;

    public void MoveTo()
    {
        foreach (ComManagedData rock in Lcom)
        {
            //sum
        }
    }
}
coarse turtle
languid axle
coarse turtle
# languid axle the one above your message

Oh, by default NativeContainers will have safety handles, which are not blittable. So you cannot include native containers into your IComponentData struct.

Better to just separate the static variables into a different class as burst has trouble interpretting the static NativeList

gusty comet
#

How does one simply place an entity within a Scene file? Does everything have to be added at runtime using a "manager" script? If so, how do you place entities at precise positions without guesstimation?

gusty comet
#

Hmm

#

As a side question, when is DOTS currently expected to be production-ready? 2022?

languid axle
coarse turtle
coarse turtle
# languid axle well that means i can't use a list in the burst system, what other ways are ther...

Wdym? Of course you can use a NativeList in a burst system. What I'm saying is, it's probably better to separate your static list into a static class of some sorts or use the SharedStatic.

public static class SomeStaticHandle {
  public static NativeList<SomeType> List;

  public static void Initialize() { 
   // Initialize your static list
  }
  public static void Release() {
    // Release any allocated data
  }
}

[BurstCompile]
struct SomeJob : IJob {
   // Read/Write access in this job
  public NativeList<SomeType> List;

  public void Execute() { /* Do something */ }
}

// In OnUpdate
Dependency = new SomeJob { List = SomeStaticHandle.List }.Schedule(...);

See shared static in the docs: https://docs.unity3d.com/Packages/com.unity.burst@1.5/manual/docs/AdvancedUsages.html#shared-static

languid axle
#

@coarse turtle

coarse turtle
#

Dependency is a JobHandle. new ComManagedData is not a JobHandle type

#

The example I posted above has a Job struct which implements IJob. To get a JobHandle, you have to call Schedule() on the struct.

languid axle
#

oh, didn't noticed
ok so i added it and it seems fine in vs

#

what would be the proper way to use the for each loop?

coarse turtle
languid axle
#

which sample?

coarse turtle
#

ECSSamples would be fine

languid axle
#

thanks

remote crater
# safe lintel <@!751340700213313557> `fwd = math.forward(rotation.Value);`

It worked, now I have some REALLY trippy cool stuff to work with. Not for people with space snake ship phobia: https://youtu.be/DOMnUNvWUhU https://www.youtube.com/watch?v=Ai5UfFsDGv8 https://youtu.be/TJJI58csYFM I told you it'd be trippy.

Dear community: name my videos. Leave a suggested name in comment.

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a ...

▶ Play video

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a spam email, and only 32 tickets sold for pro event War3)

#1 World S...

▶ Play video

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a spam email, and only 32 tickets sold for pro event War3)

#1 World S...

▶ Play video
#

I gotta compile a release version and see what we're working with

remote crater
#

My release version is different than my editor version. My release version shows an entity for a split second then disappears. I'm concerned. It took me 2 months to get a release even compiling earlier this year if you remember. I said last question before so I'm not looking for an answer. I just want to show the dif between my editor version and release version: https://youtu.be/JWm3gKNs2-o

Question: Any help? Comments etc.

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a spam email, and only 32 tickets s...

▶ Play video
gusty comet
#

Is it bad to mix MonoBehavior and ECS? Can I use the old GameObject UI system in a primarily DOTS-oriented project?

zenith wyvern
#

You don't really have a choice, there's a lot of areas DOTs hasn't fleshed out yet, UI is one of them

gusty comet
#

Hmm

#

Well, it's not as though UI has much of an impact on performance anyway

remote crater
#

Solaris, 100% your old player controller should be recycled

#

Just mimic the entity with the game object's transforms.

#

and do branches depending on game type or zone to make sure you entity

#

Its super simple

#

And proper design patterns

#

Proper design patterns cuz you don't make redundant methods.

#

Always want one function to do it all. Once you're changing code in two places for every update, you lost.

#

Gonna make a youtube video shortly once my game is playable!

#

I'll make DOTS easy for everyone. 🙂

gusty comet
#

Does conversion just feel like a hacky workaround of a solution to anyone else?
As in, entity creation and component setup should be a part of the standard scene system and fully compatible with the inspector and hierarchy windows?

rugged grove
remote crater
#

I promised no more questions yesterday, but it is a new day. What are reasons my standalone windows.exe plays differently than my editor version?

sour atlas
sour atlas
#

Also, do entity queries have to be disposed of ? I'm not quite sure i'm understanding them correctly

remote crater
sour atlas
#

are you 100% sure ?

#

im having some issues with memory.

#

sure most of it is due to game objects

#

but

#

4.4GB memory is a whole lot

remote crater
#

my project runs at about 4-18 GB, but I have a large project

#

Maybe its Unity tho, I don't use profiler

#

I see it in task manager

#

I think my problem is my Buildconfiguration.

remote crater
sour atlas
#

sorry, no idea, havent built anything in DOTS yet

remote crater
#

On this page[ https://dots-tutorial.moetsi.com/unity-ecs/publish-builds-in-unity-ecs] , it says: Click "+ Add Configuration" under Shared Configurations at the top of the Inspector than drag "Base" into the Shared Configuration field (drag gently, so that macOS Build Configuration stays selected). Please note: "Base" may already be there in more recent versions of Unity Editor.

#

I cannot find a + Add Configuration button in Buildsettings

zenith wyvern
# sour atlas

The hierarchy view should help you narrow it down, it explicitly shows the source of all allocations

#

But no I don't think queries need to be disposed afaik

sour atlas
#

yeah thats my thought too so far

digital kestrel
#

anyone get this error even though you are capturing a local variable

error DC0012: WithReadOnly requires its argument to be a local variable that is captured by the lambda expression
pliant pike
pliant pike
#

you are putting withreadonly for the variable in the statement for the entities.foreach?

karmic basin
digital kestrel
#

@pliant pike

        Entities
            //.WithoutBurst()
            .WithReadOnly(formationPosArray)
            .WithReadOnly(entityToFormationMap)
            .ForEach((Entity entity, ref Swarmania.SwarmlingCharacterControllerInputs controllerInputs, ref SwarmlingFormationComponent formationComponent, in Translation translation, in SwarmlingComponent swarmling) => 
            {
                //UnityEngine.Debug.Log("Follow Player");
                int index = formationComponent.FormationArrIndex;
                float3 target = formationPosArray[index];
                float distSQ = math.lengthsq(target - translation.Value);
                controllerInputs.WorldMoveVector = float3.zero;

                if (formationComponent.ReachedTarget == 0)
                {
                    controllerInputs.WorldMoveVector = math.normalize(target - translation.Value);
                    formationComponent.ReachedTarget = (byte)((distSQ <  .5f * thresholdSQ) ? 1 : 0);
                    //UnityEngine.Debug.Log("[SwarmFollowSystem]: LESS THAN" + (distSQ));
                }
                else if (formationComponent.ReachedTarget == 1 && distSQ > moveAgainThresholdSQ)
                {
                    formationComponent.ReachedTarget = 0;
                    controllerInputs.JumpRequested = true;
                    controllerInputs.WorldMoveVector = math.normalize(target - translation.Value);

                    //UnityEngine.Debug.Log("[SwarmFollowSystem]: GREATER" + (distSQ));
                }

                //UnityEngine.Debug.Log("[SwarmFollowSystem]: Has Reached Target " + (formationComponent.ReachedTarget > 0));
                
            })
            .WithDisposeOnCompletion(formationPosArray)
            .WithDisposeOnCompletion(entityToFormationMap)
            .Schedule();
#

both DisposeOnCompletion and WithReadOnly have problems capturing these local variables

#

what's weird is that it was working the day before

#

i added another entities.foreach loop before this one and it some how fucked the compiler

pliant pike
#

that is weird

#

yeah sometimes you have to be careful with two entities foreach in a row

digital kestrel
#

maybe i should delete my library folder

pliant pike
#

sometimes the second job can start before the first job has finished

karmic basin
#

@digital kestrel you don't use entityToFormationMap inside the foreach unless I'm blind

#

If so, remove the With instructions for this container

#

Or use it inside the lambda because you told the compiler you were about to :p

digital kestrel
#

@karmic basin You are right :p. I was using it earlier but decided to change my components to store the index instead lmao

#

yeah that fixed it ^^

cerulean pulsar
#

Has anyone experienced many warnings that say AssetDatabase.FindAssets: Folder not found: 'Packages/com.unity.netcode' when profiling a NetCode project?

remote crater
karmic basin
#

Woa lot of stuff happening here

#

You sure you need everything ?

#

LIke you have a lot of config set to zero or empty

#

You didnt save your scene. And how many others do you have ?

#

Is it the first time you try a build or did you manage one in the past ?

#

I assume you have the platforms but also the platforms.windows package installed ?

#

I also put the scenes in the legacy build menu, just to be sure :p

remote crater
#

ty

remote crater
zenith wyvern
remote crater
#

I saw that before. How do I use it? I'd download the win64, but which one? And where do I put that file?

zenith wyvern
#

I'm not sure what you mean by download, you can copy them and change the build targets

remote crater
#

So do I import them as asset package?

zenith wyvern
#

Just look through their inspectors, it shoudl be pretty clear what you need to change to make it build your project. If I remember right you should only need to change which asmdef it's referencing

#

I don't know what you mean by importing an asset package. They're just assets, no different than a texture or a tilemap

#

Just copy the relevant configuration along with it's .meta file and fix the broken stuff in their inspectors

karmic basin
#

Yeah they're pretty barebone

#

The livelink ones just have the livelink component added and that's it

cerulean pulsar
#

Is it possible to enable Deep Profiling via a build configuration asset? I can't seem to find the component for it

cerulean pulsar
coarse turtle
#

huh kind of odd blob array has a ToArray() method but doesn't have a ToNativeArray alternative lol 😦

cerulean pulsar
remote crater
karmic basin
#

You miss the profile component to tell which platform you target

remote crater
#

Which ones do I need:
Win64-Build.buildconfiguration
Publishing samples for Entities 0.17
Win64-Build.buildconfiguration.meta
Updated ECSSamples
Win64-LiveLink.buildconfiguration
Publishing samples for Entities 0.13

#

I'm windows 10.

#

I'm so confused, sorry for spam, this should be automatic, not require this level of arcane tech knowledge

karmic basin
#

Hmmm can you show you manifest.json ?

#

making sure you have the platforms and platforms.windows installed

zenith wyvern
#

I think you need "BaseBuildConfiguration" as well

#

From the samples project. The other ones work on top of that one from what I remember

zenith wyvern
#

Just another fun unity quirk

karmic basin
#

Uhm the base should only be the 3 components in my screenshot 🤔

#

then they do overrides for each platform

#

If I remember well

#

or set everything again, don't remember

remote crater
#

You know, screw doing this now. I'll just make a good game and when people see it is a good game, people will help me make a standalone.

karmic basin
#

At least check your manifest file or package manager, see if you miss com.platforms.windows. It takes 2 minutes

cerulean pulsar
remote crater
digital kestrel
#

anyone have any good resources for getting animation in?

#

i know the dots animation package is new af

low tangle
#

hows the current state of the world

#

entities making any progress?

zenith wyvern
#

If it is unity is being pretty quiet about it

viral comet
#

@digital kestrel are you still looking for a Behavior Tree dots implementation?

pine plaza
rough blaze
#

Hi, does anybody know how to import the job system Native Lists into unity 2020.3? and also can i use native lists in IParallel jobs? I want to generate marching cubes meshes using the job system and using native arrays is limiting the size of the mesh

jolly sparrow
rotund token
#

You can actually, there's a AsParallelWriter version of NativeList

#

You just can't expand it's capacity

#

It has AddNoResize method

karmic basin
#

Then using Unity.Collections; will provide all native containers

toxic crest
#

I'm just starting to play with BuildConfiguration assets and if I'm understanding these right, this is pretty cool.

#

Is there and half-decent documentation about BuildConfiguration assets?

digital kestrel
#

my internet got blown out by the storm yesterday 😦

viral comet
digital kestrel
#

wow, awesome :). I'll check it out! Thanks for sharing

viral comet
#

it should be simpler than EntitiesBT

#

and not slower 🙂

digital kestrel
#

does it support burst

#

I think that was the major problem with Entities BT

viral comet
#

@digital kestrel yeah, it does.

#

Compatible with burst and il2cpp.

digital kestrel
#

nice!

languid axle
#

How can I make a reference for an object or entity?

#

And make the job system use it’s values?

#

On other entities

viral comet
#

@languid axle entity is just a struct that contains two int values (id and gen)

#

so it's easy to make a reference this way:

public struct LinkToSomeone : IComponentData
{
    public Entity value;
}
languid axle
#

And how can I make the job system use any variable inside of that struct?

#

To apply it in the OnUpdate

#

On other entities inside the foreach

viral comet
#

it's just a component (IComponentData)

#
  1. Add this link component to an entity
  2. Query entity in Entiteies.Foreach by passing it directly in lamda as a parameter in LinkToSomene link
  3. so anything you want with the referenced entity:
    var someoneEntity = link.value;
zenith wyvern
toxic crest
#

Are you able to use a relative build output path in a build configuration asset? If so, if so, is the path relative to the asset or some other location?

karmic basin
#

uhm.... try it and tell us ? 😛

toxic crest
#

working on it lol

toxic crest
#

It supports relative paths. Paths are relative to the root project folder as well

#

Was kind of worried where it might shoot the build out lol

whole gyro
#

Has anyone had success with the "Hybrid Per Instance" setting in shader graph? My shaders work fine in play mode and I can change the property at runtime per-instance using a MaterialProperty. However, whenever I try to open the shader graph editor for the shader, it spits out these errors:

Shader error in 'Master': syntax error: unexpected token ')' at line 315 (on d3d11)

Shader error in 'Master': undeclared identifier 'UNITY_ACCESS_HYBRID_INSTANCED_PROP' at line 315 (on d3d11)
hexed heron
#

where is this menu in 2021.1.16

#

i only see burst->

karmic basin
#

I don't use 2021 (and it's recommended you don't) but maybe you lack a package ? Like the Jobs one ?

#

or Collections

hexed heron
#

well my entire project depends on it so I think I have jobs

karmic basin
#

Okay and Collections ?

hexed heron
#

1 sec

karmic basin
#

double check in package manager or manifest.json file

hexed heron
karmic basin
#

So it might come from the Entities package

#

I can't tell I installed all of them at once

hexed heron
#

entities is no longer in the package manager apparently

#

tried to install from git URL and got an error

karmic basin
#

yup it's experimental

#

anyway if it really comes with entities package, would it really kick in for a Jobs only project ? 🤔

hexed heron
#

i just want to debug my memory leaks

#

:[

karmic basin
#

installing from git url worked for me

#

or maybe i added lines in the manifest file, you could try that

#

but you need to find yourself which version is compatible

hexed heron
karmic basin
#

syntax typo

#

com.unity.entities

hexed heron
#

ahhhh

coarse turtle
#

You just need the jobs package for that menu btw

#

I have a jobs & collections only project and the menu still appears

karmic basin
#

He said he had both and didnt see the menu 🤷‍♂️

#

but yeah first guess would be the Jobs one

#

going to bed, see ya everyone 👋

hexed heron
#

After I installed entities I got this error The type 'U' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

#

RIP

#

still don't have the menu

hollow sorrel
#

if you have compilation errors that'd explain it

hexed heron
#

I didn't have that error until after I installed entities

hollow sorrel
#

entities has it as a dependency so if you fix that compile error it should show up

#

but if you just want jobs without entities, add "com.unity.jobs": "0.8.0-preview.23", to your package manifest

hexed heron
#

thanks, burned out for now but will try that later

unreal wraith
#

can i use classes with threading?

median glen
#

Considering that C# is a fully objected oriented language

light ore
#

Hi everyone, Im having issues building my scene (w entities) to mobile. I do not see anything being rendered..

#

The last time I tested, was on Unity 2020.3 LTS

#

Hybrid renderer- Version 0.11.0-preview.44

#

Entities- Version 0.17.0-preview.42

#

URP- Version 10.5.0

#

I also set the Graphics API to only Vulkan as said by some google searches, but wel[

#

Any suggestions are appreciated. Ive spent some days on it already and I cant afford further delays, I must revert back to just URP and do things that way, but rendering my scene with DOTS will certainly help, at least I could test it

unreal wraith
#

Is it possible to run the main thread and alternate threads at the same time

#

Or just multiple alternate threads while the main thread waits

hot basin
hot basin
#

so you will copy a lot of data (your whole unit/entity worth of data) per every change

#

I wonder how's your performance

viral comet
#

And although it is advisable to avoid archetype changes, in this context I think it's the only way to process agents

viral comet
hot basin
#

Yeah, you're probably right. All I can think of is to divide this to "ai agent" and "unit". Then there is less data to copy, but also there is a trade off of random access unit data.

viral comet
#

but also there is a trade off of random access unit data.
yeah, i believe so.

The only idea i have is to change separated state components into a one big state component, with different enum values... And make early return if no relevant

#

something like that

hot basin
#

yeah but I don't like "big switch" solution either

#

but maybe is better as you can have only one archetype which means 0 chunk separation

hard wagon
#

Did Unity removed .WithReadOnly() from Entities? Or was that replaced with something else?

viral comet
#

well, it will looks like
Entities.Foreach((in State state) => if (state.value != AiState.attack) return; ....);

#

no switches, but still ugly enough 😄

hot basin
#

yeah, but you still need different components to differentiate behaviour

hot basin
hot basin
#

I wonder if many ifs are quicker than one huge switch

viral comet
#

yeah, but its on the other hand produce branching

hard wagon
viral comet
#

maybe i'll benchmark it 🤔

hot basin
#

weird

hard wagon
#

🤷‍♂️

hot basin
#

hmm try updating your IDE plugin? maybe thats the problem

#

except that I get nothing

hard wagon
#

o wait.. either way, They're both up to date. Unity still complains that WithReadOnly couldn't be used... either.

hot basin
#

restart editor 😄

hot basin
hard wagon
#

It ended up going through the same safe mode over and over due to this WithReadOnly() error

mystic mountain
hot basin
hard wagon
viral comet
#

@hot basin i'm not sure anything being announced 😬

#

devs are silent this year

hot basin
#

yeah, is an old announcement

hard wagon
#

So.. has anyone had trouble opening the DOTSSample project under 2019..3.6f1? It fails to open the project and the log file report that it's a license issue, but I can open other unity version just fine beside this project?

valid haven
hot basin
#

I think you need something more than static spheres to say if GOs are fast

valid haven
#

gameobjects are plenty fast for my purposes, because I don't depend on unity's update methods, all colliders and audio/visual gameobjects are pooled per entity type, and all of my world state is being updated with burstable jobs.

unreal wraith
#

how can i use jobs so that the main thread does something while alternate threads do something. instead of the main thread waiting for the alternate threads to do something

valid haven
#

schedule the job, keep the handle then call complete later.

unreal wraith
#

is their a way to call complete automatically when the other threads are done that way the main thread doesnt have to wait for them

valid haven
#

You need to pick some thread that is going to manage the scheduling and completion of your jobs and their dependencies. If all of the jobs have finished their work then calling complete on main thread isn't a concern in most cases because.... well it has finished 🙂

#

the issue I think u are talking about is where u schedule a job then immediately call complete, in which case the main thread blocks while it waits for it to finish.

#

instead call complete the next frame, or longer depending on how much work it needs to do

unreal wraith
#

so you kinda have to guess when it will be done

valid haven
#

the handle has other properties to determine its state

unreal wraith
#

basically im trying to generate endless terrain via chunks, and im trying to determine how i should use jobs to generate the chunks, how do you think i should do the jobs? should i guess when the jobs are completed? should i call complete right after i schedule? or should i just check if the jobs are dones using the iscompleted property in update of the main thread.

zenith wyvern
unreal wraith
#

ok

valid haven
#

anyone see what i am doing wrong here? I am not super clear on how job dependencies work in the case where each job above depends on all of the previous ones. But with the above code it throws errors saying I must complete previous jobs before passing in data to the next to read/write.

zenith wyvern
#

If it's a chain of jobs that all depend on eachother you should only need one jobhandle:

var handle = new SomeJob(...).Schedule();
handle = new SomeOtherJob(...).Schedule(handle);
handle = new SomeThirdJob(...).Schedule(handle);

And so on

valid haven
#

hmm I tried that, still throwing warnings at me unless I disable them

zenith wyvern
#

Warnings or errors?

valid haven
#

errors

zenith wyvern
#

What if you remove the combine dependencies part? I'm pretty sure that would mess up what you're trying to do

valid haven
#

that still throws the error

zenith wyvern
#

And is this something you're trying to do every frame? Does it still give an error if you only do it once?

valid haven
#

yes every frame, I give it a full frame to complete otherwise I complete it

#

that is the error with the above change

zenith wyvern
#

Oh, you still have to complete it if it's complete

#

What I mean is, if IsCompleted is true, you need to call Complete on the jobhandle

#

So the safety system knows it's okay

valid haven
#

well that fixed it... lol

#

thanks. that is a bit misleading.

zenith wyvern
#

Yeah that got me for a long time when I first messed with jobs, hahah. Very confusing

valid haven
#

its needed even if you call Run()?

zenith wyvern
#

If you're trying to Run() a job that is using shared data from a threaded job then the safety system would still expect you to ensure that first job was complete

valid haven
#

i c, k thanks.

unreal wraith
#

if i were to use threading to load my chunks, should i load my chunks as a big square or in a radius?

#

like this?

#

or like this?

zenith wyvern
#

I'm not sure I follow what threading has to do with the question

viral comet
#

It only depends of what exactly player can see

unreal wraith
#

threading has some relevance to this, because in a radial generation the threading has less of a purpose since the chunks would be mostly loaded one at a time @zenith wyvern see here: https://youtu.be/xlSkYjiE-Ck?t=1022 i left a timestamp

Welcome to this series on procedural landmass generation. In this episode we begin work on an endless terrain system.

The source code for this episode can be found here:
https://github.com/SebLague/Procedural-Landmass-Generation

If you'd like to support these videos, I have a Patreon page over here: https://www.patreon.com/SebastianLague

▶ Play video
amber flicker
light ore
#

I do have the Hybrid v2 define in the settings @amber flicker

About the nee build workflow, I assume its using the "Build configuration"? Which I have not used 🤔

amber flicker
#

Not sure if vulcan will work. Could also try messing with the urp batcher settings

light ore
#

I'll look into the build configurations rn, thank you!

hot basin
#

is there documentation about blob assets?

sturdy rune
#

I used this

pliant pike
#

there's also this, which maybe a bit more up to date

#

📌 Download the full project files: https://tmg.dev/BlobAssets 📌
👨‍💻 Code/Scripts from this video: https://tmg.dev/BlobAssets-Code 👨‍💻
💬 Come chat with other DOTS/ECS devs: https://tmg.dev/Discord 💬

🚧 Resources Mentioned 🚧

▶ Play video
stone osprey
#

Im using UnsafeList and i want to be able to store my "own" struct into it... is there any tutorial for that ? It says it must be splittable and stuff like that but i have no clue on how to implement those 😮

My struct basically looks like this right now

public struct NestedEntity{
   ... some other methods
   public IList<object> Components{ get; set; }
}

Yeah dont wonder, its only used for networking to transfer a bunch of entities in a nested way.

shell berry
coarse turtle
#

the problem with IList<object> is, how can you determine the exact size of IList<object>? You won't be able to in native memory without some sort of interop marshaling from managed to native memory

stone osprey
#

While being burst compatible

coarse turtle
hot basin
#

can I somehow make DynamicBuffer a parallel writer?

stone osprey
#

Is .Schedule also possible without burst ?

coarse turtle
stone osprey
pliant pike
hot basin
#

oh there is Entities.WithNativeDisableContainerSafetyRestriction thanks!

pliant pike
#

yep that's it

hot basin
#

hmm but can I somehow tag variable from lambda with this?

pliant pike
#

what do you mean tag

hot basin
#
Entities
                .WithName("BTSystem_GetTask")
                .WithSharedComponentFilter(behaviourTree)
                .ForEach((
                    Entity entity,
                    ref DynamicBuffer<BTNodeStatusBuffer> nodeStatuses,
                    ref BTCurrentNode currentNode
                ) =>
                {
#

I want this DynamicBuffer<BTNodeStatusBuffer> to be with disabled restrictions

#

or need I get it with GetBufferFromEntity<>(); and pass is with Entities.WithNativeDisableContainerSafetyRestriction?

pliant pike
#

yeah getbuffer would probably be better

stone osprey
#

Could need some quick help...
This is an error i receive...

Why is this happening ? My "Equipment" struct is not marked as burst compatible so i thought unity does not care what the hell i am putting into my structs...

#

This is how my equipment looks like

#
    public struct Equipment : IComponentData {
        
        public UnsafeHashMap<FixedString32, Entity> equiped;
        public NativeHashMap<FixedString32, Server.Pattern.Entity> equipedEntities;
    }
hot basin
#

NativeCollections are not blittable

stone osprey
#

Yeah but they dont need to be ? I mean... im not using burst anywhere ^^

#

Or do normal struct components also require blittable data

hot basin
#

latter one

pliant pike
#

yeah nativecontainers can't really be used like that

#

there like temp containers, how would you dispose of them

stone osprey
#

Damn... thanks... so how am i supposed to store a public struct Entity{ List<Object> components} in one of my structs ? 😐

#

Or do i really need to use pointers for storing objects at this point ?

coarse turtle
#

you need a solution outside of Unity's Entities framework

hot basin
#

if you are porting OOP algorithm you probably need to redesign it

stone osprey
coarse turtle
#

e.g. you can potentially store that kind of data into a separate storage and map elements to an entity (potentially vice versa too)

pliant pike
#

yeah instead of using a whole class or struct, just find out what the exact data you need is and then convert that directly into a dynamicbuffer or component

stone osprey
#

That sounds great... but is not possible rn :/ On my server items are implemented as EC entities ( Not ecs ), means they are dynamic... just a list of objects.
And i also wanna treat them that way on the unity client. Furthermore its great to deserialize

Is public struct NestedEntity{ UnsafeList<IntPtr> components } blittable ? Then i would be forced to pin its components and dispose them manually but wouldnt that work ?

coarse turtle
#

Well the caveat is you'll need to manage the lifetime of IntPtr. Not really sure what to tell you since you want it to be generic, you'll need to write things on top of Entities in order to help you manage "generic" data

stone osprey
coarse turtle
#

I think you're going to need to start thinking of constraints in your datatype to specifically use Unity Entities 🤔

stone osprey
#

I think i can actually free them... without knowing the type or ?

//Pin it 
GCHandle myArrayHandle = GCHandle.Alloc(result,GCHandleType.Pinned);
//use array
while (r < length)
{
    int bytes = client.Client.Receive(result, r, length - r, SocketFlags.None);
    r += bytes;
}
//Unpin it
myArrayHandle.Free();

Atleast it looks like theres no type required when calling .Free();

coarse turtle
#

Yea you can free any pinned gchandle

stone osprey
#

I started with items are also entities but i quickly realized that its not works the persistence and networking pain... thats why i try to implement those EC entities on top of the ECS instead

karmic depot
#

Does anyone know which is more performant to get other entities' component inside Entities.ForEach jobs: calling GetComponent() or passing in the result of GetComponentDataFromEntity? I suspect there's a difference (cache misses or something)
edit: huh, interesting:

When you call this method inside a job scheduled using [Entities.ForEach], this method gets replaced with component access methods through <see cref="ComponentDataFromEntity{T}"/>.`

pliant pike
karmic depot
pliant pike
#

I think getcomponentdatafromentity is kind of an old method I personally wouldn't use it

unreal wraith
#

can you have classes inside a job struct

stone osprey
zenith wyvern
#

You can see for yourself in the code inspector

twilit coral
#

There are raycastCommands, Spherecast Commands, is there a way to do OverlapSphereCommand? or just a way to jobify Physics.OverlapSphere?

stone osprey
#

How do i enable unsafe context in unity ? I just tried to return a (MyLocation*) and rider and unity are telling me that i need to enable the unsafe context... but i cant find the settings location... any ideas ?

zenith wyvern
#

It's buried in player settings somewhere. If you're using asmdefs there's an option on the .asmdef asset to enable it per assembly

stone osprey
#

Thanks ! ^^ Im gonna take a look there

karmic depot
stone osprey
#

Someone up for a little bit of theory help ? Its about networking entity relations...

Theres a client and a server.
I have players and items on my server. Both are entities on their own. The player references the item entities UnsafeList<Entity> itemEntities

At some point my server needs to send a serialised player entity to the client. This is done by transforming the Entity to json. So we send a player json and one json for all his items... this could look like this...

Entity{ 
   Components: [
     Player{ 
        Items:[
           10, 50, 1, 3 ( The entity index actually ) 
        ]
     }
   ]
}

Entity{ 
   Components: [
     Item{ int amount, byte stackable, ...  }
   ]
}

The client now receives the player and the item entities packages, deserializes them.
The problem is... that the deserialized entities now have different indexes than before. Because the index is not unique. So we CANT reconstruct the owning relation between the player and his items...

Any tips on how we could deal with this ?

karmic basin
#

Man, this entities relationship are driving you crazy 🙂 ou keep coming back every month for the same question 😉
I'd say don't use entity IDs from ECS, like you say they won't persist between sessions, worlds, runtimes, whatsoever. Do your own database UID and include it in the packets. Then rebuild your relations when you deserialize.

#

I feel you think about it too much as an OOP relations thing. There might be a better approach the ECS way. But easier said than done without behind part of the profject :p

toxic crest
#

personal opinion maybe but json is like the worst possible way to serialize game data with exception to xml from a performance standpoint

stone osprey
karmic basin
#

True, but it's great to prototype 🙂

stone osprey
#

Lets say we receive this Inventory{ uniqueIds:[1293994,12314885,959492] } the deserialisation to something like this Inventory{ List<long> uniqueIds } would be no problem at all. But we need Inventory{ List<Entity> items } instead.

So i assume that we need to "receive" the player with his inventory and the item entities at the same time... then we first construct the childs / the item entities before constructing the parent ? Otherwhise we cant reconstruct the relation or am i wrong ?

karmic basin
#

Not sure I would even build the relationship. I'd maybe try to work my way through queries. But maybe I'm wrong you went further than me on the inventory part

#

Inventory{ List<long> uniqueIds } would be no problem at all. But we need Inventory{ List<Entity> items } instead.
so you need some kind of GetEntityFromID() helper then ?

stone osprey
# karmic basin > Inventory{ List<long> uniqueIds } would be no problem at all. But we need Inve...

Yes and no... but damn its hard to describe for my limited knowledge.

What i mean is... when the player json is deserialized before the items, our inventory will stay empty.
Because even a GetEntityFromId() cant return us a entity which does not exist yet... because the items were not deserialized yet.

It would work, when the items are getting deserialized before the player... BUT
When we theres a bi directional relation, it will break again... or am i wrong ?

karmic basin
#

I would deserialize into some kind of AddItemToInventory component (which contains inventory ID and Item ID or values) then have a system that grabs them all and do the mapping. If inventory doesn't exists, component is not processed, until

#

it does exists

#

or you create the inventory on the fly, dunno :p

stone osprey
#

Ah i see... so we actually deserialise the Inventory { uniqueIds : [10,20]} into a real struct AddItemToInventory{ List<long> ids }
And that component gets processed each frame to resolve the relation between the player and the item...

#

That actually sounds like a very good idea ^^ well its not the "easy" solution i hoped for... but i guess that would work.
Furthermore the same component could check if items were removed from the server and then delete the item entities on the client in the same step.

karmic basin
#
AddItemToInventory{ 
  Entity inventory; // or whatever you represent inventory with  
  long itemID; // if you deserialized also an Item{} component with values inside, otherwise all values are raw inside this component and you biuld the items later
}
#

BUt maybe that's not a good idea and creates too many sync points 🤷‍♂️

#

DIsclaimer I didnt build a complete ECS Inventory system yet, so maybe I'm hinting a bad way of doing it

#

Just hoping to give you ideas

stone osprey
viral comet
#

There is a buit in mechanism for this called entity remapping

#

There was an article about it

#

But it has some downsides

karmic basin
#

Surely you're talking about the one on gametorrahod ?

stone osprey
karmic basin
#

Unity uses one already. He explains how you could build your own but yeah maybe you could use the existing one.

#

At the end he also points at helper methods but I never used them so can't tell

karmic basin
#

then parsing the value to see if Version does match. Anyway maybe these utilities have all the functionnality you need

#

EntityRemapUtility

#

Never used them so again I'm not the best person to talk about it

toxic crest
#

Is it common to design some systems to interact directly with other systems or that considered a bad practice?

valid haven
#

anyone know why job safety warnings yell at me for this?

toxic crest
#

whats the definition of WorldIndexMap?

valid haven
#
public NativeArray<WorldTransform> Transforms;
public TransformAccessArray Transforms;
public NativeArray<int> WorldIndexMap;

var t = entity.PhantomProxy.State;

entity.PhantomIndex = t.Transforms.length;
t.Transforms.Add(entity.PhantomProxy.PhantomObject.transform);
t.TransformMap[entity.PhantomIndex] = entity;
t.WorldIndexMap.Add(entity.Space.WorldIndex);
karmic basin
toxic crest
valid haven
#

basically I needed a fast way to keep a relationship between TransformAccess index and a MUCH large collection of worldtranforms, without doing a bunch of copying/rebuilding on every change.

karmic basin
#

Oh nice I didnt try DOTSNET yet. Good to know.

toxic crest
#

It's pricey but I think its a good investment right now

karmic basin
#

I agree. Now just need to find a way to buy life Time.

toxic crest
#

lol

digital kestrel
#

how come when my system stores a copy of an Entity (prefab) I can't instantiate it. Instead I spawn a bunch of gameobject references in my subscene

#

but if I store the prefab entity in a component, i can actually spawn the entity that i want

#

weird af yo

remote crater
#

Quick Question: I have an entity reference in a mono behavior. I want to change it's mesh filter. For a gameobject the code is: go.GetComponent<MeshFilter>().mesh = meshInstance; What is this when I have an Entity and an EntityManager?

#

In other news, I want to launch my moba in 2-3 days. 🙂

#

This may be my next to last question before I ask how to compile standalone and get DOTS working.

#

Then I'll have a MMORPG out 4-7 days after MOBA. Exciting times!

#

The conversion system converts MeshRenderer and MeshFilter components into a DOTS RenderMesh component on the entity. Depending on the render pipeline your Project uses, the conversion system might also add other rendering-related components.

#

So maybe there is no way to edit a Meshfilter on the fly on a DOTS ENTITY?

zenith wyvern
#
var renderMesh = em.GetSharedComponentData<RenderMesh>(entity);
renderMesh.mesh = someMesh;
em.SetSharedComponentData(entity, renderMesh);
#

There's no MeshFilter for an entity, that's a gameobject component. The rendermesh is what holds the mesh

remote crater
#

WOW!

#

That looks easy!

#

Tron was my favorite movie growing up. No one was as into video games when I was a kid.

#

Sark is a good name.

remote crater
#

Sark, this is what you wrought: https://youtu.be/ITQgKjUqwKM

Keep watching my videos: www.youtube.com/c/goodnewsjim

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a spam email,...

▶ Play video
#

Instead of a boring drone, we have all sorts of random ships from my game.

unreal wraith
#

can you use classes with jobs?

unreal wraith
#

you know how there is a meshData array
well is there also a meshdataList?

half jay
#

Does Render System has frustum culling by default or i should realise it myself?

sacred lark
#

i'm a beginner and i wanna make a simple mobile game, i'm considering using dots but idunno if it has all the features i need..

#

some things i want is idk.. tilesets, sprites, collision detection, swipe gestures, physics.. very basic stuff

#

how about using hybrid, and i do stuff like pathfinding with dots, but i also can use monobehavior stuff like TouchPhase?

dense crypt
karmic depot
#

Is the command stream in NetCode reliable? I know that it sends current input and also 3 previous inputs, but does this mean every input sent will be processed server-side eventually?

naive ice
naive ice
naive ice
# sacred lark how about using hybrid, and i do stuff like pathfinding with dots, but i also ca...

You certainly can. For one-off things like pathfinding I would suggest starting with Jobs and Burst, which may give you all the extra performance you need.
As for using DOTS in general, it depends upon your use case. If you intend on making performance a defining feature of your game, and cannot achieve the performance target you need with traditional technology, then it may be a good candidate for you - but it is going to be significantly more challenging.

#

You can eventually make everything you need with DOTS as it is now, but much of that will be implemented by you. All of the features you mentioned are technically possible but there is not much out of the box or hand holding - even getting a 2D tileset renderer will be a pretty manual experience.

sacred lark
#

Okay, I will definitely not make it a pure DOTS project, and instead use it where the performance can be optimized. I'm new to Unity in general, and I've never done multithreaded applications.

Another more specific question: if I create a job running the pathfinding code on a different thread, but there's a part of my code which is dependent on the algorithm finishing, then would I make a second job which is dependent on the first one?

zenith wyvern
#

If your second job depends on something from your first job then you don't have a choice - the safety system will force you to either manually complete the first job before starting the second one, or include the first job as a dependency

#

If you're using ECS you can try to build your jobs around entities and components instead, rather than manually managing jobs. Then you can let unity worry about dependencies, makes life a lot easier

naive ice
#

In that specific example I would probably have the thread keep a reference to the JobHandle and check .IsComplete() until it returns true... ECS or not, you will likely need to do some extra legwork to handle cases like this yourself anyway, as the built-in job dependency system works better for very short-running, intra-frame Jobs, not long-running, multi-frame Jobs like pathfinding

sacred lark
#

oh okay, so i only need one job which is responsible for the pathfinding, then i can run .IsComplete() on it from the main thread, right?

naive ice
acoustic spire
zenith wyvern
#

Kind of a bummer to see that

acoustic spire
#

Yeah. Its like to patent a hashmap.

#

Idk, this feels weird. Thousands devs work on dozens open source ecs frameworks. That would be a disaster

zenith wyvern
#

It does seem pretty specific, referring to gameobjects and value types, so maybe it's fine, who knows. But my knee-jerk reaction is that it's extremely messed up to try to patent the concept of an ecs

#

Although I guess I shouldn't say "tried". That's literally what they did

safe lintel
#

hopefully it falls under a benevolent use where its to protect their own stuff but also keep it open for others and free from patent trolls?

stiff skiff
#

I doubt it matters, there should be more then enough prior art to challenge this

zenith wyvern
#

I wouldn't count on a corporation to be "benevolent", and they have a pretty crappy track record lately when it comes to their decisions as a company. And even if it does fail, it matters to me that devs in the company are behind it, knowing how it might be used by their company.

wooden canopy
#

Unity is just doing what they can to help abolish software patents, by showing how they can be abused

#

its heroic

pliant pike
#

Yeah it's not great, software patents are trash

#

One plus side though, it means Unity are definitely committed to DOTS

karmic basin
#

Nope, you can pull a patent to protect from others and still not do anything with it ;)

#

My pessimistic side kickin in :)

#

Happens sometimes in video games industry

pliant pike
valid haven
#

These native collections really confuse me when it comes to how/when the nativecollection and its content gets copied in memory. I assume that if I assign a nativecolletion to a field that I am not copying the entire content just to do so, that just the PTR of the collection is used?

#

Also it seems like this model encourages using large structs, which normally is discourged. I find myself doing stuff like this, but even here it seems like I should be splitting these structs up to avoid wasting memory copys?

#
public WorldTransform(in WorldTransform worldTransform, bool markDirty)
{
    Position = worldTransform.Position;
    Velocity = worldTransform.Velocity;
    Direction = worldTransform.Direction;
    LastPosition = worldTransform.LastPosition;
    LocalPosition = worldTransform.LocalPosition;
    Rotation = worldTransform.Rotation;
    Matrix = worldTransform.Matrix;
    PhysicsAabb = worldTransform.PhysicsAabb;
    Scale = worldTransform.Scale;
    LastSector = worldTransform.LastSector;
    Sector = worldTransform.Sector;
    Speed = worldTransform.Speed;
    EntityId = worldTransform.EntityId;
    Dirty = markDirty;
    IsStatic = worldTransform.IsStatic;
    SectorCollision = worldTransform.SectorCollision;
}
#

also running into issues where the nativecollections seem to be quite a bit slower outside of a jobs vs their counter parts, simple things like this is more expensive than I am used too. WHich you start noticing it when u are doing this thousands of times a frame 😉

#
public static void RemovePhantomState(BaseEntity entity)
{
    entity.Transforms.RemoveAtSwapBack(entity.PhantomIndex);
    entity.WorldIndexMap.RemoveAtSwapBack(entity.PhantomIndex);
}```
worldly pulsar
sacred lark
#

so i was thinking about use-cases for using the job system, and i wonder if i could use it for loading in a level with a bunch of data used to spawn gameobjects?

stiff skiff
vagrant surge
#

around 2018 unity has patented a lot of random things that have prior art for days

#

they went into a huge rampage around patenting game engine tech

half jay
#

Is it possible convert GameObject to entity at runtime? I have trilib library which download meshes from storage and then convert it to GameObject and then this created GO should convert to entity. I use something like this

public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
    for (var i = 0; i < _gameObjects.Count; i++)
    {
          
          var prefabEntity = conversionSystem.GetPrimaryEntity(_gameObjects[i].GameObject);
                
     }
     dstManager.DestroyEntity(entity);
}

and prefabEntity always Null

sand prawn
safe lintel
#

@zenith wyvern the way ea opened up its accessibility patents gives me a glimmer of hope if these patents stand up to dispute, that unity doesnt abuse them

#

@half jay afaik the conversion system should run during runtime, its just not intended to and as a result might have performance hiccups. though long term Im not sure if you should rely on it. alternatively it wouldnt be too hard to just write your own custom conversion stuff

shy pilot
#

Hi guys, been off the unity scene for a while, would anyone mind filling me in on what the current state of dots is? I was just looking on the roadmap and can't find any obvious mention of it

craggy orbit
#

nothing different from last time (probably. depends on how long you've been out of the scene). DOTS is currently incompatible with anything past 2020.3.x and will stay that way until, at earliest, late this year

#

we have no news on when other than that

pulsar jay
#

Could anybody tell me why delta time in a fixed step system defers from fixed delta?
"FixedStep: Elapsed: 0 Delta: 0.01666667 Fixed Delta: 0.02"

#

Why is the system updated 60 times /s and not 50 times as set by the fixed delta?

gleaming plank
#

The system *is* updating at the rate set by the fixed delta. The time between steps is variable, though.

coarse turtle
coarse turtle
river kayak
#

I'm reading about the archetypes in ecs and just trying to see if I understand it https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_components.html
Let's say I have active 3 archetypes and its components: ArchetypeA (Position, Q, R), ArchetypeB (Position, W), ArchetypeC (X, Y). For whatever reason, I want to iterate over all entities which have a Position. So unity will go, ok, entities with Archetypes A and B fit the bill, so it will iterate over all chunks of Archetypes A and B.
While iterating, does unity load into memory all components of Archetypes A and B, or is it somehow able to filter only the Position component of these archetypes?
In other words, if I have a huge Archetype (A,B,C,D,E,F,G,H) and I only need Component A, can Unity only load the A, or does it load the entire archetype?

gleaming plank
#
a fixed timestep
- runs N steps per second
- each step *represents* a fixed amount of time passing
- actual time between steps varies

a repeating timer
- runs steps with at least N seconds in between
- actual steps per second varies
hollow sorrel
coarse turtle
gleaming plank
#

sure, I'm just saying that the timestep is working like it's supposed to

#

idk for sure, but I think @pulsar jay was measuring the time between simulation steps and asking why it didn't match the fixed delta, not that Time.deltaTime != Time.fixedDeltaTime inside the group

river kayak
pulsar jay
#

I also found in the bootstrap code that it is manually set to 1/60

gleaming plank
#

oh, gotcha

pulsar jay
#

Its weird though that Time.fixedDelta is 0.02 -> 50hz

gleaming plank
#

like why 50Hz?

pulsar jay
#

it seems like the FixedStepGroup is using delta time instead of fixeddelta

gleaming plank
#

looks like you need to set a timestep property

pulsar jay
#

"The value of Time.ElapsedTime and Time.DeltaTime will be temporarily overriden"

#

Thats what irritated me. It does not override and use fixeddelta

gleaming plank
#

yeah, and then MaximumDeltaTime will cap the number of steps that can be done in one frame

pulsar jay
#

I am generally a bit confused about where to put my gameplay systems. I feel they should run in fixed update. But communication between Fixed update and Update loop gets kind of tricky

gleaming plank
#

Personally, I think best practice is putting them in the fixed update, for consistent performance and behavior (since floating-point math is non-associative). You'll need to interpolate transforms for rendering, which would involve caching the previous step's values.

#

Updating every frame is mainly for UI and rendering. You can read gameplay data just fine, but I wouldn't write any game state in those systems.

#

So when you have Update -> FixedUpdate interaction, you prob have to spawn a thing that can be read by the fixed update systems. It is a bit tricky, yeah.

pulsar jay
#

Yeah I currently ran into the problem of syncing tag components. Because if I create and destroy them in update they may live through mutliple fixed updates and vice versa

pulsar jay
coarse turtle
#

cause you can grab all the systems and stick them into FixedStepSimulationSystemGroup

pulsar jay
#

maybe it would be easier to just add it to the default code template 🤔

coarse turtle
#

Yea sounds easier too lol

pulsar jay
karmic depot
#

Does EntityManager.SetName() work for you guys? It never works for me, in both Entities and Entity Debugger windows entities still show up with the default Entity {index}:{version} name

pulsar jay
#

On entities 0.17.0-preview.42 with Unity 2020.3.17f1

karmic depot
#

weird. but thanks

pulsar jay
karmic depot
#

fixed it lol, was using wrong World in 1 case and wrong entity in another

hot basin
#

is there a easy way to use SharedComponentData in burstable job? I mean without using EntityManager.GetAllUniqueSharedComponentData()

#

it has only a Blob reference

#

maybe I should just make singleton entity with it?

robust scaffold
#

Please don't tell me unity is spending their time patent trolling and patenting their ECS system.

glacial bolt
#

@robust scaffold This is a community server, don't post off-topic. If you want to contact Unity use forums... or twitter.

cerulean pulsar
#

Is it possible to append to a dynamic buffer via an entity command buffer? i.e. Defer appending to a dynamic buffer

valid haven
#

Has anyone ran into this problem before. Where you need a HashMap Enumerator (SectorState) from a dependent scheduled job and the safety system complains at you saying you must complete it before calling it? I have done fairly extensive testing with safety checks disabled and have not seen any indication of an issue.

#
var newSectors = new NewSectors(SectorState, AddSectors, AddedSectorCnt, Structure.Gate.Systems.FreshTick.RunTime.PlayerEntity.Sector.Position, Structure.Tick).Schedule();
var expiredSectors = new ExpiredSectors(SectorState.GetEnumerator(), RemoveSectors, RemovedSectorCnt, Structure.Tick).Schedule(newSectors);
_batchJob = new RemoveSectors(SectorState, RemoveSectors, RemovedSectorCnt).Schedule(expiredSectors);```
cerulean pulsar
cerulean pulsar
cerulean pulsar
cerulean pulsar
sudden edge
#

question: not really a dots question but burst

#

simply importing the burst compiler into your project doesn't do anything, right? not unless you're using jobs, and then flag them to be compiled with burst

cerulean pulsar
pulsar jay
#

Why? How am I supposed to have multiple tigger colliders on one object?

pulsar jay
#

Thats weird. This warning seems to be a lie as the entity is clearly not getting unparented from its parent 🤔

scenic oak
#

perhaps it means un-parented during the conversion, but re-parented after the conversion. definitely confusing if true

karmic basin
#

Yeah dots physics unparent dynamic bodies. Probs an optimizaion concern. This way they can compute everything in worldspace I guess, and don't have to follow the ltw chain ?

safe lintel
#

they def dont get reparented 🙂

#

anyone following some of the graphics repo optimizations? kind of implementing a pseudo ecs within the renderpipeline to burst optimize stuff, but separate from the entities package. kind of odd in a sense, doing side by side ecs stuff? my long term outlook on entities is getting weird

half jay
#

i have this system which changing material setup and i have problem that in scene it doesn't rerender until i just select material instance from entity. How can i force rerender this changes ?

private float _transparentValue = 0.75f;
protected override void OnUpdate()
{
        Entities
        .WithStructuralChanges()
        .ForEach((Entity e, in BlockComponent block, in UpdateBlockGhostComponent ghost) =>
         {
             if (block.RenderEntity == Entity.Null) return;

             var renderMesh = EntityManager.GetSharedComponentData<RenderMesh>(block.RenderEntity);
             var newMat = new Material(renderMesh.material);

             var baseColor = newMat.color;
             baseColor.a = ghost.IsGhost ? _transparentValue:1.0f;
             newMat.SetFloat("_Surface",(float)SurfaceType.Transparent);
             newMat.SetFloat("_Blend", (float)BlendMode.Alpha);
             newMat.SetColor("_BaseColor", baseColor);

             renderMesh.material = newMat;
             EntityManager.SetSharedComponentData(block.RenderEntity,renderMesh);
                    
             EntityManager.RemoveComponent<UpdateBlockGhostComponent>(e);

          }).Run();
}
pulsar jay
karmic depot
#

Should I be caching EntityQueries in system's fields, or does GetEntityQuery() cache them well-enough?

cerulean pulsar
karmic depot
rugged grove
#

wait.. how do you write into dynamic buffers? buffer[index] = value; isn't working because "return of buffer[index] is not a variable"

coarse turtle
hot basin
#

is FixedListXXX<T> better than DynamicBuffer?

safe lintel
#

different uses

#

dynamic buffers work in entityqueries like components whereas you cant query for a fixedlist, but then you can stuff fixedlists inside of buffers or have multiple in a component

remote crater
#

I have a var vvv4= GameBoardModel.entityManager.GetComponentData<Disabled>(e2);

#

How do I remove that component data vvv4 aka disabled from entity e2?

#

GameBoardModel.entityManager.RemoveComponent<Disabled>(e2); is the answer I think

rugged grove
#

Cannot modify the return value of 'TileReader.TileBuffer' because it is not a variable [Assembly-CSharp]

zenith wyvern
#

You can't use the square bracket operator on a property. Assign the tilebuffer to a local variable first and use that instead.

rugged grove
#

ok, thanks. interesting....

lusty otter
#

How costly is using a struct larger than 4 bytes as function return, in a Burst compiled function?

digital kestrel
#

does anyone have notes or resources on the overall architecture of Unity.Animations / Unity.DataFlowGraph packages ? Kinda getting lost lol 😅

safe lintel
#

Check out the package manager to install the dataflowgraph samples

#

Its really key to understanding how to make nodes and connect them for animation

#

But all in all with animation finite state machines arent yet done nor are animation events so its really difficult to do basic stuff and to do any sort of timing

#

Imo not worth bothering though given a visual ui that sortof exists now, will replace most coding.

#

I assume whatever release of dots that comes next will have really significant ease of use improvments for animation though i guess we could be waiting forever for it.

devout prairie
#

Anybody have this problem where VS randomly doesn't recognize namespaces in your project, normally asdef namespaces

#

It's just suddenly greyed out, type or namespace isn't recognized, but the assembly is still part of the projects Refs

#

Okay here's an ECS question:
Would it be bad practice, to have an IComponentData which has a field which references another IComponentData on say a different entity?

#

It seems that would kinda defeat the whole cache friendly data oriented idea right..

#

so for example in an Entity.ForEach you could have something like:

.ForEach(( ref HelperComponent helperComponent) =>
{
  int someValue = helperComponent.otherComponent.someValue
...
}).Schedule();
zenith wyvern
#

That won't work because components are value types

#

You always reference a component through it's entity

#

So to reference a component you store the entity it lives on, and get the component through the entity reference when needed

devout prairie
#

ahhhh... thanks!

#

Essentially i'm trying to get a value from a component on the entities parent..

#

I take it using Entity.ForEach would only poll for components on the object specifically, it wouldn't be possible to reference child components also?

#

Literally just starting to try and get my head around this stuff.

zenith wyvern
#

By entities on the object do you mean components on the entity?

devout prairie
#

Ah yeah, sorry yep

zenith wyvern
#

If an entity has a child it will have a "Child" buffer. So you would have to access it's children through that buffer

devout prairie
#

i see..

#

is it possible to then grab a component from a child inside the ForEach?

#

i was looking at GetComponentFromEntity but it's not quite what i expected it to be

zenith wyvern
#

Sure it is. The syntax is going to be pretty arcane for someone new to dots though. It would be something like

Entities.ForEach(Entity e, in DynamicBuffer<Child> children) {
  for(int i = 1; i < children.Length; ++i) { // the first element always refers to the parent entity, so skip it
    var child = children[i].Value; // "child.Value" is the child entity
    if( HasComponent<Whatever>(child) ) {
      var comp = GetComponent<Whatever>(child);
    }
  }
}.Schedule();
#

Should be something like that

#

Been a while since I've actually written dots code but that's the gist of it I think

toxic crest
#

Are you able to have objects render from multiple entity worlds? I thought I had read something that said you could only render from a single world in the hybrid renderer v2 docs but I don't see that now

#

or some sort of limitation in regards to rendering multiple worlds

devout prairie
#

Would this be a reasonable approach, to reference a parent Entity via a Parent component:

    Entities
            .ForEach((
                Entity e,
                in MyCharacterTag characterTag,
                in Parent parent) =>
            {
                var someValue = GetComponent<SomeComponent>(parent.Value).SomeValue;
                ...
            }).Schedule();
zenith wyvern
#

I would say it's the approach

devout prairie
#

Great, thanks

#

More stupid questions.. Any idea if there's any difference between these two approaches:

    Entities
            .ForEach((
                in Entity e,
                ref MyCharacterTag characterTag,
                ref DynamicBuffer<MyBuffer> myBuffer) =>
            {
                ...
            }
    Entities
            .ForEach((
                in Entity e,
                ref MyCharacterTag characterTag) =>
            {
                DynamicBuffer<MyBuffer> myBuffer = GetBuffer<MyBuffer>(e);
                ...
            }
toxic crest
#

found it on the forums from Unity person but posted AUg 7th 2020:
Right now Hybrid Renderer V2 doesn't support multiple worlds.
Is that still the case with the most recent v2 renderer?

zenith wyvern
devout prairie
#

Okay - thanks!

zenith wyvern
#

Buffers can be allocated on the heap in some cases so it's not a guarantee. But yeah for performance reasons you should avoid GetComponent/GetBuffer when possible

#

It's much slower than just accessing directly from the foreach

devout prairie
#

Yeah that makes sense

#

Is it possible to view Unity.Physics collider debug stuff in the viewport?

zenith wyvern
#

If I remember right you just have to add a certain component to a gameobject (a normal unity component, not ecs component)

#

Physics debug display or something

#

And it's like a global thing that just makes all the physics debug stuff draw

devout prairie
#

Ah ok thanks

devout prairie
#

Does Unity.Physics have the same issue as standard unity physics where for example projectiles moving too quickly can pass through colliders without detecting collision - ie is it a good idea to implement a raycast system for fast moving physics bodies to check for collisions for example with bullets..

karmic depot
#

I'm using NetCode and I want to make sure all subscenes are loaded before sending GoInGameRequest, does this code make sense for that? I'm getting "Index 0 is out of range in DynamicBuffer of '0' Length." coming from GhostUpdateSystem for the first dozen ticks.

var scenes = GetEntityQuery(typeof(SceneReference), typeof(SubScene)).ToEntityArray(Allocator.Temp);
        for (int i = 0; i < scenes.Length; i++)
        {
            if (!_sceneSystem.IsSceneLoaded(scenes[i]))
                return;
        }
viral sonnet
#

hey, which was the last version that entities is working? Obviously 2020.3 as recommended, but I've also some running in 2021.1. Any info at which version it breaks?

toxic crest
#

2020.3.18f just came out I think today or yesterday maybe

#

if you're just starting, go with the most recent. Its all bleeding edge anyway lol

devout prairie
#

Are entity index's persistent or do they change when entities are added/removed?

toxic crest
#

Just looking for some feedback: Do most of you use the mono scripting backend during early development and switch to IL2CPP later on or do you just go IL2CPP right out of the gates (in relation to DOTS development only of course)?

deft stump
#

IL2CPP right out of the gates

cerulean pulsar
#

Does anyone know how to get a second light to work in URP? When I put my meshes in a subscene, only one light works on them. When I take the meshes out of the subscene and put them in the ordinary GameObject hierarchy, both lights work on them

remote crater
#

Is there a performance hit for thousands of disabled entities floating around, or does UNITY do it properly and have an array they're placed in and not processed unless re-enabled?

#

I'm just trying to wrap my head proper methodology for the software architecture of data structures in DOTS to object pool effectively.

#

Right now I spawn a disabled entity, then take away disabled tag.

#

So every single entity in my game is instantiated once at start or whenever time to load it comes along.

#

But if UNITY improperly coded their back end, which is possible, since tag based code normally involves an array of checks cycling... Maybe there is a better way to do this.

#

Good to bite these things in the bud right off the bat to have a solid foundation to grow from.

cerulean pulsar
# remote crater But if UNITY improperly coded their back end, which is possible, since tag based...

According to my understanding, entities with the Disabled component will be in a different chunk of memory than the ones without it, even with all other components being equal, since they have a different archetype. I'm guessing that the EntityQuery can ignore an entire chunk of irrelevant memory with one check, instead of checking each disabled entity. A friendly reminder that profiling is best way to go beyond the guesses of people like me

devout prairie
#

Seems to me that having these components over entities whole lifetime would make more sense, with just an enabled/disabled bool to switch on/off any processing (inside system logic or as suggested in the link built in to how ecs parses them).. not sure how much that branching would affect the burst optimization when compared to the overhead of constantly swapping archetypes

cerulean pulsar
# devout prairie Seems to me that having these components over entities whole lifetime would make...

Until they release that feature it seems like it comes down to using one's project details to navigate the trade-off and profiling to be sure. The archetype change could be worth avoiding the branching, and vise versa, depending on factors like how many entities, how often the change would need to happen, and whether you're using NetCode with client-side prediction. I default to branching now because NetCode client-side prediction can't rollback structural changes but can rollback a boolean

devout prairie
#

Yeah that makes sense.. i guess there's no better way to test than running it 10,1000,100000 times and comparing 🙂

devout prairie
twilit coral
#

I do not have Light probes in the scene nor do I wan't to use them, is there a way to get rid of LightProbeUpdateSystem then?

safe lintel
#

Use another system or monobehavior to just disable the lightprobesystem at the start

twilit coral
#

thanks, will try that

remote crater
#

I love having a solid foundation in my software architectures.

#

It means when you make behemoth projects with 100,000, or a million or more lines of code, things get easier not harder/impossible as you go along.

#

I'm actually really stoked! I want my MOBA out the door today or in the next 4 days, then a MMORPG out in 3-7 with frequent updates

#

Praise Jesus man, these are exciting times. Software engineering, game design in particular, frees the mind, and that is worth more than any amount of money.

remote crater
#

I was trying to use entity command buffer to spawn stuff and give components. I thought for sure it wouldn't work first try. I wanted to spawn just 1 unit in place... The ended up being a full wave of MOBA minions aka drones and they started going forward too! Wow! https://youtu.be/feaWx9D4mEs

Keep watching my videos: http://www.youtube.com/c/goodnewsjim

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/VGMCrazyJim The Bro Zone Layer. (temp)

The #1 video gamer who ever lived with proof! I just missed tourneys due to life problems(college for Starcraft thinking my email invite to Korea was a spam...

▶ Play video
gilded glacier
#

a general question

#

how do you guys solve when you have a long sequence of code or behaviour ?

#

putting it all in a single system seems like a huge messy blob

#

so I instead use several smaller systems (they are also parts of different assemblies, so having a single large system would break the entire code organization)

#

and I also have one additional system that creates "command" entities that trigger their respective systems

#

but I find it to be maybe a bit too complex solution (definitely more than composing methods), where I have to create, queue, and modify those entities

valid haven
#

I have two questions about IJobParallelForTransform. 1) If I need immediate results I assume I should go ahead and call .RunReadOnly() vs .Schedule then Complete, avoiding the overhead of task/thread scheduling. 2) If I use RunReadOnly() I assume the work is still parallelized, but just main thread blocking?

#

Its strange that I cannot specify a batch size if I use RunReadOnly. However, it also seems strange to do this: new UpdateWorldTransform(WorldTransforms).ScheduleReadOnly(PhysicsTransforms, batchSize).Complete()

full epoch
karmic basin
#

What is exactly DOTS 0.5 though ? Because DOTS is a collection of other libraries

#

@gilded glacier lot of small systems looks good to me. Nothing wrong in what you described

gilded glacier
#

maybe except the amount of entities

#

a great opportunity to make a mistake

#

but maybe even performance wise, it's beneficial, because the whole sequence is executed over several frames

devout prairie
#

so it's not possible to have an Entity field in a struct as 'null' because it is a non-nullable type is there a way around this?

#

Basically i'm trying to use a constructor inside my struct, which requires all fields to be initialized..

gilded glacier
#

try using Entity.Null as the substitute for null

devout prairie
#

thanks

shell berry
#

It's more clear, intention wise

cerulean pulsar
# gilded glacier how do you guys solve when you have a long sequence of code or behaviour ?

Can you elaborate on the word "long" here? In my experience there has been a natural separation of "tasks". Some tasks needed to happen in sequence. Others could happen in parallel. I lay out the data and schedule the C# jobs accordingly

Trying harder to understand what you're saying. I tend to keep systems pretty simple and don't tend to schedule more than one job in a single system. I guess my job logic can grow pretty large if I'm doing a lot with a single archetype

The most complicated system I've seen is for a character controller and all the logic was within a job. There were a lot of functions in the job but they were just for readability and code navigation

There could perhaps be a performance benefit for putting two jobs in the same system if they used the same system-stored entity query. Haven't profiled for that potential optimization yet

cerulean pulsar
# gilded glacier and I also have one additional system that creates "command" entities that trigg...

Maybe your project requires you to trigger systems via creating entities, but according to my understanding of default Unity ECS, your systems should react to the existence of entities-that-need-to-be-processed by scheduling jobs that process them. The systems discover these entities via entity queries, which can be ran implicitly via Entities.ForEach. The systems don't need explicitly created command / trigger entities to run, and creating these requires structural changes which can be expensive

devout prairie
stone osprey
#

Quick question... I need to return some sort of default/null reference... But theres no "Unsafe" class in my project ( The official one from net ).
Does UnsafeUtility from unity contains any method i could return a null "ref T" with ?

coarse turtle
stone osprey
coarse turtle
#

it might work...? Did you try putting in the DLL and using it?

stone osprey
gilded glacier
#

afaik, adding or removing components moves the entity to another chunk that matches the entity's new archetype

#

also, my case (may sound a bit extreme) has entities with buffers that require kBs of memory space, so I don't think it's a good solution to keep shuffling them over the entire memory

#

(as we got to this, I really wonder whether this is the "adding components" approach limit that should be concerned)

stone osprey
#

This is kinda dots... atleast unsafe...
I have a method like this...

        public ref T GetComponentData<T>() where T : struct{

            unsafe {
                
                for (var index = 0; index < components.Length; index++) {

                    var ptr = components[index];
                    var handle = (GCHandle) ptr;
                    var obj = handle.Target;

                    if (obj is T) 
                        return ref UnsafeUtility.AsRef<T>((void*) ptr); 
                }

                throw new Exception($"Theres no component of type {typeof(T)} attached");
            }
        }

When i use it, unity... just crashes. Any idea why or where i can find the reason for the crash ?

#

It actually crashes once the return value was passed.

ref var cmp = ref UnsafeUtility.AsRef<T>((void*) ptr);

This line causes it... any idea why ? Ptr is a real pointer to the generic... it should work...

coarse turtle
zenith wyvern
#

There would be no structural changes and the consuming system will only run when you push to the buffer

#

The downside being you have to be very careful about how you access your buffer - you can't just include it in a query as even if you don't write to it that's enough for ecs to detect it as being changed.

devout prairie
zenith wyvern
#

Yes

#

To prevent it you'd have to use GetBuffer behind some condition in your event raising system

devout prairie
#

I wonder the impact that embracing DOTS will have on for example medium sized game companies etc..

#

Where you have 99% of devs have trained and worked within the paradigm of OOP

#

Will you have like, these one or two wizards in the corner building these systems that nobody else understands

zenith wyvern
#

Considering how terrible unity has been about communicating what's happening with dots i would be pretty distressed if I worked at a company that went all in on it

devout prairie
#

Personally i think it's incredible i remember reading that document on DoD that was shared on the Unity blog and thinking, this makes TOTAL sense. But it's certainly a completely new way of approaching game dev especially i'd say for generalists and non-hardcore engineers

zenith wyvern
#

I definitely think ECS makes it a lot easier to write games, at least for me. Having messed with bevy for a while I can't say I'm a fan of how unity is doing it so far. They've completed failed at integrating it properly with their editor so you're left with all the restrictions of HPC# and you have to do so much extra work to make everything interface with existing unity stuff

#

Hopefully it will get better. Who knows since they aren't communicating at all. At least with hobbyists who are messing with dots

devout prairie
#

Interesting i hadn't looked at bevy or in fact rust at all..

zenith wyvern
#

I love it so far. I wouldn't recommend it for a serious project though, they don't even have an editor yet and Unity has so many advantages outside of DOTS that bevy isn't even close to having

devout prairie
#

I think stuff like, introducing burst and the jobs system at least opens up accessibility to performance and i guess with Unity having such a broad user base from hobbyists to full studios it makes sense to transition over time in a sortof modular way towards HPC and DoD technologies

zenith wyvern
#

Yeah it's definitely possible, a lot of people swear by just using plain old unity and leaning on jobs or ecs only where they need high performance

#

It would be nice if it was integrated nicely enough where you didn't have to pick and choose, I guess that's a ways off

devout prairie
#

OOP in my view has it's own problems, building anything with inheritance etc that is moderately complex can get very quickly out of hand.. so i guess it's swings and roundabouts in many ways

zenith wyvern
#

Well people have been successfully making games in oop, games that perform fantastically, for decades now. Clearly works for some people. Not for me though, hahah

devout prairie
#

Oh it works, without a doubt

#

I made a decision a while back to build my current project around managers which is kinda an interesting halfway approach

#

so rather than having classes and/or mono's holding data and methods i've created manager singletons effectively, that handle all of the instances of small data holders within the game

#

someone did a performance comparison at some point comparing this approach to the classic Unity approach of shoving all data and logic into mono's and it was pretty interesting, there's definitely benefits to it

#

Can't find the article 😐

stone osprey
#

Does dots work with net 4.0 ?

shell berry
cerulean pulsar
cerulean pulsar
cerulean pulsar
gilded glacier
#

why not have this enable flag in another entity that also has the reference to the processed entity ?

#

I may just be obsessed with performance, but when I compare it to the enabled-checking, it makes more sense to me

#

maybe even from the standpoint of database design, which I read is a great guideline for DOD

safe lintel
#

man over a year ago with that statement, not even sure if it was the first one they made on the enable/disable stuff.

devout prairie
#

quick question:
I have this bit of code, to gather basically all character entities before i run my Entities.ForEach:

            m_TranslationQuery = GetEntityQuery(ComponentType.ReadOnly<DotsAICharacterHelper>(), ComponentType.ReadOnly<Translation>());
            var unitPositions = m_TranslationQuery.ToComponentDataArrayAsync<Translation>(Allocator.TempJob, out JobHandle j1);

The problem is when i run my ForEach as a ScheduleParallel, it's splitting the unitPositions array up among the parallel threads..

earnest hill
#

Anyone know if there there a built-in replacement for Quaternion.ToAngleAxis in the Unity Mathematics package that I am missing somewhere?

devout prairie
#

so inside my foreach, when i do unitPositions[i] i'm getting:

#

am i going about this totally the wrong way?

#

basically i'm using ForEach to iterate my character entities, and inside i'm iterating the unitPositions array to get the closest entity

zenith wyvern
#

Like the error says if you're accessing a native container inside a parallel job as read/write you're restricted to accessing only the index given to you by the job

#

Unless you disable the safety system

#

Or maybe its WithReadOnly

karmic depot
earnest hill
#

Bummer. Sounds like I am writing my own then. Thanks!

karmic depot
earnest hill
karmic depot
devout prairie
#

Hmm not quite..
Abbreviated version of my code is this:


m_TranslationQuery = GetEntityQuery(ComponentType.ReadOnly<DotsAICharacterHelper>(), ComponentType.ReadOnly<Translation>());
var unitPositions = m_TranslationQuery.ToComponentDataArrayAsync<Translation>(Allocator.TempJob, out JobHandle j1);
j1.Complete();

Dependency = Entities.ForEach((ref DotsAICharacterHelper dotsUnit, in Translation t) =>
{
    for (int i = 0; i < unitPositions.Length; i++)
    {
        float distSq = math.lengthsq(unitPositions[i].Value - t.Value);
    }
}).ScheduleParallel(Dependency);
Dependency.Complete();
#

so i kinda figured that, because unitPositions is obtained outwith the Parallel job, that it wouldn't be split up..

#

makes sense that it would split up the results of the Entities.ForEach query obviously, but i didn't think it'd split the unitPositions array

zenith wyvern
#

Not sure what you mean, you changed it to Entities.WithReadOnly(unitPositions).ForEach(...etc and it still gave you the same error?

#

There's no splitting up involved. The threads are all reading from the same shared memory

#

The safety system just needs to know it's safe (IE Readonly) to be reading from the same index as other threads

devout prairie
#

Yeah what i mean is, the indexing of unitPositions is being split up among the threads/jobs.. i do understand it restricts access to the actual components passed to threads/jobs from the ForEach itself

#

Same error with Entities.WithReadOnly(unitPositions) though yeah

#

i'm not writing to unitPositions but i need to iterate the whole unitPositions array

devout prairie
#

Okay next question:

Muchly abbreviated code as follows.. basically it's not updating the pathRequestBuffer.. No errors or anything, the buffer is successfully being passed in but the buffer itself is not showing new elements in the Entities inspector..

var pathRequestEntity = GetSingletonEntity<PathRequestEntityComponent>();
var pathRequestBuffer = GetBufferFromEntity<PathData_PathRequests>(false)[pathRequestEntity];

Entities.ForEach((Entity e, in Translation t) =>
{
    InitGoto(ref pathRequestBuffer, t.Value);
}).Run();

public static void InitGoto(ref DynamicBuffer<PathData_PathRequests> pathRequestBuffer, float3 thisPos)
{
    pathRequestBuffer.Add(new PathData_PathRequests());
    Debug.Log("BUFFER COUNT = " + pathRequestBuffer.Length);
}
#

i assume that GetBufferFromEntity is returning a copy of the buffer rather than the buffer itself, so i'm writing to the copy

#

would i need an ECB to additionally write to the actual buffer?

devout prairie
#

So using EntityManager.GetBuffer worked rather than GetBufferFromEntity.. ECS docs are a little unclear about the differences there.

#

Ah wait no.. Problem seems to have been passing it as a ref into the static method.. not doing that updated the source buffer as expected. Sorry for flooding the chat! Hopefully it's useful to someone.

cerulean pulsar
gilded glacier
#

I don't know

#

I've been trying to look up something more about this, and only found that the entity referring is a possibility and a solution to some problems

#

I am aware that it's not very performance friendly, but I didn't manage to find how bad it is

#

I only know that tags and archetype changes are the overall good elegant solution, but with my super-sized buffers, it would be way too much data to transfer for it to be acceptable in this case (and that's why I'm asking for opinions on this)

light mason
#

I’ve got a question I was hoping someone could answer for me

#

If I translate an entity cube outside of the camera view does it save me gpu time

#

In hybrid renderer

#

Im not seeing a significant difference

cerulean pulsar
rugged grove
#

have anyone benchmarked struct systems vs class systems?

devout prairie
#

Are Entity.Null checks a bad idea in the same way that OOP null checks are bad/slow?

#

For example if (myComponent.targetEntity == Entity.Null)

amber flicker
devout prairie
#

if a component has a reference to an entity - for example myComponent.targetEntity but the target Entity has been destroyed - will the targetEntity reference still exist?

#

i'd assume as it is a value type it's a copy of the Entity and so would still exist..

amber flicker
#

Correct 👍

devout prairie
#

How do i check for the existence of an Entity?

#

Say i'm in an Entites.ForEach with Friendly units and i'm checking if an Enemy entity exists

#

I've tried like this:

EnemyQuery = GetEntityQuery(ComponentType.ReadOnly<EnemyUnit>());
var enemyEntities = EnemyQuery.ToEntityArray(Allocator.TempJob);

But this just returns an array i'd have to iterate through it to check, wondering if there's a simpler way

amber flicker
#

It's been a while but I think within a lambda you can use the presence of some component e.g. HasComponent<SomeICD>(enemyEntity) - it is rand access but then if you're using references of other entities it will be anyway

devout prairie
#

Ah okay that's interesting, thanks again!

amber flicker
# devout prairie I've tried like this: ``` EnemyQuery = GetEntityQuery(ComponentType.ReadOnly<Ene...

Np. Other thing to mention is because destroying entities is main thread, a query should never return entities that don't exist. Like you say, references to other entities might though. Good ways to deal with this are quite use-case specific. In general I prefer destroying entities as one of the last systems that runs. It's also a common pattern to have an intermediary bool that e.g. an enemy is to be destroyed (because it can be done with burst in parallel), then actually destroyed at the end of the frame at a sync point.

devout prairie
cerulean pulsar
devout prairie
left oak
#

You could consider keeping a component/buffer on each entity that's like TargetedBy, which holds all entities targeting this entity, and just iterate through those setting their target to Entity.Null when this entity is slated for deletion. That way you just need to compare to Entity.Null. I.e., any target entity that is not Entity.Null is a valid entity, and doesn't require a further check.

cerulean pulsar
# devout prairie `you could instead at that time just replace the entity reference with Entity.Nu...

I mean that in your TargetData struct I assume there is an Entity field. In some system I assume you plan to set that field to some Entity. Once that entity is destroyed you plan to set a boolean in TargetData that says it's destroyed, but you can instead re-use the no-longer-used Entity field to store that information, by setting it to Entity.Null and checking for that instead of checking the boolean

I still think it would be easier to check the validity of the Entity reference just-in-time with HasComponent

cerulean pulsar
# cerulean pulsar I mean that in your TargetData struct I assume there is an Entity field. In some...

instead of if (targetEntityIsDestroyed) targetData.IsTargetDestroyed = true it would be if (targetEntityIsDestroyed) targetData.Entity = Entity.Null and then you'd check later targetData.Entity != Entity.Null instead of !targetData.IsTargetDestroyed

And further I suggest HasComponent<SomeComponentATargetWouldHave>(targetData.Entity) instead of either, that way you won't have to do an extra TargetData cleaning job

devout prairie
cerulean pulsar
devout prairie
#

Hehe yeah it's exciting and fun..

gilded glacier
devout prairie
#

So with physics queries in DOTS/ECS, raycasts for example, is it best to queue those up and push them through a dedicated system and wait for results or is it common practice to just do raycasts 'on the fly' during Entities.ForEach loops?

gilded glacier
#

I wrote two systems - the first one was looping though entities that had components referring to entities from different chunk and changing their data, and the second one was directly looping through the entities, changing data, and adding/removing a tag component periodically

#

I was even changing the size of the buffer for the entities, but the result was always the same - the tag component adding/removing was faster than the controller entity

amber flicker
amber flicker
devout prairie
gilded glacier
amber flicker
amber flicker
# gilded glacier I did 100 iterations over both systems, so even in extreme cases, structural cha...

Structural changes can be really slow - 100 iterations over how many entities changing things how often? Check here for some benchmarks done previously (that are probably still quite accurate) https://forum.unity.com/threads/benchmarking-tag-component-v2.796470/ - in the case of 10k entities and only needing to change 80% that benchmark reckons it's ~80 microseconds to set and check a bool, about 7000 microseconds to change the tag

gilded glacier
#

I was changing 100% entities every iteration, and the structural change was always faster than using the entity reference

amber flicker
gilded glacier
#

if the buffer isn't stored in the entity, but rather in managed memory, then it would make sense that structural change is faster

#

yes, those

#

but if the buffer is always stored in managed memory, then the documentation is incorrect by saying it only moves the buffer there when the capacity is reached

amber flicker
#

I'm logging off now so only chance for brief reply. I might not have understood what you're comparing. DynamicBuffers have linear access provided they can fit in a chunk. E.g. if you had a buffer with a capacity of 100 and each entry was ~200 bytes then each entity would be ~20kb and with a chunk of 64, maybe you'd fit 3 entities in it. If not even one entity would fit in the chunk, the buffer would become managed. If you have a sensibly low capacity (<10) I doubt your buffers are managed - you should get linear mem access.

gilded glacier
#

yes, but I don't have any other explanation why adding/removing a tag component is faster than referring an entity

#

I initially thought that referring an entity is much faster than adding a tag to it when it has a buffer of kbs of data

#

but I found out it's not correct, and the only explanation I have is that the buffer is in the managed memory, and only the entity overhead and some other components are moved between chunks

devout prairie
# gilded glacier but I found out it's not correct, and the only explanation I have is that the bu...

you would think that when a bunch of entities are changed ie component/tags added or removed that because this is a structural change and they are i think moved/regrouped into different chunks of the same archetype that it could potentially take longer.. it would be interesting to hear what the technicalities of this are and why it's faster, as you say even when there are several kb's in the buffers, than just doing non-contiguous random access to entities

gilded glacier
#

probably it's because the changed entities are in the cache, and after the iteration, they're moved into the original chunk or the new chunk (which makes no difference, since it's both just writing in the memory ... I guess ...)

#

accessing a random entity via the entity struct causes cache misses, and maybe that's why it's so much slower, because the processor needs to read from multiple different addresses that may be outside the cached data

devout prairie
cerulean pulsar
cerulean pulsar
gilded glacier
#

I don't think I need to test it myself, and I don't even want to, because just setting up an (almost) blank ecs project was painful enough

#

I wasn't considering this solution at all, because when there is any ecs tutorial or article, it always says "tags over bools"

devout prairie
#

How would i get a reference to a child object in an entity hierarchy?

#

like say i had a prefab that had a child called "ChestTarget", and this was converted to ECS, then i create an Instance of the ECS entity

cerulean pulsar
devout prairie
#

Yeah i see that..

cerulean pulsar
#

Oh, then you're farther than me in the thought process

devout prairie
#

Because the entities don't have names i'm wondering how would i identify the entity i'm looking for

cerulean pulsar
devout prairie
#

Yeah i think i'll have to do it when i Instantiate() the prefabs entity, just not sure exactly how

#

Maybe some way to inject a component during a Convert() method on the prefab or something

#

so while it's actually converting to ECS i catch the ChestTarget object and give it a component, or something

#

think i'm going to have to deep search google on this one hehe

karmic basin
#

So you can query it

zenith wyvern
#

Or just add the chesttarget entity as a reference in the root or wherever else you need it

amber flicker
#

If you're converting it you can also have a component that just references the child GameObject - it will be converted to an entity reference

devout prairie
#

Thanks for the ideas I think that should help..

karmic depot
#

Can I use a single EntityQuery instance to query multiple worlds, or do I need a separate EntityQuery per world? This is for querying from MonoBehaviour

coarse turtle
forest quest
devout prairie
forest quest
#

I only know about it because I've been reading through the code to understand the inner workings of the hybrid stuff

stone osprey
#

Im using the UnsafeHashMap quite often with structs in it...
Is there any way to get a ref to one of its elements ?

remote crater
#

I have a question: How do I scale an object and still give it a physics shape? Is it possible to just take a game object scaled, and somehow turn it into a new game object where scale is 1,1,1?

#

That is two separate questions.

#

The first means scaling in inspector.