#archived-dots

1 messages Β· Page 220 of 1

boreal bobcat
#

I tried disabling the safety checks of burst but that didn't work...

ocean tundra
#

yea my guess would have been safty checks

boreal bobcat
#

Unless I'm missing somewhere else?

ocean tundra
#

looks right to me

#

close and reopen? πŸ˜›

boreal bobcat
#

one sec

#

nope, same thing

ocean tundra
#

😦

#

not sure sorry

boreal bobcat
#

np, thanks for trying :)

karmic basin
# boreal bobcat

What is happening here, you're supposed to see some toggle-able "leak detection" option πŸ‘€ Unless it's DOTS-only

#

DisposeSentinel is used to track memory leaks

#

so yeah your nativecontainer registers itself to it in the editor run

#

πŸ€” this should come with the Collections package, right ?

#

Maybe you need some combination of Collections, Jobs, Burst and Entities to see it appearing πŸ€·β€β™‚οΈ

#

Do you have the ENABLE_UNITY_COLLECTIONS_CHECKS define ?

#

I mean can you remove it ?

slow iron
#

Is there a simple way to pause physics bodies like how you can set rigidbody.iskinematic = true in gameobject world?

#

right now I set velocity to zero, but then rotation keeps going, I could just cache rotation I suppose but I figured there was an easier way?

slow iron
#

so physicsMass.InverseInertia = float3.zero; seems to work but I get odd behavior when spawning objects

void girder
#

How are people handling unmanaged shared component data? It's been confirmed to be implemented in a future DOTs releases, but do people have a solution of sharing frequently changed data between entities?

boreal bobcat
# karmic basin I mean can you remove it ?

Hi, so, I installed the Jobs package and the leak detection thingy you mentioned appeared so I turned it off and boom, the overhead is gone! It was apparently in Full Stack Traces mode... Thank you very much!

robust scaffold
slow iron
#

Thank you @karmic basin that is very helpful! I ended up using stepPhysicsWorld.Enabled = false; which adds some lag so removing the physics component per object may perform better

karmic basin
# slow iron Thank you <@!317274156578111488> that is very helpful! I ended up using ```stepP...

I wouldnt remove the PhysicsVelocity component as it would indeed result in structural changes. Unless you know the entity won't move anymore until the end of the sim. The physicsMassOverride override is great, because you can keep components that make your entity dynamic physics-wise, but just basically increase mass to infinite-ish, thus forcing them to be static through massive inertia

#

then you can toggle back, and you never mutated the archetype

slow iron
#

ahh I guess I'll stick with this method then. Now figuring out how to store the velocity so it stays on resume

bright sentinel
slow iron
#

I did try physicsMassOverride and I could not get it to work lol

#

When resuming the physics sim, I can tell it has a hard time calculating and hangs for a second if there's too much going on. While it's totally fine If I use something like setting InverseInertia to 0'

karmic basin
slow iron
#

Yeah the problem is 99% solved thank you for all the help. for a package still in preview and minimal documentation it works pretty well

karmic basin
jaunty herald
#

Anyone ever get this error?

Burst error BC1042: The managed class type `Unity.Collections.NativeQueueBlockPoolData*` is not supported. Loading from a non-readonly static field `Unity.Collections.NativeQueueBlockPool.pData` is not supported
#

I get this when trying to create a NativeQueue with an Allocator.Temp inside a burst compiled job

#

Alright, it seems you can't create queues inside jobs for some reason 🀷

#

I feel like the error could be a bit clearer on that.

jaunty herald
#

Are there any useful workarounds to handling stuff like Action inside a job?

#

I'm trying to think of a system that makes handling ScriptableObjects data / functions inside jobs easier, but I'm not sure how to go about it..

coarse turtle
#

BurstFunctionPointers?

jaunty herald
#

That's a thing?

jaunty herald
#

What if the job isn't burst compiled?

coarse turtle
#

it'd probably still work - maybe not in the same ideal sense

jaunty herald
#

Still seems very useful, thanks. Didn't know about it

#

I feel like I could encapsulate a lot of my data stored in ScriptableObjects inside structs to make them accessible in jobs, but that becomes a problem once I need a list / array inside that struct...

#

Since afaik you can't serialize native collections

coarse turtle
#

Well if possible, you can always pin your array

#
int[] arr = new int[5];

// Fill in array with some function
...

// Remember to free the GCHandle when you don't need it anymore
var arrHandle = GCHandle.Alloc(arr, GCHandleType.Pinned);
unsafe {
  int* head = (int*)arrHandle.AddressOfPinnedObject().ToPointer();
  // Pass the head ptr to your job
  var job = new SomeJob {
    Ptr = head,
    Length = arr.Length
  }
}
jaunty herald
#

Hmm, interesting, but it seems like a lot of boilerplate. I feel like it makes more sense to just handle scriptable object stuff outside of a job

#

I'll keep it in mind though, thanks

coarse turtle
#

The fixed statement is also somewhat convenient if it fits your need too

jaunty herald
#

I think my greater issue is actually the way I have some of these scriptable objects set up, they use a lot of class-only stuff like inheritance

#

It seems like that would be impossible to achieve with jobs, since there is no such thing as a non-nullable interface

#

Which makes sense since the storage size couldn't be known ahead of time

robust scaffold
#

Fun with unity. Yet another week passes with no news of 0.18.

bright sentinel
#

@robust scaffold Does the editor logs tell you anything as to why?

#

Also make sure to press that report button whenever there's a crash

sage mulch
#

Are there any good resources for unit testing using DOTS/ECS?

bright sentinel
#

@sage mulch I'd recommend taking a look in the package source tests, they have pretty good coverage

#

Entities, Physics, NetCode etc all have unit tests

deft stump
#

for Tiny, I don't need hybrid renderer right?

warped trail
#

Tiny uses it own rendering

jaunty herald
#

Can you use a System.Guid in a component data?

#

Or is that not a good idea

#

My issue is I need to save something inside a component data to reference a guid for the addressables system. I'm currently using Bytes16, but converting it to a string is slow, and it's hard to cache in a dictionary since Bytes16 has no gethashcode implementation, and defaults to reflection

mint iron
#

Not sure if it will burst compile but even if it does its a pretty large footprint and would pull in sorts of .net cruft, environment static methods, culture stuff. Maybe make a stripped down version or just use a CRC32-esque int id.

mint iron
#

if you want to just store the existing addressables id as an actual string in there for viewing in the entity debugger or whatever, you could also use a NativeString

robust scaffold
karmic basin
#

I have more crashes than ever since switching to DOTS πŸ™ƒ

robust scaffold
remote crater
#

I have a question: How do I use monobehavior to instantiate a gameObject into an Entity? This old Codemonkey example doesn't work since dstManager is gone: https://hatebin.com/nvtorrktfh

#

I found one way to induce a crash is to copy/paste assets into the assets folder while unity is open.

#

If you gotta chuck some assets in like that, always close unity first.

#

I'm talking via windows.

karmic basin
#

dstManager is not deprecated, it's the EntityManager of the destination (dst) world

remote crater
#

Wow Awesome Mr.K, so it wasn't just me being dumb, itw as a thing

remote crater
#

Ok, after reading: https://docs.unity3d.com/Packages/c...html#the-iconvertgameobjecttoentity-interface

I got this error on my attempt at understanding the tech: https://hatebin.com/trzkpmmoeo

I always look at programming like being able to tell time. It is easy, anyone trained can do it. But go ahead and try to figure out to set a clock on your new Toyota. You can't understand what the engineers were thinking. So you need to find someone to help you set the clock then you're good to go, you can tell time again. This is what techs are like.

remote crater
#

Assets\Scripts\DOTS\PrefabEntities.cs(9,46): error CS0535: 'PrefabEntities' does not implement interface member 'IConvertGameObjectToEntity.Convert(Entity, EntityManager, GameObjectConversionSystem)'

craggy orbit
#

if you create a new authoring script from the Create menu, it should give you a working example.

using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

[DisallowMultipleComponent]
public class AuthoringScript : MonoBehaviour, IConvertGameObjectToEntity
{
    // Add fields to your component here. Remember that:
    // * The purpose of this class is to store data for authoring purposes - it is not for use while the game is
    //   running.
    // * Traditional Unity serialization rules apply: fields must be public or marked with [SerializeField], and
    //   must be one of the supported types.
    // For example,
    //    public float scale;

    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        // Call methods on 'dstManager' to create runtime components on 'entity' here. Remember that:
        // * You can add more than one component to the entity. It's also OK to not add any at all.
        // * If you want to create more than one entity from the data in this class, use the 'conversionSystem'
        //   to do it, instead of adding entities through 'dstManager' directly.
        // For example,
        //   dstManager.AddComponentData(entity, new Unity.Transforms.Scale { Value = scale });
    }
}
remote crater
#

THANKS RYAN!

craggy orbit
#

new DOTS updates incoming? πŸ€” quick PSA: don't update Collections. it breaks the Entities packages

karmic basin
#

Maybe ... Collections are relevant without Entities, so who knows πŸ€·β€β™‚οΈ

craggy orbit
#

i thought they normally updated around the same time, but yeah i guess it is completely unpredictable 🀷

frail seal
#

Could someone remind me how Any and All querying are useful in practice?

#

I'm making an ecs library for use outside of Unity

#

So I kinda forgot how it all works

deft stump
#

think of Any as an OR statement.
think of All as the AND statement.

frail seal
#

Actually, nevermind, finally figured stuff out from examples

#

They were a bit hard to find

minor sapphire
safe lintel
#

New updates would be nice πŸ˜‰

jaunty herald
#

Anyone have an idea where I can find the Bytes16 implementation?

#

Says it's in Unity.Collections but I can't seem to find it

warped trail
#

@jaunty heraldNativeString.gen.cs

jaunty herald
#

Thanks @warped trail !

proper silo
#

Hello! WHat is the most efficient way to check if an Entity has a specific component from a MonoBehavior?

pliant pike
#

enititymanager.hascomponent<>()

proper silo
#

Oh ok as simple as that, thank you!

remote crater
#

I think I'm asking the wrong question... People are telling me how to access an entity after converted from GameObject. I want to know how to convert a GameObject TO an Entity, not collect Entity data after that happened.

#

I don't even care if I get an entity reference, I can do that elsewhere.

