#archived-dots

1 messages · Page 125 of 1

sour ravine
#

it's a reference type

#

Burst will kill it if you try

raven grail
#

What I mean is e.g. EntityManager GetAllUniqueSharedComponentData, according to the documentation it returns a collection of copies of shared components

sour ravine
#

Sure, but at that point you can just do the Entity trick I mentioned.

#

make the "shared" data be a normal IComponentData that lives on that Entity

raven grail
#

That'd require additional overhead of creating a dummy component just to hold a copy of that data + a system to populate it though, wouldn't it?

#

Seems to me like it'd be a lot more actual code to write

sour ravine
#

How many SharedComponentData would you need to deal with. Plus there's nothing preventing you from creating an entity like that in the same system

raven grail
#

Yeah but it's still boilerplate regardless what file it's in. And potentially a lot

sour ravine
#

I'm probably not articulating the mechanics of the secondary entity approach, then

#

it's pretty traditional as Entity creation goes

raven grail
#

Yeah I'm a bit fuzzy tbh. Can you give me a pseudo-code example or something?

sour ravine
#

struct BoundingBoxGroup : IComponentData { public Entity parent; } replaces the shared component

#

then there's something like struct GroupBoundingBox : IComponentData { public float3 mins; public float3 maxes }

#

you create one Entity via normal CreateEntity() and remember it

#

and add the BoundingBoxGroup component to Entities you want to group results for

#

likewise the GroupBoundingBox ends up on the loner entity

raven grail
#

Yeah, that's what I figured

#

Still seems like it'd be a lot more overall code plus the overhead from creating entities, adding components, etc. than just an array lookup though

sour ravine
#

if you're repeating it at every loop iteration

#

but this gets into another point about certain kinds of duplication being good

#

see locality of reference, etc.

#

it's pretty similar on the back end to what the SharedComponentData would hypothetically do anyways-- the EntityManager indirection itself is mainly to get around the reference types

#

the way DOTS is built that has to happen even if they had a special happy path where you could just send your shared component in as an argument

raven grail
#

Hhm, I'll look into it then. Thanks for the help

sour ravine
#

it might seem like a strange suggestion but I would also suggest a basic overview of MapReduce

#

since it's a parallel reduction problem

lusty otter
#

Is manager.GetExistingSystem<Type>().Enabled = ... still the recommended way to toggle on/off a system?

pliant pike
#

you could also use an event entity and RequireSingletonForUpdate

hollow sorrel
#

trying to come up with a undo/redo system
in oop would just use command pattern but i don't think that's gonna work with ecs
what's the overhead of worlds?
is it feasible to just have 1000 worlds that hold delta state? data of each world wouldn't be much but it's the worlds itself i'm wondering about

#

hmmm looks like worlds aren't really meant to be used this way

bright sentinel
#

@hollow sorrel Maybe command buffers?

#

Like, wouldn't it be possible to create a reverse command buffer?

hollow sorrel
#

i thought command buffers were just for creating entities

bright sentinel
#

No you can also use it to set component data on entities

#

So before you change the component, you would store the state associated with the command

#

Not sure if it's performant to do it this way though

hollow sorrel
#

hmmm

zinc plinth
#

does NativeList allow concurrent read&write from multiple threads ?

mint iron
#

it can be done, but its not intended or ensured to be safe..AsParallelWriter()

bright sentinel
#

@zinc plinth Yes it does, it's especially useful if you use the index of the job as the indexer

zinc plinth
#

context: building a "network" of entities based on their distance to one another. I would use recursion in oop but it's not rly possible in ecs, so my idea is I have all my non connected entities, use a IJobChunk and pass a nativelist of the already connected component type, and while the size of the nativelist doesn't stop increasing, keep iterating over what's left of the non connected components

tho now that I think about it, they would all keep iterating as long as one job is still adding elements from his chunk

opaque ledge
#

So i am having an issue, i am using singleton entities to determine what systems will be run, i am using this as my game state such as player in menu and scene change and i am enforcing this by using RequireSingletonForUpdate in my systems, but the thing is there is a freeze when i change scene for the first time and its probably because code needs to be generated or something like that (because i see Mono Cecil in my profiler) any suggestions ? and sync burst compilation doesnt help as well

bright sentinel
#

@opaque ledge Does it also happen in a build?

#

Could just be the editor hogging the resources

opaque ledge
#

didnt try it on build yet, but probably you are right, wouldnt make sense to have it like that in build

mint iron
#

Check for exceptions being swallowed somewhere. Check there's nothing heavy going on in your OnStartRunning() methods - they'll execute when a query hits (from creating the entity they need). Could also be just a lot of stuff happening all of a sudden, that could delay main thread while an EntityCommandBuffer works.

zinc plinth
#

xzjv where does .AsParallelWriter() come from if I need it ?

mint iron
#

Unity.Collections.NativeList<T>.AsParallelWriter()
com.unity.collections@0.7.0-preview.2\Unity.Collections\NativeList.cs

zinc plinth
#

thanks!

dusty scarab
#

I'm trying to setup a movement for a cube but the following is doing something weird. Works fine initially, but as soon as the cube rotates in the direction of the velocity, the system seems to stop running

public class TankMovementSystem : JobComponentSystem
    {
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var deltaTime = Time.DeltaTime;

           // JobHandle job = 
            return Entities.ForEach((ref Translation translation, ref LocalToWorld localToWorld, ref PhysicsVelocity velocity, 
                                ref TankMovementData tankMovement, in TankInputData inputData) =>
            {
                var maxSpeed = tankMovement.maxSpeed;
                var targetSpeed = maxSpeed * inputData.forwardAxis;
                tankMovement.currentSpeed = math.lerp(tankMovement.currentSpeed, targetSpeed, deltaTime);

                var currentVelocity = localToWorld.Forward * tankMovement.currentSpeed * deltaTime;

                velocity.Linear = new float3(currentVelocity.x, velocity.Linear.y, currentVelocity.z);
               
            }).Schedule(inputDeps);
        }
    }

Input System I'm using https://hatebin.com/yjqwqtoooq

#

The cube moves to its initial position actually

zinc plinth
opaque ledge
#

values

#

(most likely, otherwise keys+values)

zinc plinth
#

alright 👍

opaque ledge
#

From Joachim
Hybrid does not imply stop gap solution. It is the official renderer that is meant to be used with DOTS.
We are working towards complete compatibility with HDRP & URP functionality, but at significantly better performance on the CPU.

Lights and Cameras are in progress they will be serialised as normal unity game objects using the new Hybrid component support.

#

i guess Hybrid component is the future

mint iron
#

I think hybrid just means there's a conversion from an Editor representation into ECS, right now the Editor uses GameObjects, if it later uses something else or even writes directly into ECS, you're still going to have a 'Hybrid' setup because most users will want to configure things in an Editor GUI.

sour ravine
#

any plans to make multiple Scenes not suck

#

frankly I don't think the editor nor existing scene management does a great job dealing with that

#

DOTS actually gets it pretty right, I think

#

right but as an example if we want to have multiple (independent) scenes going a lot of the assumptions about additive scenes, etc. don't seem to hold

#

yes, but in this case project just wants scenes to exist side by side

#

and based on understanding(s) of how Unity treats Scenes, this isn't actually the case

safe lintel
#

nested subscenes?

sour ravine
#

sure

#

(porque ne los dos, as the expression goes)

#

if you want hybrid objects, then you do

#

again, unless I am greatly mistaken

formal scaffold
#

Hey, is there a console inside Visual Studio where I can test a few functions?

#

Ill do that

sour ravine
#

let's say I have a VisualEffect hybrid component in my World

#

in what Scene does the magic hybrid GO that owns the component live

#

this is tremendously unclear in the documentation but has implications for keeping things compartmentalized

#

Right, so if I have multiple Worlds, do I have any guarantee that hybrid components created in one world won't leak into others

#

so far I've mostly been doing things like compiling VisualEffect events in DOTS and then dispatching them in a fake Job running on main thread

safe lintel
#

@digital scarab so is the longterm plan for visualeffect and particle systems and the like to just to use them as hybrid components then?

#

also hybrid components in the samples are discussed as Hybrid Components are an experimental feature, their use isn't recommended yet. is this due to just being experimental and stability is in question, ie it will get better or is it experimental and they might just be replaced with something different?

sour ravine
#

experimental as in not really documented/extensively tested with

bright sentinel
#

Is there any chance that experimental stuff can still be scrapped?

sour ravine
#

@digital scarab so then how do Cameras belonging to a particular World not render objects in other worlds

#

since it seems like right now they do

#

which I understand, but this gets into mixing visibility

safe lintel
#

i get that everything is potentially changeable with it being preview but the current plan is to improve upon hybrid components then?

#

where do VisualEffect components fall into with this?

sour ravine
#

right, and you can extend that to make a pretty efficient system for pooling similar to what the FPS sample does

#

useful for small, bursty effects like impacts

safe lintel
#

im already pooling them but just trying to glean what a longer term outlook for that side of things is in the dots realm

sour ravine
#

also interested in implementing a shadow caching system based around the HDLightData

safe lintel
#

@digital scarab thanks, just trying to glean some certainty in these uncertain times 😄

formal scaffold
#

How can I get the angle between two quaternions? there is no math.angle or quaternion.angle

sour ravine
#

What Are You Doing, Really™

#

quaternion dot products will kind of do what you need BUT they have some unusual properties, so let's back up first

dull copper
formal scaffold
#

I'm implementing a movment system where input translates into rotation + movement at the same time. I rotate using math.slerp and I move by applying velocity.

This means that turning happens at the same time as moving.

My problem is that when I do a 180° turn, I move at the same time. So if I move to from Left -> Right I also move Up a bit. In this special case, let's say 160° turns or more will halt movement until my character is done rotating. This will ensure my character stays in place.

To me this is more realistic since the freeze in momentum caused by the rotation feels like stopping and then moving.

sour ravine
#

in of itself, that's fine, but where does the angle fit into it

#

as in, are you interested in comparing how similar two rotations are or is the actual Euclidean angle of interest to you

formal scaffold
#

Sorry I pressed Enter too quickly

opaque ledge
#

you can use LookRotation if you want to look at something, and you can still use UnityEngine's stuff, like Vector3.RotateTowards

#
            Entities.WithAll<EncounterShip>().ForEach((ref Rotation rotation, in EncounterNPCShipMovementDirection direction) =>
            {
                var newDir = UnityEngine.Vector3.RotateTowards(forward(rotation.Value), direction.Value, radians(direction.MaxAngle * deltaTime), 0.0f);
                rotation.Value = Unity.Mathematics.quaternion.LookRotation(newDir, up());
            }).ScheduleParallel();

I am using this for my ship to look at something with time restricted by max angle

formal scaffold
#

For that I want to compare my targetRotation with my currentRotation > 160°

opaque ledge
#

you have to use dot product then

formal scaffold
#

The dot product returns negative when 90° and more yeah 🤔

sour ravine
#

that could work, but do keep in mind that quats actually have 720 degrees of rotation

#

so remember to invert as appropriate

formal scaffold
#

But I don't want 90° and more I want 160° and more

sour ravine
#