#

I just want to take a GameObject and put it into the world exactly as is as an entity.

#

Via Monobehavior for now

jaunty herald
#

Hmm, I'm experiencing a strange bug(?)... When I try to deserialize my world using SerializeUtility.DeserializeWorld(ExclusiveEntityTransaction, StreamReader) I get a null reference exception in GameObjectSceneManager.cs:106 thonk

robust scaffold
remote crater
#

GameBoardModel.peers[a].myShipGameObject.AddComponent<ConvertToEntity>(); //This converts and destroys an entity. How do I set the conversionMode?

#

If you add a ConvertToEntity component on a gameObject, it solves the problem of turning a gameObject into an Entity.

#

I need convert and inject however.

jaunty herald
#

I guess you could either call one of the static methods, or if ConvertToEntity does the conversion in Start and not Awake you can simply change the ConversionMode after adding it @remote crater

remote crater
#

ConversionMode is a method after <convertToEntity>().conversionMode

#

But I don't know how to set it

#

OOOH!

#

I found out how to find LOTS of good info about DOTS

#

then search keywords!

#

YOu get toooooons of samples!

#

this is awesome!

slow iron
#

The more I learn about dots the less I know about dots

remote crater
#

I can add a monobehavior script to a gameObject by addComponent, but try and add an iComponentData script to a gameObject and Unity errors out: https://hatebin.com/aczvqnqbtr

karmic basin
#

@remote crater again, your questions will be answered if you read the Conversion Workflow page on the manual. There's a lot to digest, but the value you get in learning is worth it

steel pike
#

Ok I've just recently learned about dots and how it can massively increase a game's performance. I'm pretty far into my current project and I'm curious about it. So, how hard will it be to switch over to dots from a game that has quite a lot of game systems already?

bright sentinel
remote crater
#

Mr.K, I did read it twice, and many documents like it several times, and many videos. I'm just wondering why a certain syntax does not work.

#

It lets me attach one script, but not another... It simply doesn't make any sense...

steel pike
#

If I just switched stuff like enemy pathfinding and terrain generation (since they're the bulkiest) would that be good?

#

oh and I'm making an open world 2d game if that makes sense

remote crater
#

make enemies dots

#

Make player same player controller

#

But just change according to game mode depending on input

amber flicker
remote crater
#

I actually have sample code if you want to see it.

steel pike
#

ye go ahead

remote crater
#

I wrote it custom for a guy who showed up on my stream

#

and he said it works like a charm

#

I would think it is the best code for anyone who wants to use best practices of design patterns to keep their player controller from being written in two different places

#

But you can't do it with your enemies, bullets, etc

#

You need to do the majority of the work in pure DOTS/ECS.

steel pike
#

I see

#

luckily I don't need to learn DOTS just yet cause it will be a future task of mine, but this info has helped me decide what my plan is

remote crater
#

Waiting on DOTS is a very good idea.

steel pike
#

is it not stable now?

remote crater
#

It can do a lot, but it is the opposite of user friendly

#

It is stable

#

But stuff that should be a 5 second one line of code can take days or weeks.

#

Cuz the Unity Engineers don't know proper user friendliness

#

or how to write proper documentation

steel pike
#

oh boy

#

I guess I'll be coming back here when I get to it then huh

#

is it well documented?

remote crater
#

Like you should easily, easily be able to link a gameobject being converted to an entity into another script as an entity, because indexing would remember...

#

But this task is monumentally difficult

#

Instead of just being drag and drop

#

Or...

#

My current task

#

Of trying to attach a script

#

Works for some scripts, but not all dots scripts, despite being able to attach one before run time.

#

I merely want to Instantiate an entity

#

But I'm on day 5...

#

A line of code that should take 10 sec tops

#

5 days...

steel pike
#

oh god

#

it sounds like learning how to use unity all over again

remote crater
#

Why does Unity not have a single function: Take a prefab and make an entity out of it and instantiate it?

#

The world may never know.

steel pike
#

Instantiate() ?

#

how does dots do it

remote crater
#

When you find out, let me know.

steel pike
#

lmaoo 😭

remote crater
#

Just wait on DOTS... Its functional, it works, but you need to know the arcane language of fae dragons to write it.

#

Just wait on it, do your thing, come back when they hire a technical writer for the documentation that gives use cases and samples

#

Wait on it for when things that should be one line of code aren't dozens over many scripts and race conditions.

steel pike
#

I'm sure you've already been looking stuff up, but why doesn't this work?

#

βœ… Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=pk-C_h0WJZs
Let's check out how we can build Game Object Prefabs and Convert them into Entity Prefabs that we can then Instantiate.

Unity DOTS / ECS Tutorials
https://www.youtube.com/playlist?list=PLzDRvYVwl53s40yP5RQXitbT--IRcHqba

Getting Started with ECS
https:/...

β–Ά Play video
remote crater
#

It's gonna rule. It's gonna make Unity's stock soar... But why they don't hire people who are sane to write documentation, use cases and simplify the use....

#

Nope R.

#

You're the 3rd person to link that

#

That's actually dated and no longer works.

steel pike
#

damn wtf

#

barely a year old

remote crater
#

Basically when you look for youtube tutorials, don't use anything over 1.5 years ago.

#

Stuff changes rapidly

#

This is part of the fun... a good 80% of online documentation is useless.

steel pike
#

I mean most unity tutorials that I've used worked throughout

#

though they were more conceptual rather than how to do x

remote crater
#

Were they DOTS/ECS tutorials?

steel pike
#

generally youtube tutorials work if not over 4 years old I've found

remote crater
#

Only DOTS/ECS doesn't work if its over 1 year old generally.

steel pike
#

idk anything about DOTS obviously

remote crater
#

Ok, I'm out. Tomorrow I'm going to try and just load scenes of GameObjects that convert to Entities instead of Instantiating. I bet it will work!

steel pike
#

ok

#

also I found this comment

#

not sure if that helps but don't forget to sort by new

#

you might find better results

remote crater
#

The funny thing is... if I go with this solution, I'll have 10,000s of scenes.

steel pike
#

what

#

ok I'm gonna head out as well

#

this will be something I conquer in the future

remote crater
#

Stop back in a few months. πŸ™‚

steel pike
#

what news to look forward to 😌

steel pike
remote crater
#

Just remember your player controller can be branched at every input

steel pike
#

ok

remote crater
#

It will be the only thing you keep basically

#

Other than models n stuff

#

that get converted

#

God bless, adios.

steel pike
#

adios

bright sentinel
#

@steel pike Eh, I'd like to give a bit of a different point of view. DOTS is made up of Burst, the job system, and ECS, each building on the previous. What GoodNewsJim has been speaking about is specifically ECS, which is basically an engine in and of itself, separate from GameObjects.
However, Burst and the job system is more than production ready, and it's very good. Those are the things you can already use now for the more performance heavy computations. As you said, pathfinding and terrain generation are pretty much the perfect examples of what it can do well. You don't need to create any entities to do such a thing.

warped trail
craggy orbit
#

Hybrid Renderer v0.11-pre43 out today πŸ€”

frosty siren
#

i want read changelog but can't find Hybrid Renderer package anywhere

craggy orbit
#

no changelog yet

frosty siren
#

can't see in package manager, can't find in package list in Unity Documentation. What a stupid mess with visability

robust scaffold
craggy orbit
#

i thought it was pre42 before?

robust scaffold
robust scaffold
craggy orbit
#

nope

robust scaffold
#

Then again, I've been typing the package and versions manually into the package json. Hrm

frosty siren
deft stump
#

it's a good sign

#

0.18 is almost there

viral sonnet
#

aren't they internally already at 0.21?

safe lintel
#

ill believe it when I see it πŸ˜‰

#

no changelog for .43 😎

robust scaffold
#

For 2021, the focus is to make Hybrid Renderer ready for shipping applications on a broad range of devices. To help with this, the plan is to establish automated testing for mobile and console platforms.
For fucks sake unity. HR doesnt even work well for PC. Now they're focusing on pumping it out to consoles?

safe lintel
#

odd they are still updating docs with mention for v1 limitations, imo should just drop it like a hot potato

robust scaffold
#

V1 is surprisingly well optimized. And built in renderer is the most efficient for mobile.

safe lintel
#

its not in dev and isnt supported going forward, wont receive bugfixes. why even bother? the scripting define should be ENABLE_HYBRID_V1

#

pretty sure it came out back when entity queries were like using [Inject] on the component struct groups, its ancient

robust scaffold
#

And it was downhill from there

karmic basin
#

πŸ˜… πŸ• 😡 πŸ’€

mortal gyro
#

is there any way to treat a job as if 'ENABLE_UNITY_COLLECTIONS_CHECKS' was always disabled? DisableSafetyChecks = true is close, but AtomicSafetyHandle access is still checked unless the drop down in the editor is manually disabled

#

I want a job to always act like that is set to Off, including AtomicSafetyHandle access

nova adder
#

any help :v

gusty comet
#

I'm currently a bit new to dots, I did try getting into it a year or so earlier but it was very buggy and no tutorials were out there at the time, so I left it

#

Are there any new resources that you guys recommend?

#

Except for the best practices guide(I've already read through it)

#

I'm struggling to find a comprehensive documentation for the ECS systems

#

I found a udemy course but it feels like dots has changed a lot and those aren't the best practices anymore

safe lintel
#

imo best way to learn is make a simple project, theres not more comprehensive doc than whats in the pinned messages(also id ignore the top dots wiki, its also old). docs have improved in the past year so may want to revisit them

#

the samples are also a little more encompassing

viral sonnet
amber flicker
viral sonnet
#

EM is fine if you create a flat hierarchy. If you create a relation between entities and don't spread it over frames the design starts to break.

amber flicker
#

That’s not been my exp. you may want to give a specific example of what you’re trying to accomplish.

viral sonnet
#

i have a set of entities on a grid which get processed to form a path with a linkedlist, this path then gets translated into an optimized and merged path entity. the linkedlist is inside a dictionary with its own id and doesn't fit into ecs that well. this is all fine but updating paths start to be a problem because i don't have any references from the entity path to the linkedlist.

#

which would mean i have to store the linkedlist or some form of reference also in ECS, everything stems from the problem that ECB doesn't return a valid entity id and I'm pretty tired of working around it

nova adder
#

use BlobAssetReference if you have to reference unchanging managed data

nova adder
remote crater
#

ConvertAndInjectGameObject leaves a clone of an Entity and a GameObject. Someone tell me at least one of them has a reference to the other. This is basic design patterns stuff right? I should expect to be able to reference each of them from the other one, or at least the GameObject remembering it, rite? Hey, if it isn't in the official unity code, I could extend a weird system class to do this like convertandinject or something?

amber flicker
# viral sonnet i have a set of entities on a grid which get processed to form a path with a lin...

A couple of thoughts. Are you sure a NativeArray is slower than your linked list? Then you could simple store an index to the element to update? All instantiating with an ECB does is defer instantiation to a certain sync point. If having valid id's would simplify a bunch of infrastructure for you, why not just instantiate at that sync point with EM where upon it will give you the valid entities?

pulsar jay
#

How do you handle global game states/phases in ecs? Sometimes you have the same entities but different systems should run depending on the situation. Chess for example would require one/multiple systems to select and move its pieces - but only when its your turn.

#

I was thinking about using system groups and let them handle if their child system should run but this might lead to sorting problems and does not help with systems that need to run in both states but do sth different

#

I could also enable/disable the system from another system that handles the states/phases but than it would have to know about all the systems it has to toggle

remote crater
#

just have another icomponentdata script, and put it in there.

pulsar jay
#

but that would mean that each system would be required to have look for this component and read its data before doing anything else

#

I was thinking about using singleton compoenents so I could use RequireSingleton in a system to decide if it should run

amber flicker
# pulsar jay How do you handle global game states/phases in ecs? Sometimes you have the same ...

I think it's quite core to the paradigm to in general have a system run, whenever data of a certain pattern exists. Rather than e.g. enabling/disabling systems. In the case of chess pieces, I might have all p1 pieces have a SharedComponent with Player1, and all p2 pieces with a Player2 SharedComponent. Then your system would filter which entities it runs over by filtering on the current player.

#

The current player could be an ICD on a singleton for instance.

pulsar jay
# amber flicker I think it's quite core to the paradigm to in general have a system run, wheneve...

In the case of the chess game I could see how this would work. Maybe a better example for a global state change would be pausing the game. As this should stop interaction with all entities it would make sense to disable the system that handles the mouse raycasts. Adding a SharedComponent to all interactable entities so they arent interactable anymore would be a bit wierd. And you would also have to disable camera movement and e.g. tell the music system to play a different song or turn down volume etc.

#

If its a state change that effects so many different entities and components it feels weird to attach a component to all of them and having to check for it in each effected system πŸ€”

amber flicker
#

I'd say pausing is kind of worst case because it touches so many systems - I'd be careful of generalising that to 'any global state change'. Your systems should do what they do, based on presence of data. If particles spawn when a spawner exists, add a disabled tag or remove the spawning entity when you don't want it to spawn. Whatever you do, when you pause the music system is not going to magically know it should change track. Depending on how it's built, an EnablePause system could e.g. change the ActiveTrack ICD that the music system uses a DidChange check to observe.

pulsar jay
amber flicker
karmic basin
# remote crater ConvertAndInjectGameObject leaves a clone of an Entity and a GameObject. Someone...

When you convert and inject, Unity allows you to keep legacy Component Objects from the Unity engine that are not yet available in DOTS (i.e. lights, the Shuriken Particle System, the Mechanim Animator, to name a few). When switching to ECS, they become hybrid components by using AddHybridComponent(). They are attached to an hidden gameobject, which is called a companion gameobject. There's an ECS transform system provided by Unity which will keep the companion gameobject transform in sync with the entity. So if you take for example a particle system attached to an authored spaceship engine companion gameobject, it will follow the converted engine entity that you moved from let's say your ECS MovementSystem.
But you're not supposed to consider the link between the companion gameobject and the entity starting from the companion gameobject towards the entity. Rather it's a one-way link from the entity towards the companion gameobject.

#

Cherry on top, ConvertToEntity component is not recommended as it doesn't get anymore support and will be deprecated in the future. You can still use it if that works for you but it doesn't scale well for a lot of GO/entities. You're supposed to use subscenes at some point later.

#

with one of the conversion systems I linked you earlier

karmic basin
#

I don't remember if the discussion ended up with a conclusion on a better approach, I need to read it again ^^

amber flicker
#

I think mostly the concern would be that it scales poorly and that state becomes somewhat implicit. E.g. what happens when you have a 'application lost focus' that you want to behave differently from pause, and so on.

pulsar jay
karmic basin
#

Yeah I wouldnt go by using systemgroups for that

pulsar jay
#

Would be nice to have some kind of tags (e.g. attributes) to filter for systems so you could just use GetSystemsWithAttribute or GetSystemsWithTag and toggle them

karmic basin
#

Like Timboc said, systems are meant to always be there and run

#

IIRC SystemBase has an Enabled flag but I never used it

frosty siren
pliant pike
#

yeah same I use enabled all the time for debugging

#

I wish there was an easier way to turn on and off systems though, before run time

karmic basin
#

Good to know that works well :) Was more for @pulsar jay but I.m curious, is it toggleable at runtime ? I see Unity is using it onUpdate()

pulsar jay
pliant pike
#

but that's more work

#

and what if I want to create a new scene where I'm creating and testing new systems

#

at least with gameobjects it's unambiguous and clear what is running, but with systems I have to search the list and find my systems in among all the standard unity systems then figure out how to disable them if they interfere with what I'm currently doing

karmic basin
#

COuld be relevant to put them in a testing World then ?

amber flicker
# pliant pike and what if I want to create a new scene where I'm creating and testing new syst...

I agree about this. Fwiw to mitigate this, the pattern I use for the examples in my asset is [DisableAutoCreation] followed by a monobehaviour that initializes in the scene e.g.:

    {
        var bobSystem = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<Example2_BobbingSystem>();
        World.DefaultGameObjectInjectionWorld.GetExistingSystem<SimulationSystemGroup>().AddSystemToUpdateList(bobSystem);
}```
pliant pike
#

interesting πŸ€” I guess I should try something like that, thanks @amber flicker

gusty comet
#

theres something wrong with dots frustrum culling

#

basically it doesnt work, or works a little

#

only removing invisible entities helped

#

with cpu,gpu and fps

#

(the ones that had rendermesh)

#

its like theyre rendered despite being invisible/outside frustrum

#

of course i had shadows turned off, and lights even

amber flicker
gusty comet
#

no im using v1

#

bounds are made automatically

craggy orbit
safe lintel
#

well a certain dev alluded to it going away at some point in favor of entire scene conversion, but imo at the glacial rate of things id say theres really no worry of it vanishing without a lot of advance notice. componentsystems and jobcomponentsystems are technically on their way out too but theyve stuck around for a long time and still are not yet marked obsolete.

bright sentinel
safe lintel
#

I think if you can use subscenes, definitely use them though.

bright sentinel
craggy orbit
#

yeah i've been using subscenes for a while now, only using ConvertToEntity for quick testing

gusty comet
remote crater
#

Mr.K, You say: "Rather it's a one-way link from the entity towards the companion gameobject." Is there a way to access this link, because that is all I need to get the reverse link manually. Then I manually destroy the gameObject myself.

remote crater
#

Lets say... I have my array of entities. Lets say I have a specific entity say myEntity.... What is the syntax to get the gameObject reference from this myEntity?

amber flicker
# gusty comet no im using v1

I think you should add that to your forum post. In particular HRv2 adds different types of culling. Stick with old stuff, gotta deal with old feature set.

remote crater
#

Ok, I got it

#

It lets you store references to entities you made in monobehavior after you instantiate a gameObject into an Entity. Ok, super cool

#

It is something that should have taken 6 seconds instead of 6 days, but hey, I'm just happy DOTS/ECS even exists, Unity Stock is going to skyrocket next 2 years.

ocean tundra
#

@remote crater Are you sure that works?

#

Pretty sure the ENtity provided in the IConvert interface is the conversion entity

#

NOT the final entity after the subscene loads

#

try conversionSystem.GetPrimaryEntity or something like that

#

but also i cant see how that would work if your subscene entities get remapped
eg you load scene 1 with 5 entitys, then scene 2 with another 5, so the 2nd set get remapped so indexs start at 5

#

You should move where you assign the entity into a normal system, and attach entityRef as a hybrid component in the IConvert

sage mulch
#

Is there a suggested way to handle input using DOTS? I'm interested in utilizing the newer InputSystem, but I'm having trouble finding examples of how to use it with ECS.

slim nebula
#

inputMaster.Player.HorizontalMovement.ReadValue<Vector2>();

#

for example

sage mulch
#

thank you!

jaunty herald
#

What is the optimal way to create an entity in a job and add it as a reference to another component?

#

Since using an ECB the index will still be -1 until you do Playback()

bright sentinel
#

@jaunty herald Use an ECB to do both

#

The ECB will have the correct reference

jaunty herald
#

Will it remap the indices?

bright sentinel
#

It will just have the correct value at playback

jaunty herald
#

Alright, ill try that, thanks.

bright sentinel
#

If you use ecb.CreateEntity/Instantiate and then ecb.SetComponent

jaunty herald
#

Once issue I have with ECBs is that they don't let you fetch overwritten state. I usually work around this by caching it in a hashmap and then running all ECB functions at the end of the job. Is there a better way?

bright sentinel
#

No unfortunately not :/ Been dealing with the same issue with deleting entities that an ECB wants to access after

jaunty herald
#

Yeah, I wish they let you use e.g. EntityCommandBuffer.GetComponent to get the state last state written to the ecb for that entity

bright sentinel
#

Perhaps

jaunty herald
#

Btw, does Entities.ForEach process entities according to their index? Or is that not something that can be relied upon

jaunty herald
#

Yeah

bright sentinel
#

Nah, can't rely on ordering

jaunty herald
#

πŸ‘

#

Probably not a good idea even if it was consistent

bright sentinel
#

Also seems like a bit bad design to have

jaunty herald
#

Yep, that's what I mean

bright sentinel
#

Ah right πŸ˜„

jaunty herald
#

I was wondering about having a system that initializes a component to some procedural state, and wondering if I could use a single math.random throughout the Entities.ForEach to initialize the client and server state to the same thing. But I think having a seed / index in the component and using that is cleaner.

#

Since if the order was consistent the PRNG would yield the same output

bright sentinel
#

It should be, you'd still have to sync the seed

jaunty herald
#

The seed should (hopefully) already be the same, another deterministic algorithm decides it

bright sentinel
#

But how would you make sure they both have the same seed if you don't sync anything? πŸ˜„

jaunty herald
#

It syncs the world seed, and then goes from there. So I guess there is a seed that needs to be synchronized πŸ˜‰

bright sentinel
#

Gotcha πŸ˜‰

jaunty herald
#

That world seed is then used for everything

bright sentinel
#

Makes sense to me

jaunty herald
#

One thing I really struggle with is converting scriptable object settings classes to be usable in ecs, since these classes are usually abstract

#

Not sure how to deal with that with structs

#

Maybe monolithic structs instead of many classes with inheritance could work, but there is still the issues of arrays in configuration objects

jaunty herald
#

If I schedule a Job.WithCode is the correct jobhandle this.Dependency ? (this is inside a SystemBase)

remote crater
#

I'm trying to pass position/rotation/velocity via a string. And so far only I have been able to do position successfully: https://hatebin.com/knqmniahaq

#

RoyCon, 100% works

ocean tundra
#

@remote crater Are you using subscenes or convert and inject?

remote crater
#

Roycon, do you need my help? Cuz I no longer need help on this.

#

What I need help on is this: https://hatebin.com/knqmniahaq TL:DR How do I take one Entity's rotation and velocity and pass it by string then establish it in another Entity?

marsh cave
#

Hello, i have a question about ECS, or maybe it's c# in general... I want to make an scriptableobject based editor which lets me configure Abilities. Those scriptable objects are basically just components which will added to the entity. And there goes my problem, i don't know how to add the component when i don't know what type of component it is at build time.

public interface IFoo : IComponentData { }

public struct FooHealth : IFoo
{
    public float Value;
}

public class FooSO : ScriptableObject
{
    public List<IFoo> myFoos;
}


public static class FooManager
{
    public static Entity CreateFoo(FooSO scriptableFoo)
    {
        EntityManager manager = World.DefaultGameObjectInjectionWorld.EntityManager;
        Entity entity = manager.CreateEntity();

        foreach (var foo in scriptableFoo.myFoos)
        {
            //How do i do this?
            manager.AddComponentData(entity, new foo { });
        }

        return entity;
    }
}
gusty comet
#

combinish a mesh and adding it to entity renders it in wrong place, anyone knows?

#

i think it has to do with renderbounds.center but mb not

karmic basin
karmic basin
#

Your way of passing values through strings is weird, it is some kind of serialization over the network maybe

karmic basin
#

Maybe try setting with EulerZXY to keep same order, don't know I don't mess with rotations if I don't have to (they give me headaches).

karmic basin
#

But yeah that works well so if you're version-locked and/or small project nothing wrong here

gusty comet
#

whaat

#

im using converthierarchy

#

scenes are not good for worlds that move

karmic basin
gusty comet
#

Lul

karmic basin
gusty comet
#

maybe its not even related to it idk

karmic basin
#

Didnt we talked about that already ? You have cubes in contact, right ? The RenderMesh has a bounds property too, should be more accurate

gusty comet
#

i dont think we did

#

my issue is probably related to mesh combining

karmic basin
#

Ok I might confused with another situation

marsh cave
karmic basin
#

Right πŸ™‚

quiet swallow
#

How to add a rotation constraint on every axis to a PhysicsBody? I've read somewhere that PhysicsJoint might solve this. But it's not clear how should I use it, since it requires two entities. Anyone has an idea?

karmic basin
marsh cave
karmic basin
quiet swallow
# karmic basin The physics samples show examples if I remember well

Couldn't find anything useful there tbh. Did this hack instead.
private void FreezeRotation(Entity entity) { PhysicsMass physicsMassComponent = EntityManager.GetComponentData<PhysicsMass>(entity); physicsMassComponent.InverseInertia = new float3(0f, 0f, 0f); EntityManager.SetComponentData(entity, physicsMassComponent); }

But I also need to freeze the body on Y direction..

karmic basin
#

They have a component in the samples

quiet swallow
karmic basin
#

they do a bunch of custom implementation with the physics, I guess you'll have to prepare to retro-engineer a bit some of their work

quiet swallow
karmic basin
#

Yeah from what I see it looks like you create a joint entity and add a constrained body pair component to it

#

When you move the main one, the other doesnt follow ?

quiet swallow
#

Well, what I want to achieve is to move the main one via adding impulse, but freeze the rotation and Y axis movement. So if it somehow interacts with the environment, only X and Z values are changed.
Whole purpose of having the other entity to my understanding is to make the joint work. But that other entity should also have PhysicsBody into it and problem will still remain πŸ™‚

I guess I'll stick with the hacky solution for now, and then will take another look at it later.

karmic basin
#

Oh you want only 1 body. In the samples they do it for single cubes, so you know that will work if you port it to your project :p

quiet swallow
karmic basin
#

Scene 4b. Limit DOF in the samples

#

Yeah I tried, and it just works ℒ️

quiet swallow
safe lintel
#

ue5 went into early access and theres a preview vid on youtube with some of the new features. they got a full dsp audiograph solution with an actual ui, im sitting here wondering what on earth is going on with dots taking so long in that department(among others). with so much tooling around workflows(not just technically impressive), dots is feeling a bit underwhelming these days.

sturdy rune
pliant pike
#

if I use a persistent nativearray in a start method of a monobehaviour wheres the best place to dispose of it?

#

I've tried ondisable and ondestroy they didn't work or maybe I don't need to dispose of it πŸ€”

amber flicker
#

You do need to dispose - I would expect OnDestroy to work but it's possible the dispose sentinel gets it wrong

#

you sure it's not an issue with statics and fast enter play?

gusty comet
#

So far no ecs on ue5, in fact they are even increasing the modularization. They did remove some of the cruft from their framework but much of it is the same. Audio stuff is amazing though. That's top notch work.

slim nebula
#

I really want metahuman for unity. Looks so good heh

safe lintel
#

its hard not to get discouraged about things when epic does some very splashy marketing

gusty comet
#

so far lumen and nanite seem to work as advertised. I am surprised that nanite doesn't have that many limitations though.

#

but... people on unreal discord are dumbfounded by the lack of ecs or gameframework overhaul πŸ˜„

#

grass is always greener on the other side

pliant pike
#

yeah, all the stuff for Unreal 5 looks amazing

#

but I could never use it to make a game

#

its designed for massive teams or persistent people that can use C++ or Blueprints

safe lintel
#

c++ is my blocker, refuse to use blueprints for the main code

pliant pike
#

yeah there's no way I could do the games I want in blueprints, or without all the asset store stuff, and the community/google, and this discord to help

craggy orbit
#

is there a reason the physics here would be acting so weird? it acts normally (though very slowly) if i set the gravity to -0.01 instead of -10. the ground is a box shape, the person is a capsule, and everything else is a convex hull if that matters. i only have rendering and physics components on the funky entities

safe lintel
#

what are you expecting to happen?

craggy orbit
#

im expecting the objects to fall over to a flat face of the collider

#

here's the colliders

safe lintel
#

if you just throw in a cube with a physics shape+body on it, does it also do something wierd?

craggy orbit
#

it does seem to snap into place when it hits the ground, but it doesn't spin or fly off

safe lintel
#

and if you change its collider to a convex hull same thing?

craggy orbit
#

yep

safe lintel
#

id double check that you dont have a system acting on your entities because those results look very specific

craggy orbit
#

ah yep that was it 🀦 forgot to include entities with only a specific component in a job, so it included everything with a rotation and physics velocity component

#

thanks!

dusk meadow
#

Can I use Mathf.Approximately in Unity Jobs?

dense crypt
dusk meadow
#

Sometimes Unity can be pretty picky.

#

Like I can't launch a job inside a job.

dense crypt
deft stump
gusty comet
#

whats the fastest way to toggle hundreds of entities?

#

I tried destruction/instantiation from Monob

#

I also tried adding Disabled component (in Monob)

#

maybe i should do this from within a System

dense crypt
gusty comet
#

i never did it before so idk you mean like adding some filter to ForEach ?

dense crypt
gusty comet
#

yeah i need to check their parent

#

is there some way to use foreach with eg Linked group or children of parent ?

#

because then i dont need to check parent

#

as it would be already specified

dense crypt
gusty comet
#

yeah

#

hmm maybe i could use tags

dense crypt
#

Well to answer you first question, the fastest way is if you use either the EntityManager or ECB and use AddComponent that takes an entity query, that way it will do it once per chunk, instead of once per entity in the chunk(s).

https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_entity_query.html

https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.EntityManager.AddComponent.html#Unity_Entities_EntityManager_AddComponent_Unity_Entities_EntityQuery_Unity_Entities_ComponentType_

gusty comet
#

you mean to add Disabled component ?

dense crypt
#

Yeah

gusty comet
#

oh ok but do you mean to use entity manager from within a system?

dense crypt
#

That wouldn't matter, it's still gonna take the same amount of time to add component

#

Adding component can only be done on main thread. So no matter if you schedule with an EntityCommandBuffer or use EntityManager it's still going to take the same amount of time

gusty comet
#

cause i have fps drops when doing this ```cs
if (galaxyMonos[g].instantiatedScenery[i] == default)
{
Debug.Log("Scenery spawned");
galaxyMonos[g].instantiatedScenery[i] = entityManager.Instantiate(galaxyMonos[g].convertedScenery[i]);
entityManager.AddComponentData(galaxyMonos[g].instantiatedScenery[i], new Parent() { Value = galaxyMonos[g].galaxy });
entityManager.AddComponentData(galaxyMonos[g].instantiatedScenery[i], new LocalToParent());
}

dense crypt
#

The only thing you can optimize is minimize how many adds you do, or doing it through queries instead of entity by entity

gusty comet
#

yeah how to do it via queries?

dense crypt
#

That's the problem, a query will do it for ALL entities that just have a set of components, you can't check anything first.

#

Here's an example of how you'd do it through a query

#

As you can see there's no option to say "only do it for entities that also have a parent that is X"

#

It strictly checks for components, not their actual values.

gusty comet
#

what about querying parents then accessing its childbuffer inside ForEach

#

if it is even possible

dense crypt
#

Yeah you can do that, but then you're going to have to add components for each entity, which might mean 600 add components in a row.

gusty comet
#

yeah well with GOs toggling the objects enabled/disabled was quite fast

dense crypt
#

Yeah it's possible it's fast enough. I'd do what you suggested as it's the cleanest alternative (going through the childbuffer)

gusty comet
#

actually i was testing and

#

adding disabled component to each entity

#

was slower than instantiation

#

of a prefab

#

that contained these entities

#

instantation took 0ms

#

but im somehow getting fps drops cus of it

dense crypt
#

Looking at the code above, can you include LocalToParent and Parent in the prefab entity? SetComponent is a lot faster than AddComponent. So instead of adding afterwards you just set it

gusty comet
#

probably yeah but will it eliminate the fps drop

dense crypt
#

It will definitely speed up the code, not sure by how much but I'd imagine at least 90%

#

Also, make sure you test in a build, as ECS is magnitudes slower in the editor.

gusty comet
#

really?

dense crypt
#

Yeah it's terribly slow in the editor. Mainly because it does a lot of safety checks to warn you about stuff.

gusty comet
#

is there any performance difference whether i do things from MonoB or from within system

dense crypt
#

Depends, if all you do is use the EntityManager it's not gonna be different. However if you use System and follow ECS design directions it will be a lot faster.

#

For instead a ForEach job can run in parallel easily, but setting it up in a MonoB isn't as clean and optimal

gusty comet
#

i did what you said i think it helped thanks

#

maybe i was wrong about the fps drop

#

it could be caused by shaders

dense crypt
#

Profiler is your friend, you can make a build with profiler enabled to see what's taking time.

remote crater
#

Yo, why does collision with convex mesh collider bounce off an object properly, but a sphere collider sticks like a magnet to stuff it hits? I have a video here. Even if you can't answer, it is kinda a fun watch: https://www.youtube.com/watch?v=WQEbY6ntzgo

The MMO update for the game we're developing can be played now: https://store.steampowered.com/app/658480/Starfighter_General/

Meet the ancient of days:Man who's gamed more than anyone who ever lived:150,000hrs www.twitch.tv/goodnewsjim #1World Starcraft&BW&War3&D2hc.Jesus loves you.How may I pray for you?Love's the way.

Proof of me being #1 i...

β–Ά Play video
ocean tundra
#

i dont think thats the right link

remote crater
gusty comet
#

My mandatory peek in every few month. I would appreciate it if someone could tell me what has changed in the last few month on the dorts front aside from the fact that DOT's only being supported on the 2020 LTS version of unity?

karmic basin
#

Not much more from my point of view. They emphasised again that Jobs, Collection and Burst are ready but everything else is preview.

#

Can't really talk about Animation, Audio or Tiny as I don't follow along but I'd say slow progress ? Maybe Tiny does progress πŸ€·β€β™‚οΈ

#

We're still waiting for a 0.18 release, but it looks like they are further internally (smthg like 0.21 I think ?)

#

We got a new DOTS Graphics subforum

#

and uuuuh... that's it ?

safe lintel
#

Don’t think there’s been a major update in the last 6 months πŸ˜•

jaunty herald
#

Is it recommended to use in on functions that are passed structs? Or are they small enough that it doesn't really matter? I'm talking about stuff like NativeCollections, Entity, ComponentDataFromEntity<>, BufferFromEntity<> etc

gusty comet
#

Thanks I expected as much. My hunch that things where way too early when they went public with it in talks seems to materialize

#

I patiently will wait though given I am so giddy to use it production.

stiff skiff
#

They just made the tiniest of updates

#

0.17.0-preview.41 -> 0.17.0-preview.42

north bay
#

Anyone has the changelog for entities?

safe lintel
#

fairly minor

#

heh this is quite the jump for distance culling (from hybrid package update)

   // It was causing the culling system to discard the rendering of entities having a X coordinate approximately less than -32786.
   // We could not find anything relying on this number, so the value has been increased to 1 billion```
north bay
gusty comet
#

lol i have 200 fps

#

in build

slim nebula
#

grats

gusty comet
#

yeah i wonder if dots helped

#

still using hrv1

gusty comet
#

is there any keyword if u want to check if entity is null or default?

north bay
#

Entity.Null

gusty comet
#

oh nice

gusty comet
#

is there way to return value with ECB.instantiate? e.g.:

Entity ssss = ECB.instantiate();
getting error here

bright sentinel
#

@gusty comet Instantiate returns an entity and also takes an entity as argument

gusty comet
#

yeah it works that way with manager

#

but with ecb i have to find some workaround

gusty comet
#

but you lose reference

#

in next frame

#

ecb works only for single frame

bright sentinel
#

@gusty comet You can save it to a component with ECB.SetComponent/ECB.AddComponent

#

Then that reference will be correct

gusty comet
#

save what

#

you mean to save temporary ecb's entity in its component?

#

or in other entity

bright sentinel
#

@gusty comet No save the reference of the new entity

gusty comet
#

but where

bright sentinel
#

In a component

#

Any component

gusty comet
#

like that?

EntityCommandBuffer ecb = m_EndSimulationEcbSystem.CreateCommandBuffer();
galaxyMonos[g].instantiatedScenery[i] = ecb.Instantiate(galaxyMonos[g].convertedScenery[i]);

ecb.SetComponent(galaxyMonos[g].instantiatedScenery[i], new SceneryData() { entity = galaxyMonos[g].instantiatedScenery[i] });
bright sentinel
#

Sure, but you don't have to put it into an array first

#

But I'm not quite sure why you would need to do this. Couldn't you just have a component on the entity in the first place that you use to identify the entity?

gusty comet
bright sentinel
#

No, you have to get the reference from the component

#

Not sure why you want to store it in an array in the first place

gusty comet
#

anyway, ive implemented ecb but i see no difference in performance

scarlet pasture
#

Hey.. I just updated the packages; Collections, Entities, Hybrid etc..
But now I get this error?
Library\PackageCache\com.unity.entities@0.17.0-preview.42\Unity.Scenes\ResolveSceneReferenceSystem.cs(35,16): error CS0246: The type or namespace name 'Words' could not be found

safe lintel
#

latest collections appears incompatible with other dots stuff, if you roll it back to the second latest do you still get problems?

gusty comet
#

revert back one of the packages

#

i think its .Collections

#

had same issue

#

try 0.15

#

@scarlet pasture

bright sentinel
#

@gusty comet Have you also made sure that your jobs are scheduled?

gusty comet
bright sentinel
#

Uh probably

#

The reason that you want to use ecb's is that you can use them in a job that can be scheduled

#

If you aren't even using systems I'm afraid it's going to be hard to help you much

gusty comet
#

well i wanted to avoid syncpoints caused by entityManager, but maybe ecb called from outside job is instant, like entitymanager, not sure

sage mulch
#

Hi, I asked a question here recently about handling input in an ECS manner while utilizing the new InputSystem. Would this code be a good way to do it?:

public class InputSystem : SystemBase
{

    private InputSys input = new InputSys();
    
    protected override void OnCreate()
    {
        base.OnCreate();
        input.Enable();
    }

    protected override void OnUpdate()
    {
        Entities.WithoutBurst().ForEach((ref PlayerInput player) => {
            player.Move = input.Player.Move.ReadValue<Vector2>();
            player.Look = input.Player.Look.ReadValue<Vector2>();
            player.Fire = input.Player.Fire.triggered;
        }).Run();
    }
}

Asking because I'm unable to use burst/parallelism in this system due to InputSys. I could instead create the InputSys each OnUpdate, but that seemed wasteful (I'm bad at making these kinds of performance judgment calls tho lol, so lmk if I'm wrong please).

#

Basic thought process is that I'll populate the PlayerInput singleton component each frame, and then be able to use it wherever I want

hollow sorrel
#

yeah that is fine

#

you want writing inputs to be on main thread anyway and not having burst is fine because it is only 1 entity (or a few if you support local mp)

sage mulch
#

makes sense, tyvm

hollow sorrel
#

don't forget to add ordering attribute to your system so it runs before stuff that uses input

sage mulch
#

yep, just forgot to copy that

#

[UpdateInGroup(typeof(SimulationSystemGroup), OrderFirst = true)]

#

thanks !

#

Silly question, is it possible to edit a Singleton? Or will I need to create a PlayerInput component each frame and call SetSingleton<PlayerInput>() to update it?

karmic basin
#

Yes you can edit values inside Singleton. They actually are just ComponentDatas you have only 1 instance of

sage mulch
#

Am I able to do it by directly editing the component given by GetSingleton<PlayerInput>? Or will I need to make the change to the entity provided by GetSingletonEntity<PlayerInput>? I tried the first and it didn't seem to work.

#
[UpdateInGroup(typeof(SimulationSystemGroup), OrderFirst = true)]
public class InputSystem : SystemBase
{

    private InputSys_input = new InputSys();
    private Entity _playerInputEntity;
    
    protected override void OnCreate()
    {
        base.OnCreate();
        RequireSingletonForUpdate<PlayerInput>();
        
        _input.Enable();

        _playerInputEntity = EntityManager.CreateEntity(typeof(PlayerInput));
        SetSingleton(new PlayerInput());

    }

    protected override void OnUpdate()
    {
        var playerInput = new PlayerInput
        {
            Move = _input.Player.Move.ReadValue<Vector2>(),
            Look = _input.Player.Look.ReadValue<Vector2>(),
            Fire = _input.Player.Fire.triggered
        };
        EntityManager.SetComponentData(_playerInputEntity, playerInput);
    }
}

Am I creating a Singleton correctly here?

north bay
#

If you don't care about overwriting the previously set data you can just call SetSingleton(playerInput) without keeping the reference to your entity

#

You also don't need the SetSingleton in your OnCreate

sage mulch
#

Oh great, ok. Yeah I was a bit confused about the Singleton process. So as long as I have only one instance of the PlayerInput component, it will be considered a singleton? I just want to be able to call GetSingleton<PlayerInput>() in other scripts and get that entity/component.

north bay
#

So as long as I have only one instance of the PlayerInput component, it will be considered a singleton? exactly

dense lodge
#

Would anybody know any good tutorials to get started with dots? I get the general concepts but I need a project for practice

#

(pls ping me)

solar ridge
#

Looking at the updated preview package (17preview.42) They seemingly added AddComponentForEntityQuery<T>(EntityQuery); as a method to the EntityCommandBuffer. Anyone happen to have the performance differences between that and AddComponent<T>(EntityQuery);?

#

Ah. Nevermind: "New EntityCommandBuffer methods that affect a set of entities matching a query. Unlike existing methods, these new methods 'capture' the entities from the query at record time rather than playback time: the array of entities is stored in the command, and then playback of the command affects all entities of the array."

swift musk
#

Hey everyone, I was wondering what’s the current state of ECS/DOTS? I don’t see it on their roadmap except for animations nor I hear news about it from Unity

#

Did they stop working on ECS?

deft stump
#

No

#

they're working on it

#

but they're being very uncommunicative on it, and only dropping news sparingly.

#

@swift musk

gusty comet
#

how do you call ForEach from Monob

I set a foreach loop in some system, if some Bool = true, then i change system's bool from MonoB

But maybe is there more elegant way

pliant pike
#

you can have a RequireforUpdate in the OnCreate and then create that entity when you want that system to run and then destroy it when you dont

bright sentinel
gusty comet
#

maybe i should run job

#

why not call systems?

bright sentinel
#

Because they are called automatically from the world, just like a MonoBehaviour is called by Unity itself.

#

MonoBehaviour's Update function is somewhat similar to SystemBase OnUpdate

gilded glacier
#

should I make the main menu in ecs as well, or is it just overkill ?

dense crypt
gilded glacier
#

well, I would have to anyway for the gameplay

dense crypt
gilded glacier
#

agree

#

when it comes to production, right now, any hybrid solution seems to be the best

bright sentinel
#

@gilded glacier I would definitely say no, there is no official UI system for ECS, and it's not too bad to put data from ECS to MonoBehavoiurs

dense crypt
#

Yeah, pure DOTS is pretty much insanity right now. But it's always nice to try and strive towards it.

gilded glacier
viral sonnet
#

@gusty comet You can get the system class from the World and call Update from anywhere

gusty comet
#

hi all, I was wondering if anyone knew the performance difference between using ECS and using VFX-Graph with VFX-Shader Assets to render meshes in-game. Since VFX Graph is very fast I was considering creating the entire games meshes using it, but if ECS is way more performant I would probably go Convert To Entity route....

scarlet pasture
#

So, I've dropped my dots project like half a year ago. Is there an established method to render entities in layers for 2d meshes yet?

remote crater
#

I have a question about the entity list view Analysis Profiler... It has a list of Entities, but if you 2x click them, it doesn't zoom to them. How do you zoom to them? I need to know where one is because it is hidden.

slow iron
#

@remote crater You cannot. They aren't part of unity's scene view yet.

remote crater
#

You can see em in the scene view tho...

#

Weird, ok, ty

#

I guess that is coming down the pipeline

slow iron
#

Those should be the gameobjects, not yet converted to entities

#

unless im mistaken

remote crater
#

Nope

#

I can see entities in my game

#

As I fly around n stuff

slow iron
#

ah right right

#

but u cant select them or anything right

remote crater
#

They're visible in game and in the grid view you can navigate through

#

No you can't select em in scene, but they obviously have x,y,z data

#

so 2x clicking the entity in the debug analysis should have your window focus em

#

I guess they'll get around to it soon, I figured it out without that tool

#

Good to know it is impossible to do that basic task, so I will not spend time researching it on the Internet

slow iron
#

Welcome to dots lol

remote crater
#

What is dots? If we knew, we'd tell you.

#

Dots is a lot like a box of chocolates

#

Sometimes the ones you like get eaten, or future versions of the boxes do not even have em in it.

#

Sometimes you can't even figure out how to eat the chocolate, having some sort of nut shell on it that you can't break.

#

Some of the chocolates are out of date and are advised not consuming for they will cause you problems in the future.

#

But the chocolates you do find, they taste oh so good

#

Definitely UNITY's Stock will soar after a couple games with this get released. Trying to get my MMO out by the 19th of June.

slow iron
#

wait are u serious or joking

#

about the mmo thing

#

idk if dots would be a good fit

half jay
#

Hi guys i have code like this without entity command buffer. Is it wrong? Will it work? As i understand sync point will be create automatically somewhere ?

 protected override void OnUpdate()
 {
        Entities.ForEach((ref Translation translation) =>
        {
            // Some stuff here
        }).ScheduleParallel();       
}
deft stump
#

are you going to do some structural changes?
ie add/remove components or spawn/destroy an entity?

#

if so, yes, there's going to be sync point without ecb

#

but if, it's just that, and you're only manipulating the data in the components, no need to worry about sync points

#

@half jay

half jay
#

@deft stump yes, i added ref because planning write data into Translation component for example

pulsar jay
#

Can anybody figure out why this works with CreateEntityQuery but not with GetEntityQuery:

var ecb = CreateCommandBuffer();
//var query = GetEntityQuery(typeof(EventTag));
var query = this.EntityManager.CreateEntityQuery(typeof(EventTag));
ecb.DestroyEntity(query);
#

Both seem to destroy the entity but the commented line seems to mess with the timing as other systems never get to see the EventTag entity

#

Afaik the only thing GetEntityQuery does differently is cache the query πŸ€”

timber ivy
#

Is it possible to create subscenes in editor with code

gusty comet
#

trying to locate this error but kinda cant

ArgumentException: System.InvalidOperationException: Invalid Entity.Null passed.
i think it happens when u try to instantiate entity (or createntity) from entity that is entity.null

slim nebula
#

later when you get the component that entity is still uninitialized on the component

#

maybe there's multiple causes for the error though, but it sounds familiar to me

gusty comet
#

Okay i got it now

#

tried to delete entity that was null

bright sentinel
gusty comet
#

are entities taking computer resources if they appear in Debugger, but if theyre not instantiated?

#

because i have 12k un-instantiated entities

#

could lower it to 300

#

at the cost of having to do the GO conversion more often

gusty comet
#

okay i checked and seems the answer is yes xD

#

visible change in fps after adding 100k of uninstantiated entities

bright sentinel
#

@gusty comet What do you mean uninstantiated entities? Do you mean prefabs?
And GO conversion doesn't happen at runtime, so not sure how it happens more often.

gusty comet
#

i mean this

= GameObjectConversionUtility.ConvertGameObjectHierarchy(
entities made with this are uninstantiated id say as its impossible to interact with them until u instantiate them or maybe im wrong but i dont see them anywhere

#

@bright sentinel

bright sentinel
#

Oh, I haven't really used that :/

karmic basin
#

I don't use that neither, but if ConvertGameObjectHierarchy creates a prefab entity , it's "impossible to interact with them until u instantiate" because the Prefab Component filter them out of the queries. If it directly creates an entity, then what I said is irrelevant and I don't know :p

#

If that's what you meant with I don't see them anywhere

karmic basin
gusty comet
#

well they still take computer resources and FPS

#

so i decided to design code in a way so that i have less of them

karmic basin
#

But that would be in editor only, doesnt matter for runtime

gusty comet
#

really?

#

wym

karmic basin
#

it's some kind of preview

gusty comet
#

nah im sure its the same for build, but i can check it

karmic basin
#

Honestly I'm not even sure we're talking about the same thing, so I don't know if that helps

gusty comet
#

im only talking about fps drop caused by lot of uninstantiated entities

bright sentinel
#

But conversion really doesn't happen at runtime

#

And you also shouldn't use the editor for performance benchmarks either

karmic basin
#
  • you should forget about GameObjectConversionUtility.ConvertGameObjectHierarchy especially if you have loads of entities, and switch to subscenes
#

and I still don't understand what does "lot of uninstantiated entities" refer to

#

surely authored gameobjects, right ?

gusty comet
#

relax

gusty comet
bright sentinel
#

@gusty comet You mentioned that you can see them in the EntityDebugger. If you click one of them, does it have the Prefab tag?

gusty comet
#

they probably do idk

bright sentinel
#

Can you check? πŸ˜„

gusty comet
#

no because i already got rid of them

#

but theyre converted from a prefab so i guess yeah

#

why? i can get entity.instantiate to work and take less than 0ms
also i can do that on an entity that contains 50 entities under/inside it and it will work the same

karmic basin
gusty comet
#

it will be crazy if they remove GameObjectConversionUtility

#

and leave Scenes as only way

#

to load entities

#

because its very useful system

karmic basin
#

If it's a small project and you use it sparingly, and that works, no reason to change.

gusty comet
#

and i doubt i can use scenes in dynamic world

karmic basin
#

well you can

#

also like Bmandk said, keep in mind conversion does not happen at runtime

#

got to go for a drink, I hope I didn't misunderstood most of what you were saying and give irrelevant advice

#

happy coding

gusty comet
#

scene conversion or

#

gameobjectconversionutility

amber flicker
#

Conversion does just add the prefab tag, yea. No reason it would have a noticeable affect on performance unless you were eg very short of Ram or smth as they won’t be processed by any systems.

safe lintel
#

@gusty comet with your "12k un-instantiated entities" is this 12k unique entities then? all a different archetype?

gusty comet
#

no

safe lintel
#

what do you mean by 12k uninstantiated entities impacting your performance?

gusty comet
#

nah dont worry that issue is alredy solved

slow iron
#

is it possible to get the converted entity using just your own code while using the default convert script

#

or would I have to make my own convert code and muddle with the entites?

#

I just want to move something, but I need move the entity the gameobject is following, not just the gameobject

karmic basin
# gusty comet what do you mean?

I don't use gameobjectconversionutility but yeah scene conversion happens in editor. The final entity representation is serialised to disk, and that's what's loaded at runtime.

#

It's like an asset if you wish

deft stump
#

does tiny work on webgl?

hollow sorrel
#

@deft stump yea that's what it's made for

#

the main use case they're targeting with tiny is facebook ad games

deft stump
#

nice

#

I'm guessing from the name itself

#

it's much lighter than the regular webgl build right?

hollow sorrel
#

yeah

#

but it's basically new engine

#

any other libs you wanna use prob won't work and they have some barebones implementations of things but not even real UI support

#

so making anything in it is a pain

deft stump
#

hrmmm sad

remote crater
#

How do you get component velcoity?

safe lintel
#

PhysicsVelocity not Velocity

remote crater
#

ty. I tried that. I must have typoed. God bless.

#

Oh I know what I did. I forget to change the variable declaration along side it, lolz.

quiet swallow
#

Can anyone explain why I'm having performance spikes on Solver:ParallelSolverJob on android (development build), but no issue in editor (60fps, windows) ?
I'm instantiating ~1000 entities with PhysicsBody and at that particular moment many trigger & collision events occur.
Profiler graph on android is attached.

#

And here's the same graph, but from windows editor

ocean tundra
#

@quiet swallow Could it just be that android is weeker? as in less CPU power?

#

But also check that Burst is on, and that saftey checks are all off in the Dev build

#

Also does a non development build give the same results?

quiet swallow
quiet swallow
ocean tundra
#

Honestly im not sure how to confirm they are off in a Build :/

#

Release mode should definitly have them off

#

but if thats crashing that dosnt help

quiet swallow
#

ok I'll try to make the release build work. thanks for the help

ocean tundra
#

All good, sorry i cant help more

remote crater
#

So I spent about an hour trying to figure out how to get a script to run when my ECS DOTS Entities collide, They collide fine, but I want to apply damage. I reason it is something like a trigger, get data from Entity A/B, and then apply stuff to em.

#

I just can't find any sample code.

remote crater
#

In the Unity Physics Samples code of Unity GitHub, is there an example that uses: Collide Raise Collision Events?

#

If not, is there any example out there anywhere on the Internet?

quiet swallow
light mason
#

Is unity doing a open world sample w dots ?

remote crater
#

@quiet swallow Are Jobcomponentsystems even used anymore? I thought we used SystemBase now?

#

I tried a JobComponentSystem sample similar to yours, but it didn't trigger a breakpoint and I couldn't figure out how to do a Debug statement UnityEngine.Debug.Log was throwing errors. Also...

#

Do you have to attach this script to anything?

quiet swallow
remote crater
#

How can I see if it worked. Will it accept breakpoints? The last one didn't stop inside when I collided.

remote crater
#

@quiet swallow It doesn't understand your tags or even my tags...

#

The type or namespace ObsticleTag could not be found.

#

Are those IcomponentData and not Tags?

quiet swallow
remote crater
#

cool ty bro

torpid mulch
#
Entities
    .ForEach((Entity e, ref TrackLocomotor locomotor) =>
    {
        if (HasComponent<FlowField>(locomotor.flowFieldEntity))
        {
            var grid = GetBuffer<Cell>(locomotor.flowFieldEntity);
        }).ScheduleParallel();

Is there some way I can get a dynamic buffer inside an Entities.ForEach with ScheduleParallel()? Unity doesn't let me saying that dynamic buffers cannot be written to in parallel, and I don't need to write to it.

remote crater
#

@quiet swallow It works very very very well.

stiff skiff
#

You can also change ref TrackLocomotor locomotor to in TrackLocomotor locomotor to specify that component isnt written too

torpid mulch
#

locomotor is being written to, I just deleted every other line so it wasn't too unreadable

timber ivy
#

is there a way to create entities from a non unity thread? IE new Thread

pliant pike
#

I'm pretty sure they can only be created on the main thread whether its directly or through playback form the ecb

light mason
#

Can anyone think of any major conferences where Unity could potentially give and update on ECS?

#

Particularly interested in the editor compatibility and no addition information has been posted on the forums

safe lintel
#

can only think of gdc or unite(rip)

light mason
#

Unite rip?

safe lintel
#

("rest in peace" because of cancelling in person events)

light mason
#

Ah

#

Still online though that’s not bad

safe lintel
#

unite wouldve been the place and I miss the keynotes even if it was mostly marketing because at least they were compelled to present something big to drum up interest

light mason
#

Man I need something to get hyped about

safe lintel
#

"unite now" was a big letdown for dots related things(dont think there was anything outside of physics?)

light mason
#

Ok

safe lintel
#

anyway its either gdc or bust at this point

light mason
#

Well finger crossed for gdc

safe lintel
#

im coming to the acceptance that they wont show anything for gdc

light mason
#

Do U know if unity is working on a open world dots sample

safe lintel
#

well apparently that was the plan, way back in the official roadmap talk they mentioned a large scale streaming demo

light mason
#

Ok

#

Well maybe unity has that for GDC

safe lintel
#

dont get your hopes up πŸ₯²

light mason
#

My fear is Unity might decide to show less with the splash epic made

#

I imagine they wouldn’t want to show off new tech that the competitors has a better solution for

#

I just need some info haha

#

Really stuck here

safe lintel
#

yeah, being left in the dark blows

sage mulch
#

Is the best/suggested way to handle cameras simply to have a camera focused on a GameObject that follows an entity? (Following this vid but wondering if there is a better way to do it now: https://www.youtube.com/watch?v=JFv49-0vy_8)

πŸ“Œ Download the project files from this video: https://tmg.dev/CamFollowEntity πŸ“Œ
πŸ’¬ Hang out with other ECS Developers: https://tmg.dev/discord πŸ’¬
πŸ‘Ά New to ECS? Start here: https://tmg.dev/StartECS πŸ‘Ά

πŸ’» My Game Development Setup: https://tmg.dev/GameDevRig πŸ’»
πŸ‘‡ See below for time stamps πŸ‘‡

Unity Version 2019.3.15
Packages Used

  • Entities 0.11
  • Un...
β–Ά Play video
gusty comet
#

how to get value of current amount of entities?

pliant pike
deft stump
coarse turtle
#

Has anyone ran into an issue where the Begin/EndFixedStepEntityCommandBufferSystem throw this warning in a dev (Mono) build?

Internal: deleting an allocation that is older than its permitted lifetime of 4 frames
#

Trying to figure out why the EntityCommandBufferData would exceed its lifetime

hollow sorrel
#

@coarse turtle there's prob more than 4 frames in between your fixedstep updates

#

either due to high framerate or low fixedstep tickrate

coarse turtle
#

Yeah just ran the profiler - was definitely the case πŸ˜…

hollow sorrel
#

which should really be fine but for some reason unity decided to make tempjob allocator have a permitted lifetime of max 4 frames and also decided to use that in their entitycommandbuffers

#

seen forum posts about ppl running into this issue in early 2019 and the response was "we're gonna look into that" and now it's 2021

gusty comet
#

how do i debug invisible entities (that are invisible in build only)? i checked already for number of entities and its the same in both cases, but in build theyre mostly invisible

glacial jasper
plush meadow
#

is there a way to override material property WITHOUT using shadergraph?

#

and if possible i'd like to do it within the built-in render pipeline since i do not need any of the other features URP or HDRP provides

gusty comet
#

is there no GetComponent for ECB?

karmic basin
plush meadow
#

I gave up on built-in honestly

#

It doesnt seem like thats meant for run-time overriding?

#

without writting and code

karmic basin
#

How would you do at runtime without code ?

#

You lost me there ^^

plush meadow
#

No, the doc says that method is abiut overriding per object without writting code

#

I might still be able modify it with system? No clue, will try later

karmic basin
glacial jasper
#

You can see that the second cube changes scale even though i never changed it

#

There's no code involved

#

you can see that the Local to World scale is 1 as it should be, but the cube is 2 units large in the scene view

#

this is before enterying play mode and conversion to entities

#

it seems the transform of the first existing cube is just applied to all other cubes for whatever reason

gusty comet
#

i have this error on dots entities with rendermesh

Mesh '(Clone)': abnormal mesh bounds - most likely it has some invalid vertices (+/-inifinity or NANs) due to errors exporting.
Mesh bounds min=(-71444734465366174004104134656.00, -71350952989382865719805345792.00, -71378276601852749487011790848.00), max=(71355103949521308137948184576.00, 71366687914503787377657380864.00, 71409340328577066013227483136.00). Please make sure the mesh is exported without any errors.

karmic basin
#

@glacial jasper I tried to reproduce, I can't

#

sorry

glacial jasper
#

hmm, i guess i'll just try it in a new project then

#

thanks anyway

gusty comet
#

btw this is very suspicious cause im copying bounds from mesh

God.commandBuffer.SetComponent<RenderBounds>(God.galaxies[g].planets[p].entity, new RenderBounds() { Value = instancedMeshes[p].bounds.ToAABB() });
glacial jasper
#

Well, i can't reproduce my problem in a new project either. Must have messed something up then.

plush meadow
#

maybe i can try doing this myself

#

or not nvm

#

yeah this is not runtime

karmic basin
#

Yup this is not DOTS, wherever you found that code might happen at conversion time

plush meadow
#

i'm pretty much out of option now

#

so i guess i'll have to settle with moving the entities to a new chunk with a different material

#

it's not that bad for my case but would have been nice

pliant pike
#

Do you guys think its possible to make a Finite State Machine in Dots and then use that with gameobjects?

#

I'm guessing it is but I'm not sure how to get the data from the gameobjects and whether it would be worth it with the resultant performance hit

#

I'd have to use Gameobject.find or something like that?

pulsar jay
#

I am currently trying to use singleton entites as states, which works quite well as you can use RequireSingleton in a System which will only update the system if the singleton exists. You only need a way to enforce transitions etc. and to have only one state at once

pliant pike
#

@pulsar jay yeah that's what I've been doing, that works fine, I'm just curious about the other way, like what if I want all the gameobjects Transform.positions in a SystemBase

#

is that even viable, I don't its a matter of figuring how much data I have and calculate with the monobehaviours and how much in the Systems I guess

pulsar jay
#

I try to avoid manipulating GOs from Systems. I prefer manipulating entities with systems and poll data from the GO side

#

But if you really need to there are ways to get their references via conversion I guess

#

But if you are sure they exist from the start you could also get them once via GameObject.Find or better yet via FindObjectsOfType and then cache them

pliant pike
#

so you poll the entity data in the monobehaviours but what if you have lots of gameobjects and each one has to poll the data doesn't that effect performance badly

pulsar jay
#

if I have lots of the same I usually use entities πŸ˜‰

#

so why do you need GOs if they could also be hybrid entities?

pliant pike
#

yeah I'm using a lot of gameobjects with the Unity Navmesh, I'm trying to figure out how to use that efficiently with dots as there's not really any decent dots pathfinding stuff yet

pulsar jay
safe lintel
#

there are a few third party things

pliant pike
#

there's lots of things in the works but nothing really close to finished, I mainly need one that has working collisions, avoidance between the entities

safe lintel
#

none of them are ideal for me personally

pulsar jay
#

but doing the navigation in GO world and then transferring the result seems like a really slow solution

pliant pike
#

that's 3 years old will that even work

safe lintel
#

"com.unity.entities": "0.0.12-preview.8",

pulsar jay
#

"com.unity.entities": "0.17.0-preview.41",

pliant pike
#

it doesn't look like that has entity avoidance

#

but thanks for the help

pulsar jay
pliant pike
#

I've tried making my own or converting RVO2 and no thanks leahS

jaunty herald
#

Any idea what's going on here? AtomicSafetyNode has either been corrupted or is being accessed on a job which is not allowed.

#

and SetBumpSecondaryVersionOnScheduleWrite node is not valid

#

I'm iterating over a NativeHashmap using ForEach

#

Is that not allowed inside a job?

solid rock
#

so I'd be wary about foreach

jaunty herald
solid rock
#

but also- iterating the map inside a job? Is it a parallel job?

jaunty herald
#

Nope

#

scheduled non-burst job

#

How am I supposed to iterate over a NativeHashmap then? Use NativeHashmap.ToKeyArray()?

#

Seems kind of counter intuitive if I want performance

solid rock
#

I've never had cause to do so..

#

so I'm not sure

jaunty herald
#

I guess I would write the keys to another native collection and then use that, but it seems very hacky imo

solid rock
#

Maybe you'd use the KeyArray

#

yeah

#

idk - it's a preview package πŸ˜„

#

there's a lot of broken/hacky stuff still

#

ugh sory for the 0.0 link

jaunty herald
#

Yeah but supposedly there's a difference between preview and experimental

solid rock
#

damn google

jaunty herald
#

And if the jobsystem is supposed to be production ready soon these kind of things are kind of a major issue

remote crater
#

Lets say I am instantiating lasers groups with children of 1,2,3 & 4 into Entities during runtime. How do I add physics shapes and physics bodies to each of the children(individual lasers) of the group.

#

I hear Entities doesn't even have children at run time, right?

#

So in my normal mode of gameobjects, I have 4 different prefabs of lasers. Each prefab holds a group of lasers 1/2/3/4. Each laser has a rigid body to collision detect itself while the other up to 3 lasers have their own individual colliders.

If ECS/DOTS had children,

After conversion to entity of a laser group, I could access children by transform.GetChild(x) to place on physics shape/body. But I am unable to get the child of an ECS entity. How do I do that?

Is it possible I make new prefabs with laser having shape/body on them? Cuz that would solve it too.

Thanks,
Jim

remote crater
remote crater
#

So the guy says that entities have buffers, but I do not know the syntax to access such said data.

#

I was told: There's a buffer called Child with all of an entities children.

What is the syntax to access that buffer from monobehavior when I have EntityManager and the entity I want to get children from?

The Unity Documentation is unclear.

remote crater
#

Anyone have example code of accessing a buffer? I have no clue about how to access them when you have an entity and Entity manager.

gusty comet
#

anyone else had its dots build compiling clogged? i remember i had this before, then it randomly fixed after many hours and attempts, and i again have it. it will never end, last time it took 2 hours and didnt finish even though all cpu usage and IO went to 0. usually dots build compiles in just one minute

#

tried: cleaning entity cache, editor cache, setting scene to dirty and resaving it, properly opening and closing unity, then reseting PC and finally going to playmode before building.

amber flicker
#

Not seen that in recent memory - did you try deleting your library folder?

gusty comet
#

just did it

gusty comet
dense crypt
gusty comet
#

maybe cleaning unity folders from appdata would help

#

yeah . normal build works, dots build stopped working

dense crypt
#

Okay, yeah then I don't know on the top of my head

gusty comet
#

i ran it many times today, sometimes even for 2h

safe lintel
#

report it to unity, let them figure it out

#

as a last resort if you havent tried these things: try building on a different pc(if you have one), try copying only the scripts into a new project(duplicate project settings and package settings obviously), and see if it builds. id still report to unity though

jaunty herald
#

Is there a way for a job to create a native collection that is later reference by another job? For example if I don't know the size of a nativearray yet, or is the only way to use a nativelist?

#

I assume no, since jobs can only create collections with Allocator.Temp, but maybe there is some way around it

gusty comet
#

took me only 12 hours to figure it out
edit:
okay that doesnt always work, but if you cancel the second window popup very early, and wait for it to cancel, then it should work fine next time you do this

gusty comet
#

i was hoping for productive day today πŸ˜›

jaunty herald
#

its all a matter of perspective

pliant pike
#

@jaunty herald you can't create an array inside a job that will be used outside of a job

dense crypt
#

I updated my post with the latest collection version

jaunty herald
#

I'm pretty sure I schedule multiple jobs in a chain that use the same containers without issue

dense crypt
jaunty herald
#

I meant more along the lines of two jobs sharing the pointer to unmanaged memory, and the first job initializing it before the second job reads it

#

I don't think this is possible

dense crypt
jaunty herald
#

Yeah, but how does A create the collection? The structs are copied by value, and the job is only allowed to create collections using Allocator.Temp

dense crypt
#

If you're using Entities.ForEach and not manually configuring dependencies, then the dependency order is always top to bottom of your Entities.ForEach.

#

Yeah that part is impossible. You have to create the collection with TempJob allocator before scheduling A.

jaunty herald
#

e.g.


            NativeArray<int> test = default;

            Job.WithCode(() =>
            {
                test = new NativeArray<int>(100, Allocator.TempJob);
            }).Schedule();

            Job.WithCode(() =>
            {

                Debug.Log(test.Length);

            }).Schedule();
#

does not work

jaunty herald
#

So I guess just use lists or have an upper bound and use an array

dense crypt
jaunty herald
#

In the example on the page you linked, couldn't you just pass the NativeList to the second job?

dense crypt
pliant pike
#

yeah you can do that

dense crypt
#

Docs: If you tried to pass the list directly to the second job, that job would get the contents of the list at the time you schedule the job and would not see any modifications made to the list by the first job.

#

So in essence, the actual value behind the index would still be modified, but there's no way of knowing if the size changed.

jaunty herald
#

I have a bunch of jobs where I create a hashmap at the beginning and then modify it in jobs, and it all works fine

pliant pike
#

I've done it before, you just can't allocate it inside a job

jaunty herald
#

Yeah, I don't think the contents are copied, since that kind of defeats the purpose

#

Aren't nativecollections just the pointer? Although I don't know what happens if a nativelist resizes or something

#

I assume at least for NativeArray it should work

pliant pike
#

try the above with a nativelist create and allocate it outside the jobs then add some elements in the first job then see if they appear in the second job

dense crypt
jaunty herald
#

Yea, that makes sense

#

Thanks for bearing with me

#

Atleast for NativeHashmaps it does seem to work however 🀷

dense crypt
#

If I'm not mistaken and to further clarify, the metadata of the List is copied, not the actual array bits. So basically the pointer to the memory location of the backing array.

wind stag
#

In the game that I am working on, I have an issue with the performance impact of Physics.ProcessReports coming from OnCollisionEnter. However I have a hard time finding out exactly how to optimize this as it is required that collisions can register and mesh deformation happening.
I have been able to reduce the performance impact of mesh deformation by using the Jobs system specifically for modifying the triangles, however I still have to return them and Recalcualte normals, recalculate bounds and bake the new mesh after a mesh deformation has happened.
In the profiler, I am seeing anything between 100-800 KB of garbage generated from the physics collision, and the physics time taking anything from 40-60ms.
Is there a way for me to optimize further by either moving most or all deformation code to the jobs system or generate as little garbage as possible?

Using 2019.4.25f1
Multiplayer with 50 rigidbodies containing a set of very low poly (<20) triangle mesh colliders.

frosty siren
#

I was trying to set shared component via ECB and got this error. Have anybody faced it?
```Packages\com.unity.entities@0.17.0-preview.41\Unity.Entities\Types\FastEquality.cs(215,13): Burst error BC1051: Invalid managed type found for the field EqualFn of the struct Unity.Entities.FastEquality.TypeInfo.: the type System.Delegate is a managed type and is not supported

#

Seems like ecb.SetSharedComponent<T> can't be used with burst

latent oracle
#

Hi team - re: JOBS. Say I have X projectiles that I want to jobify raycasts from, to detect collisions. Do I add each projectile instance to an array and put that into one job, or can I make a job from each individual projectile? Will it make a difference? What's the best practice, sorry for the noob question

bright sentinel
#

@latent oracle You can do both. In the end it comes down to the amount of processing you need to do. It probably does not make much sense to do a singular raycast within a single job and do one job per thing, if that's all you're doing. But at some point it makes sense to split them up into batches. So by default, just keep everything in one job. If you have enough projectiles that need to do the raycast, you can start splitting your jobs into multiple batches using IJobParallelFor that does the hard parts about threading and so on for you. As for the exact breakpoints, that's something you have to test experimentally.

#

Of course if you do a lot more processing per projectile, you can have very small batches.

latent oracle
#

OK that makes senes

#

Thank you

#

I'll do that

#

just struggling to make it work per projectile at the moment haha, I'll move it over once I understand how to do the actual raycast. Thanks again man

bright sentinel
#

No worries πŸ™‚ Good luck!

quiet swallow
#

How do I get access to material of the RenderMesh or SpriteRenderer component? I want to do a simple fade out effect per entity inside my system.

bright sentinel
quiet swallow
latent oracle
#

@bright sentinel curious: Do you know if there's a way to jobify anything in Physics.updatebodies? I've got like 30ms of stuff in there.

bright sentinel
#

@latent oracle Is that PhysX? I don't remember. DOTS has their own physics stuff

latent oracle
#

ah

#

yeah physx. Wrong place to ask, oops

#

Thanks though!!!

twin raven
#

I haven't touched dots in a while, so is 2020 LTS the way to go? I started already a project with 2021.1 and didn't notice any issues, but I guess they are there just hiding.

crude sierra
#

if I have an Ecb.ParallelWriter but I want to GetComponent what's my API to do that?