(not kidding, they're really weird)

formal scaffold
#

But currently there is no function within math that return's me an angle between two quaternions right? Do you think such a thing will be added in the future? I guess I have to use the normal Unity stuff until then

sour ravine
#

it's mathematically kind of strange

#

not an API problem

opaque ledge
#

you have to do acos(dot/(forward(quaternion1)*forward(quaternion2)))
basically, inverse cos of dot producted divided by 2 vector's magnitude multiplied

#

i think 😄

north bay
#

Stop already

#

My brain

opaque ledge
#

i was actually just watching a video about this in Unity Learn

#

let me give you the link

#

i believe in video she also used cross product to determine which quadrant the difference vector was

sour ravine
#

yep, that's the inversion problem I mentioned

#

welcome to the world of imaginary pseudovectors

opaque ledge
#

xD

formal scaffold
#

Yeah I wanted to use that, but with Unity.Mathematics. Tho there is no function for that. Ill just use that and test.

opaque ledge
#

yeah, its not complete rn when it comes to utility functions

formal scaffold
#

Okay thanks 😅

opaque ledge
#

so.. i have 4k ships and Transform system takes 6.3 ms, and Step Physics World takes 5.12 ms, ships have kinematic body, and around 2/3 colliders, and bunch of children for rendering modular stuff like engine, weapons etc, do you guys think there is something i could do to reduce these numbers ?

#

except reducing children amount lol

#

and rendermesh is taking 60 ms 😒

sour ravine
#

render fewer meshes lol

opaque ledge
#

is there a dynamic occlusion i could use ?

#

i was thinking about using occlusion areas, tho not sure if it will work or not 🤔

mint iron
#

thats with burst on, all safety off, jobs debugger off, leak detection off?

opaque ledge
#

no, let me check

mint iron
#

also, either wait a while running or turn on sync compilation because otherwise it could still be using the nonburst versions, it takes a while sometimes to wire them up in async

opaque ledge
#

yeah, i am using sync compliation

#

pretty much the same

#

Well, i guess i will stick around max 1k ships 🤷

tacit finch
#

Hello, I have some questions about Unity ECS, How would I go about using a 2d boxcollider on a sprite and make it trigger code when clicked on? 1. Do I just create a system that checks for Input and executes code (instead of Monobehaviour.OnMouseDown). 2. I haven't been able to get Boxcolliders working? Should I be using Unity Physics, i.e. Physics shapes even in 2d collision?

amber flicker
#

@opaque ledge fwiw I'd expect transform system to take 6ms for more like 100k+ entities - roughly how many children does each ship have?

opaque ledge
#

10 max

#

@amber flicker

#

and i checked if it was waiting for a job to finish or not, it wasnt

warped oriole
#

I have a basic ECS querstion, I have a ComponentSystem... I can't seem to figure out how to add it to a scene?

#

It seems like I am missing something basic, but all the tutorials and such are using different versions of DOTS and it is not clear what is depricated and what is not.. honestly the variations of this framework make finding help and understanding what to do a messs

#

the official documentation (presumably up to date) has no foundational tutorial to start you from scratch, it has an implied level of knowledge expected when reading it

#

so I am not sure where to start

#

Any guidance or help would be appreciated

bright sentinel
#

@warped oriole Well, first off, you want to be using SystemBase with the latest version of Entities, that has replaced ComponentSystem and JobComponentSystem.
Secondly, systems are created automatically and does not need to be in a scene. Essentially, they live outside the scene. All they do is query for components, i.e. fetch all the components that you specify within it, and then does some transformation to its data. So it doesn't make any sense to have it in a scene

#

You really have to completely rethink how to program when you're working with DOTS

#

And data-oriented design in general

warped oriole
#

yah

#

that makes sense

#

so the system will run just because it is part of the scene

#

then it finds all enetites in the scene and runs them

#

well runs its logic on them

#

based on the components the entity has and the system is lookign for

bright sentinel
#

Not exactly, it's part of a world. It will find all the components where the entities have the set of components specified in the qiery

#

Well yeah, the last one is correct

warped oriole
#

so how do I know if a system is "active" or not?

#

if it lives outside of the scene?

bright sentinel
#

You can use the Entity Debugger

warped oriole
#

like how would I turn on and off a system programatically (presumably through a master system)

#

liek a system would say "enable this system"

#

or something?

bright sentinel
#

You'd use World.GetOrCreateSystem<SystemType>().Enabled I think

#

You can also specify that a singleton should be present in the scene

gusty comet
#

guys

bright sentinel
#

And then use RequireSingletonForUpdate in the OnCreate function of your system

#

Then you can just delete/add that singleton

#

And your system will handle it automatically

tacit finch
#

@bright sentinel Do you know how I would go around using 2D boxcolliders with ECS?

bright sentinel
#

@tacit finch You'd have to look into the DOTS 2D stuff

#

I'm not familiar with it

#

But you can't directly use the MonoBehaviour colliders in ECS

#

2D isn't very developed yet though

warped oriole
#

@bright sentinel got it working

#

wow that was way harder than it should have been

bright sentinel
#

@warped oriole As I said, you're basically having to relearn how to code with DOD

tacit finch
#

@bright sentinel Ok thanks I will do that

warped oriole
#

not only am I having to relearn how to code, I am having to do it with a system that has 10 ways over the last two years to do things and all of them are using the same words and tutorials / videos / documentation is intermingled

#

it is impossible to figure this stuff out just using the material unity is providing

#

it is a mess

bright sentinel
#

Yeah, that's true

#

But you also have to remember that it's experimental

#

It's not in a stable state yet

warped oriole
#

for sure

bright sentinel
#

That being said though, go to the official docs

#

Those are actually updated every time something new comes out

warped oriole
#

i was at the official docs and they have an assumed level of knowledge

#

they don't start at the begining like "add a game object" then add the convert to entity script

#

they don't have a step by step guide

#

which is a shame

bright sentinel
#

Yeah, but that also comes with the experimental stuff

#

The best place to learn is the docs+sample

#

The samples show a lot of useful usecases

warped oriole
#

how do I get the entity viewer to show?

bright sentinel
#

The entity debugger is brought up in the "Window -> Analysis" menu

warped oriole
#

wow cool

#

is there a way to modify component data during runtime like modifying a gameobject component from the inspector?

bright sentinel
#

Not exactly. If you go to the DOTS window and then set LiveLink to edit mode, then you can change your gameobjects, which will propagate to the entity objects. It's not exactly the same as being able to change a gameobject during runtime though, but it's the closest there is currently

warped oriole
#

hmm

amber flicker
#

@opaque ledge well.. I guess that's in the rough order of magnitude esp combined with heavy used of linkedentities, rigidbodies etc - do all of the children move independently? If not it could pay dividends to flatten your hierarchy

pliant pike
#

I have a basic question, I have this for loop for (float j = begintpos; j <= endtpos; j += MinLengthDist) I need it to execute one last time even though j never actually equals endtpos, I need it to almost force j to equal endtpos on the last loop, is there a way of doing that?

warped oriole
#

do while?

#

@pliant pike

#

do { logic } while();

#

or just run your logic one more time after the loop finishes

pliant pike
#

oh yeah, I havent used while's in ages, thanks

fallow mason
#

But I've been thinking about forgoing writing to an input singleton in favor of just listening to the input event on each system that needs it. The tradeoff is that I don't have a large singleton component that I pull into every system that doesn't use 75% of it, but now I have a bunch of empty events that get called by the input system.

#

Which is preferable?

finite ibex
#

Does anyone know why im getting this "ArgumentNullException: A valid BlobAssetStore must be passed to construct a BlobAssetComputationContext
Parameter name: blobAssetStore" I am redoing a tutorial and didn't get that before. I was using GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(_defaultWorld, null); but now i need to GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(_defaultWorld, new BlobAssetStore()); is that ok?

#

im using slighly newer packages than my previous run

pliant pike
#

@fallow mason```csharp
[AlwaysUpdateSystem]
public class PlayerInputSystem : JobComponentSystem
{

    private PlayerInputActions controls;
    private float2 inputMove;
    private float2 inputLook;
    private bool inputFire;

    protected override void OnCreate()
    {
        controls = new PlayerInputActions();
        controls.Enable();

        controls.PlayerControls.Move.performed += ctx => inputMove = ctx.ReadValue<Vector2>();

        //controls.Player.Look.performed += ctx => inputLook = ctx.ReadValue<Vector2>();
        //controls.Player.Fire.performed += ctx => inputFire = true;
        //controls.Player.Fire.canceled += ctx => inputFire = false;
    }

    protected override void OnStartRunning()
    {
        if (HasSingleton<PlayerInput>()) return;

        EntityManager.CreateEntity(typeof(PlayerInput));
    }


    protected override void OnDestroy()
    {
        controls.Disable();
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        //if (HasSingleton<PlayerInput>()) return job;
        //EntityManager.CreateEntity(typeof(PlayerInput));

        var move = inputMove;
        //var look = inputLook;
        //bool jump = controls.Player.Jump.triggered;
        //bool fire = controls.Player.Fire.triggered;
        //bool fire = inputFire;

        Entities.ForEach((ref PlayerInput input) =>
        {
            input.moveInput = move;
            //Debug.Log(input.moveInput);
            //input.jumpInput = jump;
            //input.lookInput = look;
            // input.fireInput = fire;

        }).Run();

        //Debug.Log("The current input is " + move);

        return default;
    }

}```
#

I'm not sure if that's what your looking for but someone here gave me that

fallow mason
#

yeah, that's basically following the example of writing to a singleton

#

I was just wondering if a pattern of each system just listening to the events it's interested in without writing to component data might have some benefits

bright sentinel
#

I think it depends on what the consumers of the data are

pliant pike
#

you mean each system having their own inputactions?

#

that seems more of a headache

bright sentinel
#

For example, in my project, I have an input system that sets the input of some generic components, like a MovementData component

fallow mason
#

In that example, the PlayerInput component has just moveInput, but what if it has 20 other things as part of the component? Then your move system is pulling in 19 unnecessary pieces of data

bright sentinel
#

This MovementData can also be used by AI that has the same behavior as the player, but controlled by an AI instead

#

If you don't need AI, then you can simplify it a lot (and gain performance)

#

And if you're doing networking (like I am) it's a completely other solution

pliant pike
#

at least your keeping all the inputs in one place

fallow mason
#

@pliant pike not necessarily their own input actions, just only do something with the events that matter to it

#

like this:

#
    public void OnAddWaypoint(InputAction.CallbackContext context)=>addWaypoint = context.ReadValue<Vector2>();
    public void OnPan(InputAction.CallbackContext context) { }
    public void OnZoom(InputAction.CallbackContext context) { }
#

waypoint system would do something with the events that matter, but empty events for the ones that don't. another system would use the same inputactions, but do the opposite

pliant pike
#

I don't know that seems more complicated to me, than just having one job that sets componentdata when it receives input, and then you can read or do whatever you want with it

#

inputs need to be really responsive too

#

anyway gotta go, its 2.00am damn daylights savings leahYTHO

fallow mason
#

Thank you @pliant pike and @bright sentinel for your thoughts

safe lintel
#

funny i just about wrapped up converting my existing system for getting input to the same format as you linked DROD

#

I dont think having one big component where you need it will hurt things that much, having all your input in one(or two systems in my case) is much cleaner than splitting up to multiple places. also I was relying on the PlayerInput component so im glad to be rid of that, one less piece of setup that I have to worry about.

finite ibex
#

DC0025: Type Physics cannot be used with WithAll as it is not a supported component type Without the WithAll i get Physics cannot be used in lambda. im sure I'll be able to figure it out but maybe someone can point me in the right direction

#

Im trying to setup a job using SystemBase

#

Entities.WithAll<Translation, Physics>().ForEach((ref Translation translation, in Physics physics)

safe lintel
#

"Physics" isnt a component

finite ibex
#

ty, lol

safe lintel
#

there is: PhysicsCollider, PhysicsVelocity, PhysicsMass, and others

finite ibex
#

I had Collider2D[] contextColliders = Physics2D.OverlapCircleAll(agent.transform.position, neighbourRadius); in my non ECS project

#

All i can seem to find is SphereCastAll in the Physics. methods

#

is that probably what i need to do ?

safe lintel
#

I guess, havent used spherecast personally

fallow mason
#

@safe lintel yeah, I think I'll probably do it like they have in the examples. If only to avoid all the setup it takes to get input events listening to the input actions.

safe lintel
#

yeah it is a hassle to "translate" the input over to a system when not using that example

fallow mason
#

It looks like you need to create your own sphere collider and call CastCollider from the CollisionWorld

finite ibex
#

@fallow mason tyvm, i will look into trying to understand what you're saying in the second sentence.. 🙂

blissful tendon
#

how hard is dots to learn lol

#

if you are quite proficient with unity in general

opaque escarp
#

Not too difficult. The difficulty is more from trying to get your mind out of an object-oriented mindset. I'd say an hour doing stuff each day and you'll be quite confident in your DOTS abilities in a month or so

#

But you can get simple stuff running with just a few hours of research and trying stuff

#

Also I'm referring mostly to ECS. DOTS in general is kind of hard to answer

blissful tendon
#

oh sweet

dark barn
#

can someone give me a slide script

solar spire
#

@dark barn Do not cross-post. This channel is specifically for DOTS code, which I assume your post has nothing to do with.

finite ibex
#

@blissful tendon I spent a week reading up on it and watching youtube videos

#

I can send you a stream lined list of things I felt that worked the best if you want

blissful tendon
#

@finite ibex yes that would be great thx so much!

formal scaffold
#

Hey does anyone know why this line ```cs
velocity.Linear = math.normalizesafe(localToWorld.Forward, 0) * math.length(input) * movementSpeed;

Causes my character at the start of the movement to jump into the direction a little bit? It's like, he jumps forard a bit and then get's teleported back. 

Continuous movement is smooth tho. It's just the acceleration part at the beginning
dusty scarab
#

Facing the same issue. Cube jumps/moves forward and then like rotates and goes back to the original position

What I am using


 currentVelocity = localToWorld.Forward * tankMovement.currentSpeed * deltaTime;

                velocity.Linear = new float3(currentVelocity.x, velocity.Linear.y, currentVelocity.z); ```
formal scaffold
#

The one thing I didn't try is to use += instead of = and make sure the calculated velocity increases over time up to a maximum amount, like movementSpeed

#

But maybe then += is wrong

bright sentinel
#

Do you have netcode installed?

opaque ledge
#

@formal scaffold LocalToWorld is updated at Transform System (i think), you should use Rotation component and do math.forward(rotation.Value)

scarlet inlet
#

Hello there, is there a way to know which thread is running a specific job? I think it may be the NativeThreadIndex thing but it seems that the JobWorkers can run up to 128 threads and I need to be sure about this. I want to write algorithms where the datastructures are local per thread, this means I have to initialize 128 datastructures per each job. It seems that a similar approach is anyway used by some native containers for the parallel writing. What can you tell me?

mint iron
#

yep, its the attribute [NativeSetThreadIndex] that causes the index to be injected. It uses JobsUtility.MaxJobThreadCount possible threads. Creating one dedicated collection per thread works well, iterating every thread after to consolidate whatever was added; with the downside of taking up more memory. From looking at the threadIds in my tests it mostly uses slots 1-20 but occasionally will have an Id of 60-80 so you can't assume its sequentially indexed.

scarlet inlet
#

do you use an array of datastructures?

#

how do you keep track of the datastructures to merge later

vagrant surge
#

not on unity, but on cpp for the times ive needed to do something of the sort, i had a queue of data structures. When a thread finishes, it puts it back into the queue

#

but yeah if N threads will do it at once, you need N copies.

scarlet inlet
#

a sort of pool

vagrant surge
#

pretty much

scarlet inlet
#

I would like to preallocate them

#

not allocate on demand

#

I find weird that I cannot control the number of threads to spin up

mint iron
scarlet inlet
#

if I had to write the API myself I would let the user choose the number of threads to spin up

vagrant surge
#

isnt it possible to launch the job with only a set number of cores?

#

by doing a parallel for where I is whatever number you want of launches

#

on cpp ive done that by launching a stl parallel for with N being like 4

#

so 4 threads doing that

scarlet inlet
#

wow @mint iron I don't want to speak to early but at glance that datastructure is what I need

#

@vagrant surge I don't think it works in that way

#

you can choose the number of items to iterate and how big is a batch, which theoretically means how many jobs will spin up, but a job != thread

#

as far as I understood

#

which is annoying imo

vagrant surge
#

but if batch size is 1, and you give it 5, it would spin 5 tasks, no?

scarlet inlet
#

maybe, but even if it does (which I am not sure) 5 jobs won't mean 5 threads

#

as far as I understood

mint iron
#

interestingly unitys own approaches started out with one per thread and then their NativeStream etc moved to an interlocked .Begin() step to allocate a space for a thread. Seems that way its a little annoying for the user, but lets you avoid having to always iterate through every possible thread

scarlet inlet
#

my own multithreaded task system just spawn a thread per batch

#

it's simple and effective, I am not sure why doing otherwise

vagrant surge
#

imagine you are doing a parallel for on megacity culling, where you have like 5 million meshes

#

you would launch thousands and thousands of tasks

scarlet inlet
#

yeah no it doesn't work in that way, it still splits them in N predefined threads

#

M tasks, N trhreads

#

but I have control on M and N

bright sentinel
#

The thing is with the job system, you shouldn't have to care about the amount of threads. All you need to care about is jobs, except when writing to arrays from multiple threads. Essentially Unity spawns 1 thread per CPU core to control context switching

scarlet inlet
#

@bright sentinel that's fine until you want to write strategies that adopt thread local datastructures

#

at that point the design becomes super annoying

bright sentinel
#

But why would you need that?

scarlet inlet
#

because a lot of solutions work better using single threaded simple data structures per thread and merge them in a sync point, then using a thread safe datastructure shared between threads

bright sentinel
#

But wouldn't that be what components are?

vagrant surge
#

not neccesarely

#

think something like culling or collision

scarlet inlet
#

yes I am talking about native containers though, when components are not enough

vagrant surge
#

you run the jobs and build arrays of the stuff that collided

#

and at the end you have N arrays of collision events, done with basically 0 sync

bright sentinel
#

FixedList?

vagrant surge
#

array of lists

#

one per core

scarlet inlet
#

in perfect world one per core, on windows one per thread

#

that's why you need to know the threds

#

the number of threads

#

(on console you can reason per core, on windows you can't)

vagrant surge
#

i do something fairly similar to that on my experimental vulkan renderer, but in there i control how many threads i launch

bright sentinel
#

Well, you could always just use a flattened 2D NativeArray/List and use the thread index to access the specific thread's part of the array

scarlet inlet
#

exactly

#

controlling the number of threads is fundamental

vagrant surge
#

i launch 4 workers that go through the scene gathering rendering commands, and putting those rendering commands in a threadlocal array

#

then at the end i have 4 arrays of stuff to renderer, and i sort those in a bigger array with all

scarlet inlet
#

@bright sentinel it works, but in some cases, like mine now, I don't really know the size in advance

#

I need to use resizible datastructures

bright sentinel
#

Isn't FixedList resizable?

mint iron
#

use a flattened 2D NativeArray/List and use the thread index to access the specific thread's part of the array it may work but its not optimal because of the cachline sized overlaps between thread areas causing contention. One thread can write to its space, and cause the thread operating next to it to have its cache line tossed out and reloaded.

scarlet inlet
#

wait I have never seen FixedList, I know only NativeList let me see

vagrant surge
#

@mint iron not if they are padded

#

or in the shared array you are storing a pointer to the dynamic array

#

not the dynamic array itself

scarlet inlet
#

@mint iron I am still not sure that in real life false sharing is a real problem

mint iron
#

right, but thats what we're talking about, allocating specially for this scenario

vagrant surge
#

@scarlet inlet ive actually seen it on some of my experiments

#

when it hits, it hits hard

#

but its not very easy to have it happen

scarlet inlet
#

but the impact of it depends by how big your datastructures are right?

vagrant surge
#

it mostly means that your reads/writes from that memory locations are suddenly 100x more expensive

scarlet inlet
#

even if I allocated a continous array and share it with ranges per threads, if each range is quite big, false sharing will be rare

vagrant surge
#

yeah in those cases you never bother

scarlet inlet
#

I still believe that forcing to copy of structures instead to use ref is worse

vagrant surge
#

it only really shows clearly if you do something like have an array of integers

#

and then each thread is writing to those

#

contiguosly

#

i found it by mistake lmao

scarlet inlet
#

that's also why using something like a NativeQueue paralleWrite is not always a great idea right?

vagrant surge
#

i dont know how that queue is implemented

#

so i dont know

#

but for example the cpp moodycamel queue can chug extreme amounts of data with nearly zero overhead

scarlet inlet
#

well my point is that it's still shared memory between threads

vagrant surge
#

on parallel write

#

if its similar to the implementation there, parallelwrite is so cheap you basically dont bother

scarlet inlet
#

the false sharing issue happens only if threads read/write or also on writing only?

vagrant surge
#

read-write

#

basically all reads and all writes have to sync through L3

#

so they become a L3 cache miss

scarlet inlet
#

OK, makes sense

vagrant surge
#

bit more expensive than that in fact

#

you can run those benchmarks, they show a lot of the behavior of this sort of thing

mint iron
#

wow, nice!

vagrant surge
#

one of them is specifically about false sharing

#

there was a results page somewhere, im trying to find it

scarlet inlet
#

would be nice to have a tool to know if these problems arise in my code

#

would VTUNE do that?

#

btw just speaking with you now I found out 2 datastructures I was not aware of FixedList and UnsafeAppendbuffer

#

this is annoying too

#

also because I implemented my version of UnsafeAppendBuffer

vagrant surge
#

oh yes vtune has a conter for it

scarlet inlet
#

it's ages I don't use Vtune, I know that now it works with unity

#

I have never needed that level of optimization so far

#

we are pushing DOTS a lot and still not getting to the limits of it

#

I have seen things I still can't really process

#

in terms of performnace

vagrant surge
#

its very uncommon to get false sharing on the ecs

scarlet inlet
#

you mean unity ecs

vagrant surge
#

yeah in the model they use

scarlet inlet
#

but I don't use UECS

vagrant surge
#

in stuff like entt you can see false sharing

scarlet inlet
#

I use UECS only for Havok physics

vagrant surge
#

but only a small % of stuff, so its not really a huge hit

scarlet inlet
#

the problem about this level of optimization is that you can have different effect on different machines, very annoying

#

stupid PCs 😄

#

I understand how on console this kind of optimization would me more common

#

I instead have a LOT of doubts for mobile

#

you don't want even to push the CPU so hard to not drain the battery rihgt?

vagrant surge
#

my favourite of those was on my little boids/spacebattle thingy, where i run something like 100k moveable spaceships with child entities and boid-like logic

#

i gave the bench to a friend who had a threadripper 32 cores

#

and some sections of the code slowed down massively

#

due to the absolutely insane amount of memory requests to the RAM

#

the threadripper was choking hard on memory bandwidth

scarlet inlet
#

is an AMD issue?

vagrant surge
#

nah, i develop this thing on my ryzen 1700 (8 cores)

#

that threadripper is mostly just 4 of those glued together

scarlet inlet
#

so you mean the code was too fast? 🙂

vagrant surge
#

it became super-bottlenecked on memory latency, as this guy had tweaked his RAM timings

scarlet inlet
#

why

vagrant surge
#

to clock the ram higher

scarlet inlet
#

I don't understand how it can get worse

vagrant surge
#

in first gen ryzens, ram clock speed is also internal cache speed

#

its weird to try to run stuff in such exotic hardware, with 32 cores. You dont know what will happen

dull copper
#

I dunno, things seem to scale pretty well on AMD

scarlet inlet
#

a bit strange, but yeah I bet once I finish all the obvious optimizations, I will start to face these problems too

vagrant surge
#

i believe one of the reasons it ran so bad, is because, being an ECS, the stuff was changing from the caches of different cores

dull copper
#

from my own exp, my current 12 core 3900x is more than 2x the perf of 6 core 2600x on all brute force cpu load

vagrant surge
#

so i had stuff like a parallel-for for some chunks (my ecs is unity-style), and then another parallel for for other systems. But the jobs get allocated to different threads

#

so chunk A is first calculated on thread 1, and then maybe on thread 8, and has to transfer the memory

dull copper
#

and most benchmarks I've seen online, things seem to scale for higher cpu count ryzens too

#

if the 32c TR is some older model, those had lower clock speeds per core

#

most recent one (3970x) should be quite snappy

vagrant surge
#

yeah that one has more contiguous caches

#

the weird one was the first and second gen ones

#

where it was literally 4 ryzens glued together

#

each with its own caches

dull copper
#

ah, yes

lusty otter
#

😔

#

I'm hoping they fix the Android compile issue soon.

#

I'm developing a game for mobile and I use Android for remote testing so I cannot switch to another platform.

#

I need to do the fix everytime I start up the project and it's getting really annoying.

dull copper
#

@lusty otter is this related to dots?

warped trail
#

copy package from PackageCache to Packages folder😅

scarlet inlet
#

thank you for your help, I can go back coding now. This channel is very good 👍

dull copper
#

and yeah, don't edit packages on packagecache

#

they will be overwritten on load

lusty otter
#

Oh okay, I didn't know that.

#

I just follow the fix on that forum post 😂

#

Thanks for the info.

coarse turtle
#

hmm anyone have notes on limitations of subscenes? I'm trying to figure out how to write a conversion pipeline to declare certain project assets as entities like textures and materials (similar to what TinySpaceShip 2D Sample did), but I'm finding that some of declared assets in ISCDs are null :/

finite ibex
#
_entityPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(_gameObjectPrefab, settings);``` This was working before I added the Physics package which in turn needed to update the collections package.  I can add ```new BlobAssetStore()``` in place of the null.  But then I get a memory leak. If I put that BlobAssetStore() into a variable and Dispose of it once i've created my entities.. It seems to work.  But I don't understand why I need to do that now
uncut vessel
#

I just noticed there is a channel for DOTS. I'm looking to start a project soon but I wanted to know if I should use Playmaker vs Unity's Visual Programing? Anyone have experience with both?

opaque ledge
#

its just how its Ironcat 😄

worldly pulsar
#

Unity visual scripting is nowhere near ready for production 🙂

opaque ledge
#

i dont think Playmaker is suitable, and Unity's Visual Programming is right now in experimental state

#

tho they told us they will release a new version around the end of this month

coarse turtle
#

there's bolt - but it's for monobehaviour workflows ¯_(ツ)_/¯

uncut vessel
#

You guys don't like playmaker?

coarse turtle
#

well personally I don't use any visual scripter

opaque ledge
#

isnt playmaker for monobehaviour workflow ? ECS is whole another workflow

safe lintel
#

@uncut vessel playmaker doesnt cover dots, afaik none of them do except unity's own which is very early in production

uncut vessel
#

I used to be more on the production/design side, so I'm very green to the programing/implementation side.

#

Please excuse my ignorance.

safe lintel
#

by all means try it out, give your feedback in the thread for it, but i wouldnt start a proper project with a dependence on it being production ready

formal scaffold
#

@opaque ledge Using ```cs
math.forward(rotation.Value)

Changes nothing, I also tried ``` UpdateAfter(TransformSystemGroup)```since the LocalToWorld is being set there, yes. It's really wierd that this bump orruces only at the beginning.  But @dusty scarab I managed to fix it with this
```cs
math.lerp(velocity.Linear, direction * magnitude * movementSpeed, 0.1f);

I wonder if this is the only way to fix this problem 🤔 I feels right tho.

amber flicker
#

@uncut vessel I haven’t used either but I think they are very different- I think playmaker has much more functionality. I would strongly recommend using playmaker if you don’t have that much programming experience as there will be so much more help with getting started and solving problems.

dusty scarab
#

@formal scaffold ill check it out, thanks! Cant access a system rn.

formal scaffold
#

How can I prevent friction between colliding physics objects? I have a wall with a Physics Shape and a character with a Physics Shape and Physics Body.

When sliding along the wall my character rotates to the wall at about a 90° angle, like he is directly walking into it. This happens even when applying volocity at an angle that is 45° relative to the wall. I think it's the friction that's rotating my character. Can I somehow prevent it?

zinc plinth
mint iron
#

yep, use the chunkIndex

zinc plinth
#

alright 👍

pliant pike
#

I don't know what the hell has happened my latest ECS proj has stopped working completely, trying to run it and its stuck in a infinite loop

#

I tried importing it all into a new project and now I'm getting the error ibrary\PackageCache\com.unity.collections@0.7.0-preview.2\Unity.Collections\NativeArrayExtensions.cs(46,63): error CS0426: The type name 'ReadOnly' does not exist in the type 'NativeArray<T>'

#

have I found a massive bug or something

#

I have the collections package

zinc plinth
#

still in IJobChunk, how do you handle and access "optional" components that could be in this chunk?

#

nvm I use ArchetypeChunk.Has with a ArchetypeChunkComponentType<T>

bright sentinel
#

@pliant pike You might want to try deleting your PackageCache

#

Make sure to also update to the latest packages of Burst etc

pliant pike
#

yeah I've just been messing around with the packages and seen I'm getting loads of errors between them, thanks

pliant pike
#

I dont know what is going on I keep getting an error and conflicts between themPackage has invalid dependencies: com.unity.burst: Resolved version [1.2.3]does not satisfy requested version [1.3.0-preview.]. See console for more details

#

or I get an error with the Collections

#

it seems like I cant download or find Burst 1.3.0 with the package manager

mint iron
#

if it doesnt show up maybe your editor version is too old

pliant pike
#

ok that is weird I removed it and it gave me 1.3.0

mint iron
#

did you have a version in your /packages/?

pliant pike
#

ok when I try to update burst to 1.3.0 preview .8 I get a warning This version of the package is being used by other packages and may break them.

#

I'm on the latest alpha 2020.1.0b3.385

#

and all the other packages are updated, Collections dependency is Burst preview .5 so maybe that is it 🤔

#

nope that cant be it

#

when trying to use the latest burst I get the error InvalidOperationException: Burst failed to compile the function pointer `Int32 DoGetCSRTrampoline()

safe lintel
#

i only update burst/collections/jobs when one of the main packages depends on it, imo unless you are getting problems with what you were on before or were looking for a specific feature, best not to update willy nilly

mint iron
#

these versions work for me on 2019.3.6F1
"com.unity.collections": "0.7.0-preview.2",
"com.unity.burst": "1.3.0-preview.7",
"com.unity.entities": "0.8.0-preview.8",

pliant pike
#

now you tell me leahYTHO

safe lintel
#

yep on those packages in b3 of 2020.1

pliant pike
#

can you downgrade the packages backwards to them

safe lintel
#

yeah

#

i recall updating/changing burst needs an editor restart but the others shouldnt, but kinda always safer to do so 🙂

pliant pike
#

I dont think that would help though I'm still getting errors with the previous update

#

anyway I guess that's what you get for using alpha's and beta's, thanks for help guys

safe lintel
#

copy the manifest of packages to a new project, if it works then might be your project 😩

pliant pike
#

ok I think I've definitely found a bug new project is stuck in an infinite loop same as the first

safe lintel
#

to the bug reportmobile! chop chop 😉

dull copper
#

or... wipe library first and try again

pliant pike
#

isn't that what I did when imported it into a new project

sour ravine
#

Is there a way to sort DynamicBuffer elements directly? Copying to a NativeArray<> rn but unsure if there's high overheads associated with manipulating the buffer directly

#

would be nice to skip the copy

mint iron
#

Check out NativeSortExtension there's a ptr based overload i think.

pliant pike
#

is there a better way to disable jobs than using enabled in OnCreate or Startrunning?

#

I need to disable them all before the program runs and then enable them one by one so I can perhaps figure out which job is breaking it

mint iron
#

you could maybe put the [DisableAutoCreation] attribute on and then add them to the simulation group one at a time.

pliant pike
#

that's a bit more work than just using enabled

warped trail
#

SingltonEntity😏

pliant pike
#

maybe that's something they can put in for the future an easier way to enable and disable jobs with the editor

warped trail
#

jobs or systems?🤔

pliant pike
#

systems I guess

warped trail
#

just create singlton entity for every system you have and make requiredsingltonforupdate 😅

pliant pike
#

how about no leahYTHO

mint iron
#

mm you can also check the box next to them in the EntityDebugger

pliant pike
#

yeah but I have to get to that point first and I cant leahYTHO

coarse turtle
#

could press pause first and then play 🤔

#

I dont think systems run yet

pliant pike
#

I'll try that thanks

#

anyway I think I've figured out what the problem was its a do while loop

#

I don't think its an infinite loop but even so shouldn't it load up first

#

ok neh mind it is a fricking infinite loop leahYTHO

#

sorry guys 😳

opaque ledge
#

imo go with proper debugging (put a break point in visual studio and inspect your code, activate debug mode if in 2020.1) or do debug.log and disable burst

pliant pike
#

yeah that's what I did but the thing that threw me off was the fact it wasn't loading at all, normally when I create an infinite loop you get a partial load at least, and can tell its my fault but with this I'd never come across it behaving like that before

opaque ledge
#

when i encountered that something was causing a crash i simply commented out parts of the code until it wasnt crashing

#

its definitely poor man's solution but it works 😄

scarlet inlet
#

Trying to understand why FixedList exists and what is its use case. Someone mind shedding some light on?

opaque ledge
#

list like structure that you can place in your components

scarlet inlet
#

why is it different than a NativeList

opaque ledge
#

you cant put NativeList to a component, its not blittable

scarlet inlet
#

so it's a blittable nativelist?

#

Why does it exists since we have the Dynamicbuffer?

opaque ledge
#

something like that, except it has a hard capacity limit

scarlet inlet
#

yeah that's not clear. It says that it's resizable, but then it's not?

#

𝘼𝙣 𝙪𝙣𝙢𝙖𝙣𝙖𝙜𝙚𝙙, 𝙧𝙚𝙨𝙞𝙯𝙖𝙗𝙡𝙚 𝙡𝙞𝙨𝙩 𝙩𝙝𝙖𝙩 𝙙𝙤𝙚𝙨 𝙣𝙤𝙩 𝙖𝙡𝙡𝙤𝙘𝙖𝙩𝙚 𝙢𝙚𝙢𝙤𝙧𝙮. 𝙄𝙩 𝙞𝙨 64 𝙗𝙮𝙩𝙚𝙨 𝙞𝙣 𝙨𝙞𝙯𝙚, 𝙖𝙣𝙙 𝙘𝙤𝙣𝙩𝙖𝙞𝙣𝙨 𝙖𝙡𝙡 𝙩𝙝𝙚 𝙢𝙚𝙢𝙤𝙧𝙮 𝙞𝙩 𝙣𝙚𝙚𝙙𝙨.

#

this comment must be the most obscure in history

#

it's resizable but doesn't allocate. Its 64 bytes, but contains all the moemry it needs

#

waaaaaat

#

haha

opaque ledge
#

well, dynamic buffer is a whole another thing, but basically you can do it like that yes, but if your list has to work with your component then it would be wasted, so instead you could put fixedlist in your component and it will satisfy your needs without having to depend on a dynamic buffer

vagrant surge
#

i think its basically a std::array but with capacity tracking

#

resizeable but not really, it just preallocates that size

#

kind of hilarious that there multiple versions for multiple sizes

opaque ledge
#

and yes, unfortunately explanation of fixedlist could be worked on 😄

vagrant surge
#

vs cpp where you would do FixedList<float,64>

opaque ledge
#

its not exactly resizeable, its just it has a capacity limit so it cant go infinite

vagrant surge
#

for extra triggering, the size is on bytes

scarlet inlet
#

yes it's clearer, still not sure why the 32 to 4096 thing

#

is that the capacity?

vagrant surge
#

so FixedListFloat64 is 64 bytes of floats, so actually 16 floats

opaque ledge
#

yeah byte capacity

scarlet inlet
#

ok got it thank you

vagrant surge
#

which i think is massively stupid

#

if you read FixedListFloat64, you would think "ah, 64 floats"

opaque ledge
#

BUT 2 bytes is already being used internally 😄

#

so fixedlistfloat64 can hold up to 15 floats 😄

vagrant surge
#
  • padding i would guess
#

its still baffling cpp doesnt have one of those in the stl

#

or the good old smallvec

scarlet inlet
#

wait what? float64 means 64 bytes means 16 floats right?

vagrant surge
#

where it has fixed preallocated size, but if it goes past that it becomes a normal vector

#

@scarlet inlet -1 due to capacity int

scarlet inlet
#

oh I see thanks

opaque ledge
#

i think the reason why they did that is.. because every other fixedlist stuff has their numbers indicated by bytes, so if they were to make the number indicated the capacity insttead of bytes there would be inconsistency

#

this is even more obvious when it comes to fixedstring as ascii character would take 1 byte while a chinese character could take 4 bytes

wary anchor
#

Hi all, are there any more detailed / wide examples for how to implement SystemBase style lambdas? I'm finding it difficult to translate my many JobComponentSystems into SystemBase based on the limited (and yet simultaneously verbose) docs.unity3d.com page on SystemBase Entities.

#

On a side note, I have no idea why they changed to this style, it seems so much messier and more difficult to read than the nice separated job struct but hey ho the damage is done

wary anchor
#

Thanks @amber flicker that's very helpful

#

I really hope they don't decide to move off this new one like they did with JobComponentSystem, I have Soooooo much to change now for no benefit 😦

amber flicker
#

it feels like this is the one to settle on... mostly I'm not looking forward to reworking a bunch of code if/when they introduce a chunk.foreach api

#

well.. simultaneously looking forward to them introducing that api obviously 😄

wary anchor
#

I can't really complain because I chose this pre-production base to learn/implement, I get that. Just having a little moan because it's really not very clear how to structure these jobs now, and it's not like I already haven't given myself far too much to do! 🙂

amber flicker
#

I think if you've been working with the lambdas for a while, SystemBase doesn't feel that different... just more tidy.. but if you've come straight from e.g. IJobForEach then it feels v different

wary anchor
#

yeah I was on 0.5 up until a week or so ago

#

now it's like... oh, I gotta rewrite literally everything 😬

amber flicker
#

good luck 🙂

wary anchor
#

Cheers, going to need it! bunch of different patterns to translate with sketchy docs, what could possibly go wrong!?

#

uhhh so in is [ReadOnly] now and ref is for when you want ReadWrite access to the component?

warped trail
#

and without in or ref is just by value😅

amber flicker
#

yes and always order your args from write to readonly

wary anchor
#

and how do you translate a IJobForEachWithEntity now? I don't have too many of those but seem to have started alphabetically and the first system in my list has this

#
    [RequireComponentTag(typeof(AITag))]
    [BurstCompile]
    private    struct UpdateAISpheresArrayJob : IJobForEachWithEntity<Translation, CollisionComponent>
    {
        public NativeArray<float4> SpheresArray;
        public void Execute(Entity entity, int index, [ReadOnly] ref Translation translation, [ReadOnly] ref CollisionComponent collisionComponent)
        {
            SpheresArray[index] = new float4(translation.Value, collisionComponent.CollisionRadius);
        }
    }```
warped trail
#

Entity entity, int entityInQueryIndex

amber flicker
#

RequireComponentTag = WithAll

wary anchor
#

oh god WithAll instead of ForEach? this is worse than I thought!

amber flicker
#

instead of foreach? no

#

it ends up much more simple

warped trail
#
Entities
.WithAll<AITag>()
.ForEach((Entity entity, int entityInQueryIndex,ref Translation c1, ...)=>
{})```
wet epoch
#

that's just for tags where you don't need the data

wary anchor
#

and presumably the in Translation translation and the other component too

warped trail
#

ref if you want to change component, in or without anything if you don't want to change

wary anchor
#

yup okay got it will have a go, thanks guys

#

and is burstcompile automatic if you use ScheduleParallel();?

amber flicker
#

yes - things are burst by default - you can use .WithoutBurst or .WithStructuralChanges where appropriate

wary anchor
#

top stuff 👍

mint iron
#

Is there any way to get access to an ArchetypeChunk being used in Entities.ForEach?

amber flicker
#

nope afaik - that's what hopefully a future chunk api will provide

wary anchor
#

Sorry, one more for now... when I need a job to run now so I can do something with the data immediately, but I also want it to run in parallel, do I ScheduleParallel and then .Run() in the same chain, or will .Run() on its own run in parallel by default?

warped trail
#

i think Run will run on main thread🤔

wary anchor
#

like the equivalent of the old .Complete()

warped trail
#

no

#

😅

wary arrow
#

can you run multiple physics worlds simultaneously with the new physics pkg?

mint iron
#

not sure that you can get the JobHandle out of Entities.ForEach().Schedule(), that would be nice.

#

maybe complete on base.Dependency ?

warped trail
#

var jh = Entities.ForEach().Schedule(Dependency) 🤔

mint iron
#

that would pass in a dependency (i think?)

warped trail
#
Entities.ForEach().Schedule()``` is same as ```cs
Dependency = Entities.ForEach().Schedule(Dependency)```
sour ravine
#

just complete the handle you make

warped trail
#

in systembase

sour ravine
#

Dependency.Complete() will do what you want

#

it's just not the best idea for perf

#

(stalling main thread)

#

consider moving the other code to another job and have that depend on the Entity stuff

wary anchor
#

I couldn't work out how to do that and still access the native containers I need for sending to the compute and render shaders

mint iron
#

ahh i see the problem, you need to pass in Dependency for it to return one.
var handle = Entities.ForEach().Schedule(Dependency) works but
var handle = Entities.ForEach().Schedule() doesn't
its just a little confusing i think because of how its worked before, you only passed in a handle you wanted it to wait for, and it always spat one out regardless.

sour ravine
#

you can mix and match regular Jobs

#

Job.WithCode((lol) => { float lol = 0.0f/0.0f; }).Schedule()

#

lambda captures will keep your containers

wary anchor
#
Entities
  .WithAll<AITag>()
  .ForEach((Entity entity, int index, in Translation translation, in CollisionComponent collisionComponent) =>
  {
    spheresArray[index] = new float4(translation.Value, collisionComponent.CollisionRadius);
})
  .ScheduleParallel(Dependency)
  .Complete();

seems to compile fine. This is the trouble with upgrading, you end up going on another 2 months massive refactor and every single time this happens, your project has grown and the job gets bigger and bigger

warped trail
#

you don't have to pass Dependency to your job in this code🤔

wary anchor
#

I do if I call .Complete

zenith wyvern
#

You could just do Dependency.Complete instead

#

No difference though

wet epoch
#

does seem weird that scheduleparallel doesn't return a dependency

wary anchor
#

o/ Lecks

wet epoch
#

doesn't seem unusual for something to be a dependency without having a dependency

gusty comet
#

Getting errors like this:
"Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 5)" in my project but I am unable to determine where, is there any way of logging where this specific allocation was made?

warped trail
#

but scheduleparallel return dependency but internally🤔

wary anchor
#

also, it literally won't let me use "index" :/ Really?

zenith wyvern
#

The jobhandle is handled internally so you can ignore it unless you need it

warped trail
#

@wary anchor use entityInQueryIndex instead of index

wary anchor
#

yeah no worries done that already thanks tho!

#

mmm Entity Debugger is reporting 0.00 time for all systems

wet epoch
#

nice!

#

infinite fps

wary anchor
#

lol

warped trail
gusty comet
#

Yes and no, when I run the project in the editor no leaks are reported (burst on, stack traces on, not seeing the Use Job Threads option though), but when I compile and run the project it gives me those errors.

wary anchor
#

okay so I think there's a problem where burst isn't being used here... it's slower with the new SystemBase code (0.08 to 0.09ms) than the old JobComponentSystem (0.06-0.07ms)

zenith wyvern
#

Are you sure you haven't changed the behaviour from when you were using IJFE?

amber flicker
#

you should be able to tell from the profiler if burst is being used

zenith wyvern
#

It literally compiles to the same code

wary anchor
zenith wyvern
#

Eh your old code is using Run, so it's running on the main thread. Your new code is using Schedule, so it's scheduling a job. There is some minor overhead for scheduling jobs.

#

If your job does almost nothing you might as well just use Run.

#

It will be faster.

wary anchor
#

yup, that was the discrepancy, thanks @zenith wyvern

zenith wyvern
#

No problem. As a side note please don't use DefaultGameObjectINjectionWorld inside a system. You can just use World

wary anchor
#

k, for outside systems, I need that tho yeah?

zenith wyvern
#

Yes

wary anchor
#

👍

amber flicker
#

I'm also not sure you need to be creating that aiActionsEntityQuery? Unless it's for clarity or something?

warped trail
#
if (AICount == 0)``` i think this part is useless, because your system has RequireForUpdate(aiActorsEntityQuery), and this system just will not run if there is 0 entities in this query🤔
wary anchor
#

I think I didn't refactor this code yet, I agree that is superfluous

#

also that other entity query is a hangover from a previous version of the script so that's gone too

warped trail
#

and NativeArray has .ToArray() method😅

wary anchor
#

yup, again a hangover from when I was using a different type in another class

#

right.. next major design flaw that I need to correct and I never got around to looking into EntityComponentBuffers but as I'm refactoring this all now I should definitely do it right and do it once.

...
inputDeps = job.Schedule(this, inputDeps);
inputDeps.Complete();
if (Result.TryDequeue(out bool collidedWithPlayer))
{
  if (collidedWithPlayer)
    {
...

I have various points in systems were I'm putting in a NativeQueue of some sort then dealing with the output after completing the job. Clearly not optimal, how would you structure this type of behaviour?

zenith wyvern
#

Schedule a second job that takes output from the first job

#

Ideally you would never have to manually call complete

#

At least in my case I've never found a case where I had to force a sync point on the main thread

wary anchor
#

I know that that's the case, but so far I've not managed to get my head around how to do it

zenith wyvern
#

Unless you're still working with GameObjects in which case it will come up eventually

wary anchor
#

I'm trying to keep gameobjects limited to UI and the camera

zenith wyvern
#

If you can give a complete code example of a real world case where you feel like you need to call complete we can try and point you in the right direction

warped trail
#

Hive mind will help you😄

wary anchor
#

that would be awesome, here's the very worst case - I know I don't have to call Complete, I am just too stupid to work out how to get around it!!

https://hatebin.com/jgspqksrym

wet epoch
#

what is the BlobAssetStore that you need to pass into GameObjectConversionSettings about?

#

i'm not sure what to pass in there :/

wary anchor
#

god there's so much mess in there, I am shame itself

wet epoch
#

or maybe i'm not meant to create entity templates like this any more? bulletTemplate = GameObjectConversionUtility.ConvertGameObjectHierarchy(bulletPrefab, GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, ? ? ?)) });

zenith wyvern
#

@wary anchor Trust me I've seen/written much worse myself. You should read this page https://docs.unity3d.com/Packages/com.unity.entities@0.8/manual/entity_command_buffer.html

Try to turn the second part of your OnUpdate into a ForEach. Something like

Entities.ForEach((in PlayerElementDataComponent playerData)=>
{
    int pickupIndex = playerData.pickupCollectedThisFrame;
    if(pickupIndex >= 0)
    {
        pointLightData.RemoveAtSwapBack(pickupIndex);
        var e = commandBuffer.CreateEntity();
        commandBuffer.AddComponent<ParticlesChangedEvent>(e);
    }
}).Schedule();
#

I'm not sure what you're doing with the dynamic buffer, it looks like you copy it out to a nativearray inside the system every frame?

mint iron
#

im liking this code-review discussion, we should do this more.

wary anchor
#

yeah, this went through several attempted iterations. The aim is this: get data for these (moving) lights to send to the shader every frame (although there may be a better way I could write the shader for that particular job, I'm still pondering that).

#

I really am grateful for your time and help, everyone, thank you for this!!

#

yeah that ECB page, okay, it's time to tackle this... I read that page a couple of times a while back and it just didn't go in, but I can do this. Let's go.

zenith wyvern
#

Wherever you are grabbing that NativeArray from that public variable, you should instead be running a job inside another system that reads the dynamic buffer directly

wary anchor
#

the NativeArray gets directly put into a ComputeBuffer for the shader

#

looking at this sideways, I could lose the whole second part if instead of enqueuing the bool in the first part, I just do the EntityCommandBuffer work there instead

zenith wyvern
#

That's fine, but you shouldn't be doing that via a public variable in another system. You can do something like

Entities
    .WithoutBurst()
    .ForEach((in DynamicBuffer<MyBuffer> buffer)=>
    {
        computeBuffer.SetData(buffer.Reinterpret<int>().AsNativeArray());
    }).Run();
wary anchor
#

uh wait ignore that last comment lol

#

yeah okay that makes sense, lemme see how I can shunt that around

zenith wyvern
#

Basically having this public NativeArray seems like you're just doing work in this system that has nothing to do with what the system is doing

#

Also with AsNativeArray you avoid any copying

#

I mean, it still copies into the compute buffer, but you avoid the interim copy at least

stiff skiff
#

Hey all, I'm trying to upgrade my code from ancient 0.1.0 to latest in small steps and have some issues with 0.2.0

#
'Message': 'Burst failed to compile the function pointer `Void AddComponentEntitiesBatchExecute(Unity.Entities.EntityComponentStore*, Unity.Collections.LowLevel.Unsafe.UnsafeList*, Int32)`'
'Stacktrace': '  at Unity.Burst.BurstCompiler.Compile[T] (T delegateObj, System.Boolean isFunctionPointer) [0x000f3] in <a9b4e6c1165e4e1a8f79606ed3b1a263>:0 
  at Unity.Burst.BurstCompiler.CompileFunctionPointer[T] (T delegateMethod) [0x00000] in <a9b4e6c1165e4e1a8f79606ed3b1a263>:0 
  at Unity.Entities.StructuralChange.Initialize () [0x00000] in <9c99dfac65e54433b101952b90a46f71>:0 
  at Unity.Entities.EntityManager..ctor (Unity.Entities.World world) [0x0000b] in <9c99dfac65e54433b101952b90a46f71>:0 
  at Unity.Entities.World..ctor (System.String name) [0x00046] in <9c99dfac65e54433b101952b90a46f71>:0 
#

I'm getting this when I create my custom world, with burst disabled

#

I can't see anything in the changelogs for further versions that mention fixing this bug

#

Does anyone have an idea whats up here?

wet epoch
#

not sure what the error is, but seems like a long way to go about updating with the amount they change stuff

warped trail
#

i guess you don't have to create your own world, unless you really have to🤔

wet epoch
#

seems like there' s not much point unless you want a history lesson 🙂

stiff skiff
#

The issue is that if I update further and new errors pop up, I won't know if its because the 0.2.0 upgrade was broken, or its a new error introduced by the new upgrade

wet epoch
#

yeh you'll get lots of errors either way, the problem is your fixes in 0.2.0 might be broken in 0.3.0

zenith wyvern
#

Doing incremental upgrades like that sounds like a nightmare

fallow mason
stiff skiff
#

The error itself is odd, since burst is off. So why is it "failing" to compile a function pointer?

zenith wyvern
#

Just create a fresh project with updated entities and import your code one module at a time

wary anchor
#

I'm upgrading from 0.5 to 0.8 and it's a vast difference. TBH I think you're better off just trying to rewrite in the new paradigm because otherwise you're going to have to learn 5 different ways of achieving it all in the old systems. Honestly, that is SO much more work.

stiff skiff
#

@zenith wyvern Thats sadly not possible

#

@wary anchor New paradigm?

wary anchor
#

as in using SystemBase

#

instead of ComponentSystem -> JobComponentSystem -> SystemBase

#

and rewriting all of your code at least 3 times

stiff skiff
#

The ECS framework hasn;t changed much fundamentally, so I don't think it'll be that much of a problem

warped trail
#

i don't think anyone here remember how thing were working at 0.1.0 😅

wary anchor
#

at least

wet epoch
#

it has changed a fair bit (several times)

stiff skiff
#

The bits that changed mostly, seem to be the conversion workflow and other systems build on top of the framework

#

I dont use any of those

wary anchor
#

you don't use Systems?

wet epoch
#

and the syntax for systems/jobs

stiff skiff
#

I don't use any jobs either, the systems dont seem to have changed much

fallow mason
#

What do you use?

warped trail
#

[inject]? 😏

stiff skiff
#

worlds, systems, entities, components, chunks, etc

#

aka, the base framework

fallow mason
#

Got any IJobForEach in there?

wet epoch
#

it should be a lot cleaner/quicker to just update to the newest version :/

stiff skiff
#

@fallow mason Nop

wet epoch
#

it doesn't really matter which version your errors were introduced in?

#

they need to be fixed to work with the newest one anyway 🙂

wary anchor
#

I think the main problem you'll face is all the help you'll get is from people who are using the new versions where everything is very different than 0.2.0 - you'll struggle to find any answers dating back that far now I think

wet epoch
#

even just iterating through entities has changed significantly (you use Entities.ForEach now)

zenith wyvern
#

Either way if you want help with something specific we need to see the code that's actually causing the error

stiff skiff
#

@wet epoch that exists in 0.1.0 as well 😉

#

@zenith wyvern That is the code. I'm literally just calling new World(name)

#

Nothing special

mint iron
#

@fallow mason looks generally good to me, the comments running on the end of lines makes it a little hard to read/follow for me. The only thing i can think of is that this code runs on every actor, every frame. The early exit helps but you've still got scheduling time. It depends on how often things move versus not-move, but you could consider a tag component that designates that it has a target, and that would allow the system query to quickly filter out everything that shouldn't be processed, and do much less when nothing moves.

zenith wyvern
#

Okay. Well I just tried var world = new World("Hi"); And there is no error. So I'm gonna say it's probably not that.

wet epoch
#

in 0.2?

wary anchor
#

or not

mint iron
fallow mason
#

@mint iron Thanks. I kind of have that with the cooldown in between targets, but yes, it would still be running on entities once all targets are exhausted. I wish there were a way to filter out empty buffers. That would just solve that problem.

wary anchor
#

it's okay I'm maxxed on shame already today 😄

warped trail
#

there is .WithChangeFilter<>()@fallow mason 🤔

fallow mason
#

ooo right. don't know why that I didn't think of that 🤦‍♂️

vagrant surge
#

what the fuck is that style of comments

#

on normal-ish text size it has to wrap

mint iron
#

although change filter is per chunk so if anything in that chunk changes in any way, every entity is getting processed.

zenith wyvern
#

Hahah, maybe one of those cases where the comments actually make it harder to read

fallow mason
#

yeah, probably should have done new line comments

stiff skiff
#

@zenith wyvern Its likely a combination of 0.2. and burst disabled, its always a little tricky.

zenith wyvern
#

Ah so you're saying you may have hit an obscure bug that's long since been fixed in newer versions that no one here could possibly help you with

#

Hence why everyone was saying it may be better to just upgrade and import.

fallow mason
#

No, I did think of that. If i filter only for changes, won't it only run once? the buffer doesnt change every frame.

#

yeah, I don't think that will work

zenith wyvern
#

Could you just remove the buffer when it's empty and re-add when needed?

fallow mason
#

yes, I could do that. I probably will do that lol

#

also note, it seems you cannot have a change filter for a buffer. Got a doesn't allow generic types error.

zenith wyvern
#

You would probably just use the direct buffer type

#

Instead of DynamicBuffer<MyBuffer> just use <MyBuffer>

#

Although I'm not sure if that works either honestly

fallow mason
#

ah ok. I did try that and got no error, but it may have filtered out my entity entirely so things stopped moving.

#

huh. how do you remove the buffer? only example I see is one where it destroys the entity that has the buffer.

zenith wyvern
#

RemoveComponent<BufferType>

wary anchor
#

whoa, you can use Entity as a data type in IComponentData now?

warped trail
#

it was possible from beginning? 🤔

wary anchor
#

it was? Maybe I'm getting confused with native collections

#

christ that will make things so much easier

zenith wyvern
#

Hahah

fallow mason
#

that worked...perfectly 🙂

zenith wyvern
#

Just remember you're adding a bit of indirection there, but yeah using entities in your components/buffers is the right way to handle references to entities

wary anchor
#

like... enemies targeting the player entity for example

#

/smdh

#

oh boy these half days for covid (childcare for the other half day) is going to stretch out this monster refactor a horrible amount.

fallow mason
#

my day job of working with Unity is really cutting into my hobby of working with Unity

fallow mason
mint iron
#

im a special snowflake ❄️

warped trail
#

make it 80 characters long😅

fallow mason
#

don't have time to count characters!

dry dune
#

Maybe someone knows, does dots based per instance material properties are supported by URP now?

dry dune
#

about a month ago per instance material properties was introduced and at that moment it was working only with HDRP, my question is it still in the same state, or URP was updated to support it?

opaque ledge
#

oh also forgot to mention, hybrid v2 is not officially supported yet

#

i think they mentioned "they are working on it"

dry dune
#

yes it was in "coming soon" state

warped trail
#

i think simple answer is it is still in the same state🤔

dry dune
#

aha looks like it is going to be supported in 9.0.0-preview of the URP package

opaque ledge
#

its actually out in SRP github but... you know.. risks and crashes

dry dune
#

anyway i'm happy - it is almost there 🙂

formal scaffold
#

Any tutorial on how to create a physics material for a Physics Shape with either code or from within the editor? Creating a normal Physics Material is not supported by Physics Shape

warped trail
safe lintel
#

PhysicsMaterial.default gives you a basic one

#

or Physics.Material

formal scaffold
#

Oh @warped trail 🤦 sorry I missed that completely

opaque ledge
#

visual scripting drop 8 tomorrow 👀

mint iron
#

anyone here tried it yet?

frank wind
#

Nope

fallow mason
#

previous versions? yes.

#

I stopped because it was causing more errors in addition to standard DOTS packages.

#

also never really got used to visual scripting as I've always felt more productive just typing it out. But I like the idea.

finite ibex
#

I am trying to use SubScenes for my Entities. When I start my scene, the Entities dont appear or show in the Entity Debugger. But if I click the checkbox to edit. they appear both on screen and debugger

#

Turns out the putting the Subscene into a folder 1 deeper was the issue? idk the scene and subscene are in same folder and now it works

formal scaffold
#

Hmm a CollisionEvent doesn't have information on which layers collided. Is there a way to find out which layers collided with each other?

I want to differentiate between colliding with terrain and colliding with other characters. One way I thought of was checking the entities and accessing the layers that way, if that is possible 🤔 any ideas?

frank wind
#

I have a background in ue4 honnestly its a very useful tool to have in a team

#

A native tool like visual scripting will help a lot

#

Shadergraph is already pretty well done

zenith wyvern
#

I haven't looked at it yet, is it similar to blueprints where it really integrates well with the editor for designers?

frank wind
#

Its the goal

#

And generating actual c# code will provide very good performance if done properly

dull copper
#

they seemed to have horizontal flow on recent roadmap

#

I saw the message on roadmap talk where they said they are experimenting with it

#

I kinda hope they go with horizontal flow as that's what most people are used to, but people will adapt to it either way

#

if anything I do hope they don't let users to pick one as it's be nightmare fuel for all people following tutorials

#

this thing needs to be as streamlined as possible as visual scripting isn't really targeted at people who are fluent in text based coding

#

also IMHO... DOTS visual scripting isn't really a thing anyone should use for few years now, it's fine to test it now if your only reason is to provide feedback... but I can't imagine the pain nonprogrammers will have with DOTS ecosystem when it's such a PITA even for people who have coded for decades (not necessarily because it would be too complicated but because things evolve, need specific combo on packages etc). it's just not a very smooth experience even without the visual scripting thrown in the mix.

zenith wyvern
#

I just want a way to make editor tools that are actually nicely integrated with ECS

#

Conversion system kinda made that a nightmare as is

safe lintel
#

yeah im kinda wondering how raycasting in editor works, how terrain tools in the future work if you want the final result which gets transmogrified to ecs representation

#

just any extensive editor tooling in the future needing to go through a lengthy conversion just sounds strange 🤔

limpid bough
#

You can use ECS in the editor. You just have to cleanup entities you create if appropriate

zenith wyvern
#

How can I make a ComponentSystemGroup update between Initialization and Simulation? [UpdateAfter] and [UpdateBefore] only work if they're a part of the same Group

coarse turtle
#

I think you have to add to the list of systems to update

#

and sort it in the particularly order

zenith wyvern
#

Oh boy, that looks real rough. I barely have any systems yet and I'm already finding it a real headache to try and maintain the correct order and when I add and remove components. Based on that and similar threads it seems I'm not alone

coarse turtle
#

Otherwise I imagine you can use an ICustomBootstrap

zenith wyvern
#

I think I need to rethink how I'm doing my tagging

coarse turtle
#

I've yet to use it tho 🤔

finite ibex
#

How can I update ISharedComponent data through the editor while the game is playing? I read the fields when I am Instantiating the entities. But id like to be able to move the sliders and hit 'apply' and then I can just run a function to change the shared data

#

i have limited Editor experience, I dont think I can just call a function that is part of a running game from within the editor loop

#

maybe i'll just create ui sliders in the game and do it that way, thats the only way i can see how to do it

zenith wyvern
#

It doesn't really sound like a dots problem. There's mountains of resources online about how to write general editor tools. Once you have your ui set up you can access your entity manager from inside an editor or monobehaviour through World.DefaultGameObjectInjectionWorld

finite ibex
#

well aint that pretty! thanks for the heads up!

#

sounds promising

finite ibex
#

@zenith wyvern kinda sloppy but I got it working. Thanks!

mint iron
#

i have the nastiest bug right now, where if i destroy all the game elements at the end of my level, the editor crashes.

#

and if i comment it all out, it doesn't crash 🙂

#

....dll!Assets.Game.Systems.RemoveSelectionOffsetsSystem.Assets.Game.Systems.OnUpdate_LambdaJob0.IterateEntities(Assets.Game.Systems.RemoveSelectionOffsetsSystem/Assets.Game.Systems.OnUpdate_LambdaJob0.124 *) Line 0 C

#

so god damn strange, there's nothing really interesting happening in that system.

coarse turtle
#

what's selection offset?

#

I've honestly no idea - looks like you're just doing math 😅

finite ibex
#

are you looping to remove your game objects?

mint iron
#

thats what causes the crash yeah, end game, destroy all actors in the level, but it happens in another system, and still crashes even if i switch from Run() to .Schedule() and EntityManager.CompleteAllJobs() before the EntityManager.DestroyEntity(query) which should have its own safety anyway. I don't see how the two are related, they shouldn't be running at the same time.

mint iron
#

mmmm, its probably SetComponent(e.Entity, offsets) on an Entity that doesnt exist anymore

opaque ledge
#

i doubt that would cause a crash, it would just give you an error (i think)

gusty comet
#

Anyone used the EntityManager method CopyAndReplaceEntitiesFrom(SourceEntityManager) in order to copy entities from one world to another? Is it stable? Are there any other methods?

amber flicker
#

@mint iron Is your system that destroys the entities the calling completeall and the last system to run? Perhaps a job somewhere is still using it somehow?

#

@gusty comet I haven’t used it but it should be stable.. it’s how all the subscene stuff works I believe

gusty comet
#

@amber flicker
Ah cool!
The reason I ask is because I've run into a problem with serializing a world containing shared components that have references to managed objects in them, due to lost references when de-serializing.
Is there any good solution to the need to hook up run-time references for managed components? Are class-components a solution?

opaque ledge
#

he has an insider 😉

#

aww 😦

bright sentinel
#

I mean you could set up a bot that checks every time the package registry is updated

#

¯_(ツ)_/¯

amber flicker
#

@gusty comet shared components? Assume you mean MonoBehaviours that other MonoBehaviours reference rather than ISCD's?

gusty comet
#

@amber flicker Nah, ISharedComponentData's that contain fields that reference managed objects. A good example would be RenderMesh that references a Unity Mesh.

gusty comet
#

As far as I've been able to determine when using SerializeWorld(EntityManager, BinaryWriter, out Object[]) on a world containing such entities Unity will spit out any indigestable references to objects through the Object[] array.
I presume that the idea is that I then serialize those objects and pass them in when deserializing?

amber flicker
gusty comet
#

@amber flicker Thanks, you're a lifesaver!

mint iron
#
{
    protected override void OnUpdate()
    {
        var entity = EntityManager.CreateEntity();
        EntityManager.AddComponent<Translation>(entity);
        EntityManager.DestroyEntity(entity);

        Job.WithCode(() =>
        {
            SetComponent(entity, new Translation());

        }).Run();
    }
}```
#

we just need a burst compatible Exists method in SystemBase

fallow mason
#

Does that really cause a crash?

north bay
#

Ye it does

gusty comet
#

Why would someone use a crash system script?

mint iron
#

to prove that it crashes

gusty comet
#

:O

#

What a hacker

mint iron
#

dont get me wrong, im actually excited by the idea of having completely unchecked burst set methods without having to jump through hoops.

gusty comet
#

I was thinking it could be a method for kicking unwanted players from game

mint iron
#

What a hacker no i just had this exact crash happen yesterday and took me a while to figure out the problem.

gusty comet
#

Oh

#

I crash always. Unity Engine hates me :/

wary anchor
#

On a scale of 0 to Roo, how dumbass is this?

NativeArray<GameState> GameStateComponents = gameStateEntityQuery.ToComponentDataArrayAsync<GameState>(Allocator.TempJob, out JobHandle gameStateHandle);
NativeArray<PlayerElementDataComponent> PlayerElementDataComponents = playerEntityQuery.ToComponentDataArrayAsync<PlayerElementDataComponent>(Allocator.TempJob, out JobHandle playerElementHandle);
NativeArray<QuitGameEvent> QuitGameEvent = quitGameEntityQuery.ToComponentDataArrayAsync<QuitGameEvent>(Allocator.TempJob, out JobHandle quitGameHandle);
NativeArray<JobHandle> jobHandles = new NativeArray<JobHandle>(4, Allocator.TempJob);
jobHandles[0] = Dependency;
jobHandles[1] = gameStateHandle;
jobHandles[2] = playerElementHandle;
jobHandles[3] = quitGameHandle;
Dependency = JobHandle.CombineDependencies(jobHandles);

?

warped trail
#

you can use NativeList like they do in EndFramePhysicsSystem🤔

wary anchor
#

ahh nice one, I'm using my own physics so didn't check there

#

does that make sense to do for just 3 jobhandles being added to Dependency or is it a bit overkill?

mint iron
#

how many of these entities do you have for each component

wary anchor
#

1 entity for each, 1 component for each

warped trail
#

1 entity with 1 component?

wary anchor
#

it's an end game event message

warped trail
#

have you looked into Singlton Entities?

wary anchor
#

I kinda did but it was so obscure in the docs that I just couldn't face trying to implement it. I read several web blogs too but it just seemed too weird

#

Bear in mind just managing to tie my shoe laces and brush my teeth is often a struggle and I have no other team members to learn from/chat to/bounce ideas off 😄

mint iron
#

it would be faster and easier to just use GetSingleton<T>()

wary anchor
#

It makes sense for game state and, I guess player if I put all ideas for future MP off (which is not unreasonable, I'm sure even in MP I'd only have 1 active Player per client anyway but that's years off at this stage)

#

Have they written any new docs on that, because honestly 6 months ago it was absolutely impenetrable

mint iron
#
var state = GetSingleton<GameState>();
var playerData = GetSingleton<PlayerElementDataComponent>();
var quitGameEvent = GetSingleton<QuitGameEvent>();
#

it just expects there to be 1 entity with that component on it, and one only or it will throw exceptions.

wary anchor
#

actually the playerElementDataComponent is one of many IComponentData on the Player, but I guess there's a way to set multiple components to a singleton entity?

mint iron
#

yep, you can create an entity, then put multiple components on it, still works with get singleton

wary anchor
#

although I'm doing various parallel jobs on components on the player in the same jobs as components on other entities, eg movement/physics

mint iron
#

i found singletons to be annoying i have to say, its nice for prototyping things quick but im looking for a better solution. for one thing if you try to load a new Scene that doesn't create the things all these GetSingleton<T>() calls require, then you get exceptions all over the place. So then you start literring code with HasSingleton<T>() branches to fix that. And then you start questioning your existence when looking at how ugly the code has become.

warped trail
#

why not use RequireSingletonForUpdate ?🤔

wary anchor
#

I'm only using this for a one off "game has ended, now need to kick some main thread and UI stuff off" scenario, but still I do want to learn how to improve, even if I am horrendously daunted by some of the implementations that Unity have created here

warped trail
#

i think it is better than 😅 cs if(!HasSingleton<T>()) return;

mint iron
#

yeah you're probably right 😄

wary anchor
#

so you'd still create a singleton entity for an event (that contains data) used as a message?

#

And if so... how 😄

warped trail
#

or this codecs if(m_Query.CalculateEntityCount()<=0) return; 😅

coarse turtle
#

@wary anchor so this is something I've done as an entire messaging system before (tho I don't really like the whole singleton entity call cause it completes all the jobs)

// Messaging Processing System
Do some logic with the message entity (can be a singleton)

// Consumer System
CmdBuffer.DestroyEntity(some_query);

// Producer System
CmdBuffer.CreateEntity(some_archetype);
wary anchor
#

so if I were to convert my player entity to an ECS Singleton, would its components still be picked up in other systems processing eg Translations etc?

warped trail
#

Singlton Entity is just an entity with 1 component😅

wary anchor
#

oh right so it's not a single match for a whole archetype

#

hmm that's less helpful

warped trail
wary anchor
#

yeah I read that several times tbh I didn't get it

warped trail
#

i guess you can have a lot of components in 1 entity and it will count as a lot of singlton entities🤔

mint iron
#

i wanna see someone put like 500 components on a singleton entity

wary anchor
#

then at that point I might as well just pass a reference to my entity around and have done with it... it just doesn't seem like a good fit for the purpose.

gusty comet
#

Ok

#

i wanna see someone put like 500 components on a singleton entity
@mint iron

#

You wanted this

#

😀

vagrant surge
#

its not really a good idea. Singleton contexts are much better implemented as a separated thing from normal entities

#

on my self-rolled ecs, i have singleton components as a special case, with its own syntax. its stored different from normal entities

gusty comet
#

:O

vagrant surge
#

basically a hashmap of key = componentHash, and value = pointer to the thingy

gusty comet
#

🤔

coarse turtle
#

is the hashmap kind of like this static instance that you can grab from anywhere?

vagrant surge
#

yup

mint iron
#

i agree it doesn't really make sense to have so much overhead if there truly is only 1 entity and you're throwing exceptions when thats not true. In Unity ECS you could just lock the chunk and go directly to the component pointer.

vagrant surge
#

specially important in an ecs like unity, where component structs have a lot of constraints

#

@mint iron and you are allocating one entire chunk per singleton, which is just not smart

coarse turtle
#

yea - and we can't control the chunk size yet 🤔

vagrant surge
#

this sort of singleton components are quite critical to an ECS architecture

#

its where you store the system data

#

and how you communicate beetween systems

#

for example, a octree system that writes into a Octree singleton

#

or a logger that has a queue inside

warped trail
#

but if you store 500 components on a singleton entity it will be stored in 1 chunk? 😅

vagrant surge
#

might not fit @warped trail

mint iron
#

i still have no elegant solution for getting configuration data into my jobs/systems. I originally went with MBs in prefabs being converted to create singletons (lol), because it let me easily configure the data in the Editor and pass them around as a resusable package (addressables etc). But now that they're saying they have no intention for users to leverage the conversion workflow or support that effort, and SubScenes just complicates things further, im left again wondering what to do.

wary anchor
#

I don't understand this compiler error - I thought I was assigning the field to a local outside of the lambda expression, how am I not?
AIHomingSystem.cs(45,5): error DC0001: Entities.ForEach Lambda expression uses field 'settingsStorageSystem'. Either assign the field to a local outside of the lambda expression and use that instead, or use .WithoutBurst() and .Run()
corresponding code (warts and all)
https://hatebin.com/tmscuprzpa

opaque ledge
#

get a local variable of it in OnUpdate method

#

like var localSettings = settingsStorageSystem

#

then use localSettings

wary anchor
#
float HomingRangeSq = settingsStorageSystem.AISettings.AIHomingRangeSq;
bool godModeCheat = settingsStorageSystem.AISettings.IgnoreAIGameFailCondition;

so I have to split that up even further?!

coarse turtle
#

You have to replace that call to the settingsStorageSystem with a local variable

wary anchor
#

OH JESUS CHRIST lol

#

thank you

#

how did I not see that FML

mint iron
#

yeah... its a bit nasty, i hope they improve it, they actually copy data back now into the inputs (at least for Job.WithCode.Run()), so it has to be local or pinned.

wary anchor
#

yeah that needs refactoring too

#

cheers @coarse turtle

coarse turtle
#

@mint iron I think you could still use subscenes for the authoring the data part. I've been tinkering with that feature lately - but I wrote a conversion system for a few monobehaviours that just convert the mb to the entities for the settings I needed in my game

#

haven't figured how to handle referenced based objects yet tho 🤔

mint iron
#

i might just go back to my scriptableobjects prototype and see if i cant get something reasonable working

wary anchor
#

I'm using SOs for my data handling in this, seems to work pretty well

#

also means I can vary shader inputs on the fly which is handy for the raymarching side of things

wary anchor
#

okay now I'm confused.

If I try to get the Translation component from my player (a regular entity with a bunch of different components) so that I can use the position as an input for my AI job, I'm generating a NativeArray<Translation> using entityQuery.ToComponentDataArrayAsync, and I'm using the out JobHandle as a dependency of the AI job: .Schedule(translationHandle)
But I need to dispose of the array, so I figured, okay I can use nativeArray.Dispose(Dependency) to make the disposal dependent on the job having been completed...
but then it's complaining that I need to add the lambda job as a dependency of (then the message cuts out helpfully). What am I missing here?

#

ahha

#

I combined the dependencies

#
JobHandle lambdaHandle = Entities
  .WithAll<AITag>()
...
  .ScheduleParallel(translationHandle);
Dependency = JobHandle.CombineDependencies(lambdaHandle, Dependency);
endSimulationECBSystem.AddJobHandleForProducer(Dependency);
PlayerPositions.Dispose(Dependency);

that seems to work, I hope I'm doing this right :/

mint iron
#

is the job an Entities.ForEach or Jobs.WithCode ?

wary anchor
#

ForEach

mint iron
#

hmmm, i thought those were auto wired up to the Dependency handle

wary anchor
#

Apparently not :/

#

nope, you need to get the Handle out of it if you use .Schedule(otherDependency); by the look of things

warped trail
#

this will be auto wired up cs Entities.ForEach().ScheduleParallel() this will not cs Entities.ForEach().ScheduleParallel(jobhandle)

digital kestrel
#

I scheduled a foreach job in my SystemBase class

#

but i can't find it in the profiler

#

i know it's running

#

is there anyway to search for it?

warped trail
#

give it a name?

digital kestrel
#

i did

#

nvm i found a search bar in the profiler in hierarchy mode

coarse turtle
#

@wary anchor there's an extension to the ForEach api like WithDisposeOnJobCompletion or something to that effect - so you could pass your native array like that

wary anchor
#

ooo that'd save a few lines thanks @coarse turtle will have a gander

#

.WithDeallocateOnJobCompletion(PlayerPositions) beauty!

opaque ledge
stable fog
#

oooh, maybe I'll give it another go

coarse turtle
#

I wonder how their event node works

#

🤔

stable fog
#

@digital scarab sounds to me like ya'll need to communicate better :p

mint iron
#

we need a reason to keep you coming back.

wary anchor
#

if it takes some stupid questions being asked, I am not afraid! 🙂

#

Just to prove it, look, I found out if you name systems alphabetically, they no longer get put into the correct order, so you have to not be a lazy roo and set up your UpdateAfter() attributes properly 😄

formal scaffold
#

Hey is this visiualization and my understanding of collisons in Unity.Physics correct? I know there must be more that's happening in the background. I am more intereseted in the two collisions

warped trail
#

my bet that there will be just 1 collision with 2 contact points 😅

formal scaffold
#

Assuming I hit the perfect middle, the normal should be 45° then? Assuming you are correct 🤔

warped trail
#

normal of what?

formal scaffold
#

The normal of the CollisionEvent. It's usually perpendicular to the surface

warped trail
#

45° is not perpendicular 😅

formal scaffold
#

If you multiply the normal of "Wall1" with the normal of "Wall2" you get an new vector that is 45° from either wall, the exact middle

#

I don't think so, if I move against just a single wall at an angle that is less than 90° I slide along the wall. If the normal was perpendicular to my velocity I would stop sliding I think. I think that the build in Unity Physics system does that tho 🤔 could be wrong

wary anchor
#

What's the equivalent for [ReadOnly] for things like NativeArrays and the usual blittable types that were in the JobComponentSystem structs?

dull copper
#

@digital scarab I used to poll bintray along with other things I follow but since they Unity has changed the registry to different location now, 2020 packages will not show up there anymore

#

there's also a way to query for npn packages through some node.js tool, I used it once to browse Unity bintray but can't remember which tool it was and how it was used to do that 😄

#

I actually tried to search for it the other day but no luck so far and I can't even remember who showed it to me in the first place 😄

#

yes

#

I didn't know the new url tho 😄

#

I saw the IP address but didn't know the packages were at root

#

the issue with that is that it doesn't actually list the new packages. having bintray list all new packages was a great way to discover new things before there were forum posts etc

#

anyway, thanks for the link, I'll see what I can do with it

verbal pewter
#

Hey all, been away from DOTS since 0.5 and we're already on 0.8 😄 Is there somewhere to see the main changes that have happened with each release?

coarse turtle
#

the changelog in the packages give you a good summary

#

package should be pinned so you can just click that and view the changelog on the page

verbal pewter
#

Ahhh duh, ya. Thanks!

fallow mason
#

thought I was being clever adding a using to clear up one error I had with Graph Tools Foundation

#

just recompiled and now I have 256 errors! 🤣

opaque ledge
#

lol

#

has anyone managed to try out drop 8 without any issues, if so i would like to try it as well 😄

fallow mason
#

restarting the editor cleared up the errors. now to actually test it 🙂

safe lintel
#

600 errors for me 😀

fallow mason
#

yeah, I went back to undo the change I made (just in case it ended up being unnecessary) and now I have 689 errors...

#

alright, back to the error I got at first: Packages\com.unity.graphtools.foundation.overdrive\Editor\CodeViewer\Elements\DocumentContainer.cs(136,50): error CS0308: The non-generic type 'IEnumerable' cannot be used with type arguments

#

I added using System.Collections.Generic to that file, closed editor, deleted PackageCache, and started the editor.

safe lintel
#

im gonna try this in 19.3 instead of 2020

zenith wyvern
#

Seems to work in 2020 after you add the using and restart the editor like DROD says

fallow mason
#

yeah, though it may be the version as the first error comes on a line enabled by 2020 preprocessor directive

safe lintel
#

actually yeah, two errors but i believe its just the editor(😉 ), none regarding the packages

#

good old multicast group error, greeting me at every start