#archived-dots

1 messages ยท Page 163 of 1

tight blade
#

how does runtime mesh manipulation then work if it cant be jobified?

#

"slowly"

zinc plinth
#

You copy vertices in and out of native containers

#

With a lovely bunch of allocation when you copy back to managed

coarse turtle
zinc plinth
#

Hooo I'll have a look at this, didn't know that existed

#

hooo this seems rly nice

#

tho it can't work with CombineInstance sadly soo

tight blade
#

niiiice

zinc plinth
#

I wanted to cache my resulting meshes, but I'm not sure how they get combined and if there's no offset to the transform matrixes I'm providing for each mesh to combine

#

like if the 0 0 is the 0 0 of the first mesh or if everything is on world space

#

which would omega suck

#

so testing that now

#

huuuh test isn't really conclusive

#

I can't seem to get the combined mesh to display ?

#

(testing on gameobjects)

violet cosmos
#

So, I'm curious how to do something that is a process with Jobs/ECS

Let's say the process always runs in the order A, B, C, D

How do I move data from A > B or A > D?

Is that in Execute? ex: Execute([ReadOnly] ref A aResult) with an [UpdateAfter(typeof(A))] in the system class def?

#

Also, if the resulting data in A is an array that potentially changes size each frame... how do I handle that? Just allocate a new NativeArray?

zinc plinth
#

Are you talking of jobs or systems

If you want to pass data between jobs put your dependencies correctly and pass around your native containers

rancid geode
#

@violet cosmos you use NativeContainers (NativeArray, NativeHashMap, Native....) to pass data from one job to another, like the following:

var resultsFromA = new NativeList<int>(Allocator.TempJob);
var jobA = new JobA() { Results = resultsFromA }.Schedule();
new JobB() { Input = resultsFromA }.Schedule(jobA);
zinc plinth
#

Or use Unfase if you like to live dangerouslu 0_Kappa

violet cosmos
#

In this case, I'm going to be running mostly on things that exist not as Entities, but GameObjects/Colliders/etc in the Scene... But, there's a blurry line between ECS and Jobs I haven't quite isolated yet

zinc plinth
#

You can't use managed types in jobs

#

You can check references between each other using Dunstan's article, but that's it

rancid geode
#

@zinc plinth actually you can, with GCHandle, but GameObject/Collider and many other UnityEngine.Object stuff can't be used outside MainThread

#

you can't use managedtypes at all with Burst

violet cosmos
#

So, if I wanted A to run collision detection, every object that it could potentially collide with would need to be migrated into Entity?

#

Well, not collision detection per se... But things like CapsuleCast, SphereCast, etc

rancid geode
#

So, if I wanted A to run collision detection, every object that it could potentially collide with would need to be migrated into Entity?
@violet cosmos unless you create a custom collision detection and used the colliders data to create your own custom jobfied colliders

#

which I would not recommend to do unless you have expertise on that

#

you can take a look into RaycastCommand, which is a jobfied way to do Raycast with standard unity physics

#

you can create CapsuleCast/SphereCast/etc based on that

violet cosmos
#

Then that's into pure Jobs, and then... How do I run Jobs in that A, B, C, D scenario where B uses data from A?

rancid geode
#

@violet cosmos you use NativeContainers (NativeArray, NativeHashMap, Native....) to pass data from one job to another, like the following:

var resultsFromA = new NativeList<int>(Allocator.TempJob);
var jobA = new JobA() { Results = resultsFromA }.Schedule();
new JobB() { Input = resultsFromA }.Schedule(jobA);
#
struct JobA : IJob
{
    [WriteOnly]
    public NativeList<int> Results;

    public void Execute()
    {
        for (int i = 0; i < 100; i++)
        {
            Results.Add(i);
        }
    }
}

struct JobB : IJob
{
    [ReadOnly]
    public NativeList<int> Input;

    public void Execute()
    {
        for (int i = 0; i < 100; i++)
        {
            Debug.Log(Results[i]);
        }
    }
}
violet cosmos
#

What's the best way to check when a Job completed? Polling for IsCompleted seems dumb. IsCompleted isn't async. Forcing Complete seems a bit... blunt

rancid geode
#

polling for IsCompleted is the correct way

violet cosmos
#

O_o

rancid geode
#

or just call Complete when you require it at a certain point

violet cosmos
#

You'd think they would have added CompleteAsync so code could be organized ๐Ÿ˜„

rancid geode
#

currently, jobs doesn't seem designed to be running across many frames

minor sluice
#

think the manual check is alright since you usually operate on a system execution per frame basis, but if one used jobs only, i can see that it can make sense

rancid geode
#

they surely need to add support for that (like Addressables does) if this use case is intended

violet cosmos
#

No, and for this particular chain of inquiry, I'll likely just force Complete and try to aggregate as many things as I can before

#

So, that brings up another question... I formed a big job that using a system that effects multiple GameObject/Behaviors, then forced it to complete... Now, what's the usual best practice to migrate that data back into the GO's?

minor sluice
#

apply it in a synchronous context I'd say, not sure if there are better practices

violet cosmos
#

But, when? Update/FixedUpdate/etc are running on their own independent timeline and I can't just block that

minor sluice
#

if you work in other thread related ways, you could make a queue to store actions that need to be applied then,,
I think it depends on when you need it

#

I would set it up so it either happens in update /lateupdate or another event method... maybe? I'm not sure about systems, I think there it depends to which system group they are part of?

#

but could certainly be done in an OnUpdate too I'd think

violet cosmos
#

Hmm, that's where the decision gets blurry for me on Jobs/ECS. Do I migrate lots of other things into ECS so I'm running a parallel physics world so then it can just be magically applied, or do I try to solve a bunch of issues around "when" and "who" for applying results of pure Jobs ๐Ÿค”

minor sluice
#

doesn't physx support parallel worlds in recent versions too?

#

maybe im wrong, let me check

violet cosmos
#

I can't count on PhysX

minor sluice
#

ah okay

violet cosmos
#

The reason I'm going down this path is to eek as much performance as I can out of the Quest for a system that is likely to easily grow in size and complexity, and computation time

#

I'm still new at DOTS, and trying to wrap my head around it for new and existing systems

minor sluice
#

hmmhh, but physx is already multithreaded? not sure if the unity physics are already faster, maybe they are if everything is properly set up with data in the ecs world

violet cosmos
#

I think I'm OK migrating many things into Entities using MonoBehaviours that are converters

#

But, I wouldn't mind making things isolated systems either that just work on existing GameObject workflow

tardy spoke
#

@violet cosmos welcome to the fun world of DOTS and Oculus Quest. If you get ECS running on the quest at all with 2020.1 and Entities 0.13, let me know, haha. I can get 0.11 to run, but not 0.13

stiff skiff
#

With the XR toolkit?

tardy spoke
#

Yeah, with XR

#

It'll build/load but ECS systems just don't seem to execute

violet cosmos
#

Hmmm, that's a huge red flag. I just converted to to XR Plugins, but I'm not using the Integration Toolkit, I have my own API

#

There's still one thing I'm very confused about, is that demarcation line between ECS and ECS based Jobs and the traditional scene... and how to control that. Does ECS run it's system before any MonoBehavior Update?

#

Flat pure Jobs I can wrap my head around how to organize

Pure 100% ECS too

It's mixing ECS and ECS Systems with the Scene that I'm still seeking clarity

tardy spoke
#

Lol, someone needs to draw a chart. That question comes up all the time. Someone must know the order of execution?

rancid geode
#

just ensure to tick the Show Full Player Loop

tardy spoke
#

I should draw a chart based on that

#

Just for a simpler mental model

violet cosmos
#

@rancid geode sure, but I'm in the planning phase now, how to organize. There's nothing for me to check

rancid geode
#

basically it is :

MB.Update()
SimulationSystemGroup
MB.LateUpdate()
PresentationSystemGroup

#

@rancid geode sure, but I'm in the planning phase now, how to organize. There's nothing for me to check
@violet cosmos this screenshot is from a pratically empty project, having more scripts doesn't change the player loop order

#

unless some of your script is modifying the player loop itself

violet cosmos
#

That's a really useful thing

#

... if I could find it ๐Ÿ˜„

rancid geode
#

if you don't have DOTS Editor installed you can use the one in the EntityDebugger

#

if you have the DOTS Editor, it is in Window -> DOTS -> System

violet cosmos
#

Lovely... New 2020.1 project, enabled preview packages... Hybrid Renderer is not in the list of available packages in the Unity Registry

rancid geode
#

just click +, add from url and type "com.unity.rendering.hybrid"

violet cosmos
#

Learning this is like some weird priest cult. What's next, I have to open the command line and type in a bunch of undocumented commands? haha

rancid geode
#

they changed the entities-related visibility due its experimental state

quasi trellis
violet cosmos
#

@quasi trellis Well, that explains it.... And also, kind of annoying

#

It's also not a Git URL ๐Ÿ˜›

stone osprey
#

How do we construct systems and components in a flexible and clean way... lets say we wanna spawn popups once we click on a entity... we could either decide between the hard coded approach : "ClickOnEntitySystem sending click event, OnClickSpawnPopUp as Component which returns the PopUp being spawned, OnClickSpawnPopUpSystem iterates over click events to spawn popups using OnClickSpawnPopUp" or would you choose the flexible approach : "ClickOnEntitySystem sending click event, OnClick as Component which simply contains a callback/action with code, OnClickSystem which iterates over the events and OnClick components in order to execute the callbacks"... The first approach is only spawning popups while the second approach is pretty flexible and can get extended by callbacks pretty simple... for example we can just hook up new actions and print stuff while a entity was clicked ๐Ÿ˜› what would you choose and why ?

deft stump
#

what you mean by popups?

stone osprey
#

popups... uhm... just replace popups with "UI"/"UI-Elements"/"UI-Notifications"... everything that pop-ups ^^

dark cypress
#

Isn't the accepted pattern to have MouseButton component on all archetypes that need to react to input and set every MouseButton component in a PlayerInput system?

stone osprey
#

Damn.. i should have said that this is a "server side" example... a general ECS question and not special for unity ^^

violet cosmos
#

I think I'm going to have to read that over a few times though

tardy spoke
#

Yeah, it's a bit tricky as some of that stuff is a bit older now, but still a good resource

violet cosmos
#

Example: "Companion GameObject"

tardy spoke
#

the principles are the same, syntax or class names may be a bit different

violet cosmos
#

@tardy spoke Could you tell me more about the Quest / ECS issue you're having? Are just entities alone that are not processing, or XR tracking? Or XR Interaction Toolkit?

#

Also, do you see it work correctly in say, Link mode?

tardy spoke
#

XR kit all works fine, just ECS doesn't seem to "run" at all (on Entities 0.13. Downgrading to Entities 0.11 it works fine). No errors that I saw. Haven't tried linked mode.

#

It could be something to do with the XR kit stuff, but I couldn't tell you for sure. The XR kit stuff seems functional and doesn't have any errors.

violet cosmos
#

Hmm, is there an issue tracked for this?

#

Right now I'm mostly on Link mode, in editor with some rare spot checks on Quest via APK to make sure I'm not doing something dumb

tardy spoke
#

Interesting, I have never actually used the Link mode, haha. You're on PC?

#

I'm on a Mac, I'm not sure it can use the link mode though I haven't downloaded the Oculus desktop app and tried

violet cosmos
#

Yah, I'm on PC. Have the official Link cable (with a short 2m extension run of high quality TB3 compatible USB)

tardy spoke
#

I think the issue is tracked, I found someone else that reported the same issue and that's how I learned downgrading to 0.11 was the solution.

violet cosmos
#

Do you have other VR headsets that actually work on Mac?

tardy spoke
#

I haven't bothered, because as soon as you start developing for quest the first thing you do is build a controller that works on both quest and your desktop and do most your dev on desktop because it's such a pain putting the headset on/off all the time no matter how fast the build is, hahaha

#

I'm not sure, my experience is limited just to the Quest, and I'm a fairly new game dev.

violet cosmos
#

I really think if you're getting into VR, it helps to be on Windows. What CPU/GPU do you have in the Mac?

tardy spoke
#

Nothing amazing, I'm sure

zinc plinth
#

got stuff working ```
RenderMesh[] CombineRenderMeshes(RenderMesh[] renderMeshes, NativeArray<LocalToWorld> localToWorlds, LocalToWorld rootLTW)
{
List<RenderMesh> results = new List<RenderMesh>();
Dictionary<string, List<CombineInstance>> combines = new Dictionary<string, List<CombineInstance>>();
Dictionary<string, Material> namedMaterials = new Dictionary<string, Material>();

        for (int i = 0; i < renderMeshes.Length; i++)
        {
            var renderMesh = renderMeshes[i];
            var LTW = localToWorlds[i];
            
            var material = renderMesh.material;
            if (material != null && !combines.ContainsKey(material.name))
            {
                combines.Add(material.name, new List<CombineInstance>());
                namedMaterials.Add(material.name, material);
            }
            CombineInstance ci = new CombineInstance
            {
                mesh = renderMesh.mesh,
                transform = rootLTW.Value * LTW.Value
            };
            combines[material.name].Add(ci);
        }
        foreach (var namedMaterial in namedMaterials)
        {
            RenderMesh result = new RenderMesh();
            result.material = namedMaterial.Value;
            result.mesh = new Mesh();
            result.mesh.CombineMeshes(combines[namedMaterial.Key].ToArray(), true, true);
            results.Add(result);
        }

        return results.ToArray();
    }```
#

combines meshes based on their materials (since you can't combine meshes with diferent materials) and outputs the unique RenderMeshes

tardy spoke
#

Awesome! ๐Ÿ˜Ž

violet cosmos
#

So, many of the ECS examples deal with Entities and Components that are generally homogeneous... Something like a bullet hell shooter

What is the general strategy for non-homogeneous entities? Lets say I'm not making a bullet hell, but I want to leverage ECS to help organize multi threaded Jobs by component easier. Do I pay a penalty, or is it just a "penalty by contrast"?

safe lintel
#

"I want to leverage ECS to help organize multi threaded Jobs by component easier. " what do you mean?

violet cosmos
#

I can make Jobs without ECS, just need to manage them and organize the data layout myself

#

So in "pure Jobs" if I have 30 things, I need to collect the data from all 30, pack that into NativeArrays, schedule the Job and go. With ECS I just write Systems (organized Jobs) that work on component sets, which seems to be better for the particular game system I'm working on, but... Like I said, Entities won't have a very homogeneous structure, so I'm curious how to avoid any pitfalls there

safe lintel
#

do you mean just if theres penalties of having lots of entities that dont have the same components? like a handful of ab and c, some with c, others with xyz and so on?

violet cosmos
#

Yah, the "archetypes" and clustering penalties

#

I don't plan on add/removing components (I understand the penalties there clearly), but don't understand the ramifications of having a variety of archetypes that are shallow

safe lintel
#

i dont think it should be a problem unless you are doing some codegen thing that creates a vast multitude of different combinations

violet cosmos
#

What's a "vast multitude"? thousands? tens of thousands?

safe lintel
#

im trying to find a forum thread where someone was doing this and ran into memory problems

violet cosmos
#

Also, mobile hardware ๐Ÿ˜„

#

Thank you, I appreciate it if you did find it

safe lintel
#

29k

violet cosmos
#

hahaha I love this comment: "Regardless, I would strongly encourage you to look at how you end up with 29000 archetypes. I'm in no position to judge whether that is a reasonable number for your game, but with that number of archetypes I'd personally be suspicious"

safe lintel
#

seems like a soft limit as previously he made over 6 million archetypes but i truly dont think this is a common need ๐Ÿ™ƒ

violet cosmos
#

Yah, I don't think I'll hit that high. Maybe a few hundred, but I'm more concerned about allocation... Maybe I shouldn't be, since these are briefly lived (only a few seconds) there's likely to be chunk holes to be filled up and it's not allocating anything

zinc plinth
#

lots of archetypes mean higher minimum chunk amount

#

so 29K archetypes = 29K minimum chunks

#

a) that starts to be alot of memory
b) the hashtable that handles archetypes won't be as fast at all as with fewer archetypes

#

and how in the world are you getting 29K archetypes anyway

tardy spoke
#

Hmm, you should be able to access a regular monobehaviour like this and change a variable no?

I'm trying to add a vector3 that moves around to decide when to load/unload Subscenes based on distance. It resides as a monobehaviour variable on the Subscene GO itself.

Additionally I want this vector3 to move around opposite to the player's movement, but I can't seem to change it's value via ECS code, even though I believe it should be able to? Unless subscenes are special compared to regular GO's, they are in a different namespace so not sure.

zinc plinth
#

do you get some kind of errors ?

tardy spoke
#

Nope, nothing

tardy spoke
#

@zinc plinth creating an ICD as a class on another GO to reference it seems to work. No idea why. Doesn't work when on subscene though.

#

So that'll work for now, but odd.

buoyant aspen
#

Do anyone here have experience with ECS? Is it stable enough for production?

safe lintel
#

yes. no.

tardy spoke
#

Depends on the phase of the moon, pretty much.

#

If by ready for production you mean that Entities 0.13 doesn't even seem to work on VR builds, then yes, it's ready.

dark cypress
#

Define production.

#

Can you make a good game with it?

#

Yes.

tardy spoke
#

Define "enough".

tight blade
#

oh my god mother f****ckers I finally did it. behold my triumph

#

the one that is in line floats farther than the one moving broadside laterally. the one with its nose out of the water drifts the farthest. the one that is flat is turning towards the other boat because its drafting off its movement

tight blade
#

Lol I'm so bad at capturing video. No one is able to see that video are they?

dark cypress
#

You can see the second half if you manually click at 13s.

tight blade
#

Hahaha perfect.

proper silo
#

Hello! Quick beginner and maybe stupid question, but can you schedule job (IJobParallelFor) inside an Entities.ForEach loop, which is also scheduled? It sounds like something you shouldn't do, but I am curious

mint iron
#

nope

proper silo
#

Damn

#

So, if for example I have a system that cast a ray along the forward of an entity, and if this ray collide I turn the entity 1 degree, I have to make the raycast test in the forEach, with the rest of the code that turn the entity ?

dark cypress
#

You can make multiple jobs that run sequentially in one system and pass data in native containers or components between them.

proper silo
#

Humm I see, but since I need the entity's forward for the raycast, and it's rotation for the, well, rotation, I could do something like 2 consecutives entities.ForEach, and having the second one depends on the first ?

dark cypress
#

What are you trying to do with the nested .foreach anyways?

proper silo
#

To be honest, I am not sure. I feel like having "too much different stuff" happening in one .foreach is not the optimal way to do things, like having the raycast test with the physic and such + any movement depending on the result of said raycast in just one .foreach

tardy spoke
#

@tight blade that's awesome. What project is it for? Haha

tight blade
#

yeah nevermind its still broken haha, the draft way overcorrects when it gets a sudden impulse thrown at the boat

dark cypress
#

Yeah, if you want to split up the check/action, you could use 2 jobs. Although if you're not using the result of the check in any other place you'd need to think if the split offers you any performance gain(probably not).

tight blade
#

lol, it'll be a game one day. sailing game, is the idea

#

turns out drag is really hard.

#

who knew.

proper silo
#

Make sense! Thank you @dark cypress for taking the time!

dark cypress
#

Is there any way for me to use MeshData.SetVertexBufferParams() if I don't know the number of vertices the job will generate? Or is the size parameter "capacity" instead of a hard size?

violet cosmos
#

Hm, so IJobForeach is going away? It seemed like a nice way to mark up classes

#

So... How do I make ordering dependencies with just Entities.ForEach() between different systems to have a precise order of operations?

dark cypress
#

The same way. Use the UpdateBefore/UpdateAfter for the systems, and pass the handles around in Schedule().

violet cosmos
#

So... I have to pass job handle references around each system?

dark cypress
#

How were you doing it before?

violet cosmos
#

I thought things implementing SystemBase were automatically loaded and executed

#

I wasn't, I'm writing something new

dark cypress
#

They are. All jobs Scheduled() in an OnUpdate() of a system automagically depend on eachother.

#

You pass the handles if you want finer control.

violet cosmos
#

How do I pass the handles from one automagically run SystemBase class to another automagically run SystemBase class?

dark cypress
#

What are you trying to achieve? System1.Job1>S2.J1>S1.J2>S2.J2?

violet cosmos
#

No, in ECS you're recommended to write a number of Systems, correct? Each doing something discreet. So I want to have say, three systems. PositionSystem, TargetSystem, MechanicsSystem. They need to run in that specific order

dark cypress
violet cosmos
#

OK, so there's still that tag. whew.

dark cypress
#

I mentioned it a few posts back. Think you missed it.

violet cosmos
#

I think I did, apologies I'm still trying to wrap my head around this and ever changing examples and recent deprecations

dark cypress
#

Haha, no issues. Doing the same thing myself.

violet cosmos
#

Hm... is there something that replaces [ReadOnly] in the .ForEach parameters?

violet cosmos
#

Unity 2020.1 with ECS 0.13

dark cypress
#

in

violet cosmos
#

๐Ÿ‘

tardy spoke
#

https://youtu.be/V0_WaCKIOJU @tight blade @amber flicker @minor sluice I finally got it working, haha. Continuous Floating Origin player that loads subscenes by proximity.

Seems promising. I couldn't get the version where it moves the world in one move when a new subscene is loaded because I wasn't sure how to access any sort of callback after the subscene was done it's async loading, which would be required to then move the scene into the correct world position.

coarse turtle
#

Woah - that's pretty nice

tardy spoke
#

Haha, I'll keep you posted on how it works out. I'm so tired of working on floating origin stuff at this point... working on the actual game at some point would be a nice change of pace, hahaha

coarse turtle
#

I know that feel - I'm still working on the kinks of my 2d physics engine - I haven't really gotten to my game mechanics extensively lol

#

I did start playing around with subscenes again - hoping it'd work with some sprites I have

tardy spoke
#

Haha, when it's the foundation of your game if you don't get it right the rest of the work may become pointless, that's the problem, hahah

#

Subscenes are a bit rough to work with. They have no component on them that actually includes the correct bounds of the objects they contain, which to me is insane, because then that boundary could be used for loading them by proximity, which is one of the main reasons people use subscenes.

Secondly, I couldn't reference a monobehaviour's variable directly on a subscene from a System (withoutburst().Run()), but had to use an ICD on another non-entity to hold a reference to that monobehaviour's variable in order to change it. This could be me not understanding something simple, but it definitely seems odd. Just moving a script off the subscene to a GO works. Even moving the ICD component onto the subscene doesn't work, it has to be on a non-entity GO for the reference to work correctly, haha. It doesn't spit out any errors or anything either.

coarse turtle
#

I think for my case - I'll likely be using them to load some static entities and to declare some prefabs

tardy spoke
#

They seem good at that, at least, haha

#

If you're doing 2D Codemonkey has a tutorial on subscenes where he demonstrates them in 2D.

#

Despite ECS's rough edges I still already waaaay prefer it to OOP approaches.

Agree/disagree?

deft stump
#

can't deny. with the state of Unity's ECS right now, it's better to just do it in Classic Unity if you want something up and running asap

dark cypress
#

Isn't that the opposite of what alex said.

deft stump
#

hrmmmmmmmmmm...

#

it is

tardy spoke
#

We are now enemies

deft stump
#

๐Ÿ—ก๏ธ

tardy spoke
#

That's the whole Synty pirates pack demo scene from the asset store, it instantiates it crazy fast. Noice.

half jay
#

Does DisableRendering component will disable render for all LinkedEntityGroup?

amber flicker
#

I don't know. I would guess/expect it to only disable for the entities it's added to. If you find out differently though please report back.

half jay
#

i have hybrid render 0.5 version with ENABLE_HYBRID_RENDERER_V2 when i add component to Parent Entity of LinkedEntityGroup and its working only for parent

amber flicker
#

๐Ÿ‘ that's what I'd expect - I sometimes want an 'AddComponentDataToHierarchy' method but I can kinda understand why it doesn't exist

half jay
#

i saw somewhere that DisableRendering will enable on whole LinkedEntityGroup

amber flicker
#

it would be expensive to walk up the hierarchy for every entity.. I don't think it's likely... there might be some utility method that automatically adds the tag to all of the children though

stone osprey
#

ECS question ( not unity in general )... I wanna recreate the "Buffer-Systems" from unity to execute some stuff at the start/end of a frame... i can either do this by : "OnStartComponent{action}, OnStartSystem iterating over them to call the actions" or by "OnStartSystem.buffer(action)"... so either by using a component or by direct acess... what would you choose ?

tight blade
#

nicely done, @tardy spoke !!

#

anyone know a good way to do a ground check with unity physics?

#

@stone osprey can you give some more detail on the direct access option?

#

actually on both, Im having trouble understanding what you mean by those alternatives

minor sluice
#

@tardy spoke good job! so basically you load/unload subscenes based on the current position of the character?

#

I think for the ground check you could do it like with regular physics,
often times that might be a raycast of a bunch of raycasts (I think some people also do something like a sphere cast)
here is a tutorial with raycast example
https://www.youtube.com/watch?v=B3SFWm9gkL8

โœ… Let's check out how to use Unity DOTS Physics!
Super Performant Collisions, Events, Triggers and Raycasts!
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=B3SFWm9gkL8

Getting Started with Unity DOTS / ECS
https://www.youtube.com/playlist?list=...

โ–ถ Play video
#

I think basically, you could just think of the approach you would take with a non-ecs character controller and then simply translate that

thorny halo
#

Hello, does anyone know why disposing of a nativecontainer OnApplicationQuit() causes an exception - the container has already been disposed? I'm checking if the container isCreated before disposing, yet the exception still occurs.

zinc plinth
#

why would you want to dispose on animation quit ?

#

everything is going to be freed up anyway by the OS

thorny halo
#

cause i get a crapload of errors while in the editor whenever i end play.

tight blade
#

yeah, the errors in the editor problem are really a bummer

#

gon fill up my hard drive before long

#

and it prevents me from using flythrough in my scene navigation

zinc plinth
tight blade
#

are you suggesting there's something that I can do from my end to fix that?

zinc plinth
#

I know that I had this error when I destroyed a system, so I just disabled it instead

tight blade
#

hmm. I definitely am not intentionally instantiating or destroying systems in my code. I wasn't even aware thats something I could do

amber flicker
#

usually using using {} is useful... unless under unfortunate "pass container by ref to static method" circumstances where upon it becomes use-less

#

I did have issues when I briefly tried using static native containers - now I just avoid them

#

They're not ideal due to the whole domain reload issue anyway

tardy spoke
#

@half jay from my experience DisableRendering doesn't affect the entire linked entity group

#

@minor sluice yep, it loads and unloads subscenes based on proximity to character. It's a bit trickier than it sounds though because you have to create an alternate system for the detection and have it hold a reference to the subscene. There might be a smarter way to do it, but I couldn't figure it out, haha.

Subscenes also seem to not quite act like regular entities or regular GO's in some odd respects.

amber flicker
tardy spoke
#

What does that mean exactly? haha

amber flicker
#

at the moment if you have a tree and put one in each of 1000 subscene tiles, the project will have the size of 1000 trees

tardy spoke
#

ah

amber flicker
#

I didn't intend for that to be a Stereophonics reference

#

darn motion blur being so expensive on hdrp.. it's pretty

tardy spoke
#

I havent ever touched HRDP yet. Ive been using my one vertex color shader with no lights for tests for months now. I've forgotten what good graphics look like at this point.

#

I wanted to make my own little render pipeline but it looked pretty intense haha

amber flicker
#

๐Ÿคฃ don't worry.. no good graphics over here, it just makes primitives look more interesting

tardy spoke
#

Hah that does look cool.

amber flicker
#

motion blur ~1.5ms for 30k dynamic meshes.. it's not terrible.. I'm just looking at 20+ unused threads for a large part of hybrid renderer v2 + hdrp ๐Ÿ˜ฌ (edit: seems srp batcher related.. dunno)

tardy spoke
#

I really need to learn how to use the profiler better. Been putting it off... seems super handy though, haha.

#

Sometimes I look at it to feel smart.

amber flicker
#

do it.. super handy. In case it's useful @CiroContns did a good intro recently https://t.co/y1corSxu96?amp=1

Profiling is one of the best ways to optimize your game. In this session, learn how to use Unityโ€™s highly effective profiling tools and how to interpret the data they produce.

tardy spoke
#

Awesome! Was just googling for some good tutorials, haha

violet cosmos
#

ProfileMarkers is one of the reasons I moved to 2020.1 from 2019.4LTS

#

To me, if you're using the DOTS tech stack, but don't have a grip on Profiling.... You're kind of shooting around in the dark

tardy spoke
#

Since i've only been programming for a few months... I live in the dark. Like batman.

#

Best way to learn is to walk into walls and shit. Makes you want to turn lights on, hahah.

radiant sentinel
#

Hello, how can i create a world and assign my systems to that?

tardy spoke
#

@radiant sentinel an extra world besides the default world?

radiant sentinel
#

Yes> @radiant sentinel an extra world besides the default world?
@tardy spoke

#

I want other worlds to calculate data of my players and more as systems but i cant find how to create new world at google.
@tardy spoke

#

I want create matchmaking system to handle online game matches

coarse turtle
#

var otherWorld = new World("Other World");

radiant sentinel
#

Yes i have created but when i using GetOrCreateSystem
Icant see my system at entity debugger.@coarse turtle

coarse turtle
#

Ah im not sure about the entity debugger - tbh I haven't really been using that lately

radiant sentinel
#

I can find world at entity debuger, but its empty and not any system exist

coarse turtle
#

Hmm yeah sorry, I'm not sure about having it show up in the EntityManager/Systems window

tardy spoke
#

I thought I read that that wasn't implemented yet but I'm not sure

radiant sentinel
#

I thought I read that that wasn't implemented yet but I'm not sure
@tardy spoke
Thats mean i cant create new worlds?
Sry my English is not good

tardy spoke
#

@radiant sentinel I'm not sure if this is correct. I believe you can create new worlds, but you can't see their entities listed in the entity debugger yet. I could be wrong.

radiant sentinel
#

Ok no problem, thank you for answer
@tardy spoke @coarse turtle
I will test systems without checking entity debugger window.

tardy spoke
#

No problem! ๐Ÿ‘

quasi trellis
#

you might want to select the Show Inactive Systems option in the entity debugger as your system probably never ran

feral plover
#

Hello! Im pretty new at coding C# jobs, and im having some issues when destroying objects that are on a native list. How can I destroy an object and re arrange the list?

coarse turtle
#

Well, NativeList<T> can't store managed objects (only structs with blittable data)

feral plover
#

I mean, it is a float3 array, it stores positions of my instantiated objects, but when I destroy one of them I get memory leak error

coarse turtle
#

Just to clarify, what do you mean by destroy one of them? Like remove one of the float3 from the NativeList?

feral plover
#

yeah, I made and object spawner, those objects are explosive objects, and once their hp reach 0, they explode and destroy themselves. That makes a hole in the array, because there will not be an object anymore

#

Should I show code of the spawner?

#

Im not even sure if im implementing jobs well here

coarse turtle
#

Well typically you can remove an element from a NativeList<float3> by using the RemoveAt or RemoveAtSwapBack function calls

feral plover
#

true, but bomb class and spawner class are different

tardy spoke
#

I'm a bit confused because I believe NativeList has to be value types (blittable or whatnot), not reference types? Is there some sort of reference to the hitpoints or is another system writing the new values to the NativeList?

feral plover
#

I think im doing pretty much nothing of jobs there, there are many things that Im not understanding about jibs

#

jobs*

coarse turtle
#

Where are you trying to destroy the element in the code?

feral plover
#

in another code, in the bom script

#

it destroys itself once hitpoints reach 0

coarse turtle
#

hmm okay, so I'm thinking the first piece of code, the List<prefab> contains the GameObject containing the Explosion MonoBehaviour

#

so an idea, is to possibly assign an index to each Explosion GameObject that corresponds with the index in your NativeList<float3>

#

when the Detonate function is called, you can collect all of your indices of elements you need to remove and remove them from the NativeList<float3>

#

when you do that - you probably want to update all of the remaining Explosion GameObjects with updated indices as you're now manipulating the size of the list and indices that are removed in the middle of the list needed to be shifted up to be remapped

#

so if you had 6 potential explosions and the 3rd index detonates:

[ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ]
[ 0 ] [ 1 ] [ 2 ] [ x ] [ 4 ] { 5 ] <- shift 4 and 5 down to 3 , 4 and update your indices
feral plover
#

hmm okay, so I'm thinking the first piece of code, the List<prefab> contains the GameObject containing the Explosion MonoBehaviour
yeah

#

Ohh I got you

#

I will try that

#

Ty bud

#

well, I didnt work

#

Im gettin error at the same line

coarse turtle
#

Well keep in mind that on line 75/76 of the first script, you're already disposing your NativeArray<float3> so by the time the next frame occurs, the data no longer exists and you're spawning new gameobjects and allocating new NativeArray<float3>s

feral plover
#

Well keep in mind that on line 75/76 of the first script, you're already disposing your NativeArray<float3> so by the time the next frame occurs, the data no longer exists and you're spawning new gameobjects and allocating new NativeArray<float3>s
well, thats true, however the error is happening at the instances array

coarse turtle
#

what's the error exactly?

feral plover
#

it is not finding the object once it has exploded, including != null in the list isnt working

coarse turtle
#

You might want to explicitly assign null to the index for cleanup, I don't think Destroy will handle assigned references

feral plover
radiant sentinel
#

it os active> you might want to select the Show Inactive Systems option in the entity debugger as your system probably never ran
@quasi trellis

#

Oops sry for image

#

I should add world to any update system?

low oasis
#

I'm trying to figure out where the best point would be in the player loop to copy entities from one world to the default world, AND have the systems in the default world have access to them this loop. Is it better to do this in a MonoBehaviour or create a system to handle it? Is there something along the lines of a command buffer that can be used?

gilded glacier
#

are there any details about blob assets ?

tardy spoke
gilded glacier
#

yeah ... maybe a bit more detailed ...

#

or more precisely, whether it's worth using it, or rather access the data different way

#

like storing non-blittable objects (prefabs, materials, ...) in an array accessed from systems

#

using index stored in an entity component

tardy spoke
#

Blob assets are immutable so they can't store non-blittable objects afaik. So you'd have to do it another way?

gilded glacier
#

somehow I managed to store material reference in it

#

maybe I've done something forbidden ...

tardy spoke
#

Try changing it, should get an error

gilded glacier
#

well, if blobs can only be used with blittable data, then how should I store and refer the non-blittable data, such as materials ?

tardy spoke
#

What's the type of the reference you have it holding or whatnot?

hollow sorrel
#

@radiant sentinel entitydebugger only shows worlds that are scheduled to update by the player loop
if you add it using ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world); it should work

gilded glacier
#

@tardy spoke I don't understand ... I have a BlobAssetReference with a type of struct that contains reference to material in the diamond

dark cypress
#

refer the non-blittable data
In jobs you don't do that. Jobs are blittable-only.

#

I store my references in global statics.

#

And refer to them on the main thread.

#

Sorry, I meant parallel or burst jobs are blittable-only.

#

You can have normal code on a main thread job.

gilded glacier
#

@dark cypress that's what makes most sense to me, but I am very uncertain since there are not many information on this topic

tardy spoke
#

I'm not really sure if there is a "good" way to do it yet, I see a lot of people holding references to materials on GO's, etc.

dark cypress
#

GOs are just statics with extra steps, no?

#

At some point you need a global reference.

gilded glacier
#

I use a singleton

#

well, it actually is a singleton only because I store bundles in it

tardy spoke
#

@dark cypress I'm not saying it's a better approach, probably worse, just saying that's the way I see a lot of people handle it

gilded glacier
#

and I eventually want to unload it, so I have to keep the reference somewhere

#

I use GO only for the bootstrap script

#

and for some scene input data, which can be assigned via the script in inspector

tardy spoke
#

@gilded glacier you should be able to access the materials in your singleton if the job isn't parallel like @dark cypress said? Would that be suitable for what you're doing?

gilded glacier
#

I suppose

tardy spoke
#

Are you looking for a solution that runs multi threaded?

gilded glacier
#

I expect that systems that use non-blittable data, such as the renderer, would have to be run on the main thread

tardy spoke
hollow sorrel
#

@low oasis if it's just specific entities (as opposed to copying entire world) you could prob use one of the ECB's from the default world
this also means your custom world has to update before the ECB that you're using
e.g. you could use beginsimulationecb and have your custom world run before Update, for example earlyupdate or preupdate

tardy spoke
#

That's my hacky way to do a lot of stuff. Probably pretty slow, but easy for prototyping, haha.

gilded glacier
#

looks like the entire programming profession can be renamed to duct tape programming

#

no clean solution for any problem

dark cypress
#

There is, however, the cleanest solution ๐Ÿ™‚

#

Just gotta find it

tardy spoke
#

No clean solution yet, but there likely will be in time. DOTS technically isn't even "released" yet, haha.

#

They made it invisible in the package manager even on 2020.1

gilded glacier
#

@dark cypress I try, but I look like a lunatic

tardy spoke
#

I'm actually not sure what the plans are for dealing with reference types in ECS... I think they may just be observing the ways people are currently doing it and figuring out how they'll handle it, haha.

#

Could be worth looking at any demo scenes they have and seeing how they do it.

gilded glacier
#

or they'll break them into the elemental data and compose it into components

#

isn't unity supposed to be run using dots internally ?

tardy spoke
#

nah, it uses job system internally

#

Maybe eventually they will though. I think a lot of the DOTS stuff is built on layers of DOTS

safe lintel
#

i mean all these packages are the engine

#

the whole burst+entities+collections+physics+buildplatforms etc etc are the new internal guts, its just now visible for us to see whats going on.

tardy spoke
#

Anyone doing a lot of tests for their ECS code? Wanted to try that out soon

#

Is the ECS test suite rough around the edges or solid?

safe lintel
#

my tests are: play mode & copious amounts of debug.log ๐Ÿ˜…

tardy spoke
#

Lol, yep, same. Trying to get something in place before scaling to too many systems and stuff.

hollow sorrel
#

only using a couple since not a big fan of unit testing in general but the test framework seems pretty solid imo

#

but unity just uses NUnit internally which is also used for a lot of regular C# projects so makes sense that it's solid

#

it's not something unity built so higher chance of being good

tardy spoke
#

I imagine testing in general becomes a diminishing return, due to coupling of tests and code

#

Eventually you spend more time fixing tests if you have full coverage than hunting bugs down and squashing them without the assistance of tests, haha.

coarse turtle
#

Anyone doing a lot of tests for their ECS code? Wanted to try that out soon
@tardy spoke I pretty much write a lot of editor tests to "unit" test systems

tardy spoke
#

Haha @hollow sorrel cool, I'll look into it. Good to know the tech it's built on.

#

@coarse turtle what's that look like in practice?

coarse turtle
#

hmm I think it's pretty simple

#

you pretty much set up entities to test out a scenario

tardy spoke
#

In web stuff we had like, unit tests and integration tests / end to end tests or whatever, what's the usual go to approaches for game dev stuff?

coarse turtle
#

so I think that varies per person, I mostly just end up spawning a few entities setting up a few scenarios, constructing the system and calling system.Update() and assert on the data of the components

tardy spoke
#

Interesting. Yeah I figured the preferred approach might change because in the web dev stuff you were not often dealing with "time" in the form of an update loop in the same way. Mostly just testing static logic

#

Thanks! I'll watch it asap

coarse turtle
#

A good boiler plate for setting up the test fixtures is the ECSTestFixtures in the Entities package

zinc plinth
#

how would one create a hash of a vertex buffer ? it seems like alot to process really fast if I want something accurate

dark cypress
#

What do you need to hash the entire buffer for?

zinc plinth
#

I'm combining meshes and due to what I do I'm combining the same stuff at diferent places in the world; I want to cache my meshes to be able to batch them

#

the easiest way would be to hash the buffer I guess ?

radiant sentinel
#

Guys please help me at creating new world
I need an example and all examples are old

#

Unity changed everything at new releases and examples not working

hollow sorrel
#

@radiant sentinel entitydebugger only shows worlds that are scheduled to update by the player loop
if you add it using ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world); it should work

radiant sentinel
#

Yes its work, thank you, but i have not same systems for multiple worlds. But it is show me same systems

#

@hollow sorrel

hollow sorrel
#

what do you mean?

radiant sentinel
#

I want create different systems for my new world. But i will see default three groups, same as default world

#

Sry for my English

hollow sorrel
#

ah yea

#

do you want to manually update your world? or do you want unity to schedule it

radiant sentinel
#

Unity scheduler is better, can i have custm systems with unity schedule

#

?

hollow sorrel
#

yes

#

unity sorta assumes you always have a init, simulation and presentation group as your root level systems in each world, but which ones get added under that is up to you

radiant sentinel
#

Thats mean i have 3 groups by default but in their child systems are different

#

I have upgraded to unity 2020.2 for 0.13 entities package, now i have new functiona at scriptBehaviorUpdateOrder, ill try them and i will ask you again, can i ask?

hollow sorrel
#

you can see how the default world gets instantiated in packages folder
Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs
two relevant parts are GetAllSystems() and AddSystemsToRootLevelSystemGroups()
so what you could do is
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
which will basically look for all ComponentSystemBase in your entire project and add them to a list

then you can create a new method that filters the list of all systems to just the ones you want to add
for example if you were to create your own Attribute [CustomSystem] or whatever that only gets added to the ones you want in your custom world, you could then do

foreach (var type in systems)
{
  var attribute = type.GetCustomAttribute(typeof(CustomSystem));
  if (attribute != null)
  // add system to custom world
}
#

or if you are using multiple worlds, create an UpdateInWorld attribute with an enum

#

one thing to keep in mind here though is that you must add it to one of the toplevel groups (such as SimulationSystemGroup), free floating systems that are in your world but not updated by a toplevel group won't get updated

#

with addtosystemupdatelist

radiant sentinel
#

you can see how the default world gets instantiated in packages folder
Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs
two relevant parts are GetAllSystems() and AddSystemsToRootLevelSystemGroups()
so what you could do is
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
which will basically look for all ComponentSystemBase in your entire project and add them to a list

then you can create a new method that filters the list of all systems to just the ones you want to add
for example if you were to create your own Attribute [CustomSystem] or whatever that only gets added to the ones you want in your custom world, you could then do

foreach (var type in systems)
{
  var attribute = type.GetCustomAttribute(typeof(CustomSystem));
  if (attribute != null)
  // add system to custom world
}

@hollow sorrel
thank you, thanks a lot

hollow sorrel
#

np

zinc plinth
zinc plinth
#

I definetely can get the vertices from the origin meshes tho ThinkMan

zinc plinth
#

^ what I was seeing was my source meshes still being renderer for some reason, my combined mesh's vertices are all indeed on 0, 0, 0

radiant sentinel
#

@hollow sorrel hello again,
i want default player loop for default world and my custom player loop for myWorld world. can i have both of them?

#

@hollow sorrel hello again,
i want default player loop for default world and my custom player loop for myWorld world. can i have both of them?
@radiant sentinel ,thank you , i got my answer. thats true ,the system is working at background but i cant see that ๐Ÿ˜„

hollow sorrel
#

@radiant sentinel yeah adding custom world to playerloop doesn't overwrite the default one

#

or shouldn't at least

#

but sounds like you figured it out

zinc plinth
#

I hate that entity debugger makes it seems like the renderer is taking so long but it's just the physics rebuilding --'

#

I need to switch off using one collider per tile :x

#

(this is 10K colliders)

#

I'm already cutting pretty big corners by just disabling LocalToParent updates for my hierachy when I don't move anything

hollow sorrel
#

daymn

#

does it display that way because it's presentationgroup that's waiting for physics jobs to complete? weird it doesn't just show it as physicsjobs.complete or whatever

#

weren't you making a tile based game

#

what's the colliders for

zinc plinth
#

raycast on grid to get grid tile entity, and then get the rest

hollow sorrel
#

ah i was gonna mention you can just convert mouse pos to tile pos but i guess that won't work if you're trying to select tall buildings by clicking the top and the camera is tilted

#

you could prob get away with mouse pos to tile pos for a lot of small things tho

zinc plinth
#

I'm prob still gonna raycast, but I'll use my new combined meshes and get an offset coordinate in local space from LTP of the entity I raycasted

#

since I can throw at minimum 20 by 20 patch of tiles per combined mesh

#

but that will be when I fix my coordinate problem in the combined meshses >.>

hollow sorrel
#

what's the benefit from raycasting here

#

out of curiosity

zinc plinth
#

well how am I getting entities otherwise ? I need local space coordinates to get the correct index in my grid tile buffer

dark cypress
#

What do you mean by "local space coordinates"

hollow sorrel
#

don't you have a way to get an entity at a coordinate

zinc plinth
#
bool haveHit = collisionWorld.CastRay(input, out hit);
            if (haveHit)
            {
                Debug.Log("hit");
                Entity hitEntity = physicsWorldSystem.PhysicsWorld.Bodies[hit.RigidBodyIndex].Entity;
                EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
                var parent = em.GetComponentData<Parent>(hitEntity);

                LocalToWorld gridTransform = em.GetComponentData<LocalToWorld>(parent.Value);
                var transformMatrix = (Matrix4x4)gridTransform.Value;
                var localPos = transformMatrix.inverse.MultiplyPoint(hit.Position);
                return new RaycastResult
                {
                    Entity = physicsWorldSystem.PhysicsWorld.Bodies[hit.RigidBodyIndex].Entity,
                    originPosition = camera.transform.position,
                    LocalHitPosition = localPos
                };
            }``` @dark cypress
#

at a grid local space coordinate yes, one tile is 1 unit forward in x and z @hollow sorrel

#

which I get from my buffer

hollow sorrel
#

what's stopping you from converting a world pos to grid local space

#

you have your local grid offset right

zinc plinth
#

needing a world pos in the first place??? why do you think I do a raycast

hollow sorrel
#

but raycast is just a less efficient way of achieving the same

dark cypress
#

I'm not sure why you need thousands of colliders.

#

You can achieve this with just 1 per grid or 1 per world if grids are in a pattern.

zinc plinth
#

how is a screen to world raycast not the way to get a world pos on a plane?.. @hollow sorrel

and I said I needed to change that but for now I took the easy route @dark cypress

dark cypress
#

Give developers more RAM and they'll eat it I guess.

zinc plinth
#

it's not even ram it's just cpu time

#

if the physics world wasn't damn rebuilding itself every frame

hollow sorrel
#

because it's a grid
you know exactly where it is because you have the grid position in your world
you know exactly where the player is trying to click
you can know exactly what tile a player is trying to click instantly because you just take the offset from the grid

#

it'd be instant that way

#

0.001ms cost

zinc plinth
#

I want tiles to be free from eachother, so not possible

hollow sorrel
#

what do you mean free

zinc plinth
#

think 3d chess (literally)

#

but under the hood they're on the same grid

hollow sorrel
#

it doesn't matter how much space there is between the tiles, even if your grid tiles are moving all over the place you could still get their tile position in world

#

because you're already tracking your grid

zinc plinth
#

you know exactly where the player is trying to click
we know the mouse position on the screen, no world pos

#

and each tiles don't have the same offset from eachother

hollow sorrel
#

hmmm ok fair, my mind started focusing on 2d representation for some reason
but in 3d you could just give one collider to your entire grid floor, then you have the world pos the player is trying to click

zinc plinth
#

what did I say earlier --'

#

I'm prob still gonna raycast, but I'll use my new combined meshes and get an offset coordinate in local space from LTP of the entity I raycasted
@zinc plinth

hollow sorrel
#

ah

zinc plinth
#

you can't add chunk components right after creating an entity with an archetype

#

ayy works if I add it to the archetype with ComponentType.ChunkComponent

tardy spoke
#

How lucky. It pisses me off every day. ๐Ÿ˜„

#

Anyone know a quick way to figure out how to detect any unused components or systems?

zinc plinth
#

unused component ?

#

ho

#

fun

#

so, if you have the DisableRendering component on an entity with a RenderMesh, it will still get processed by HDRP

#

and make my hdrp loop go from 2ms to 27

#

so I have to destroy my entities while I could need them in the future to rebuild new combined meshes

#

great

low tangle
#

dots isn't finished and the hybrid renderer is really unfinished

#

you accept this when you start using it

zinc plinth
#

did a forum thread cuz seems like no one asked before

dark cypress
#

I read in the docs that .WithChangeFilter doesn't care about writing to the component, but rather about a system being ran that declared write access to it. But that's not what I'm seeing. I have an system that declares write access to my NeedUpdate component every frame, but only writes into it if an update occured. A system that has .WithChangeFilter<NeedUpdate>() however, isn't ran every frame, only when the actual write happens.

rancid geode
#

If the system that declares write access didn't run this frame, then it doesn't trigger the change filter

#

But if your system declares write access runs this frame but didn't touch the component at all it will still trigger the change filter

dark cypress
#

It runs every frame. It's a system that responds to mouse clicks, so the only variable there is the InputMouseButtons component which is written to every frame. The system just checks whether a button was clicked from that component and sets the update component if it was.

rancid geode
#

How is your code?

#

If (mouseClick) Entities.ForEach((ref Translation t) => { if (someBool) t = default; }).Schedule();

If you put the code above inside a system that forcelly runs everyframe, it will trigger the change filter for Translation every frame that mouseClick is true, even if someBool is false. If mouseClick is false, even if the system runs, it will not trigger the change filter

dark cypress
#

Wait you can do that?

#

You can do foreach conditionally?

rancid geode
#

Yes, you can

dark cypress
#

It seems like a compile-time construct.

rancid geode
#

It seems like a compile-time construct.
@dark cypress foreach compiles to IJobChunk, the same way that you can conditionally run an IJobChunk, you can conditionally run a ForEach

#

You can see the generated code in the Dots Compiler (is that the name?) window

dark cypress
#

That's great.

#

What you said doesn't seem to be correct though. This query is shown in the debugger as having entities matches and the system is shown to be running.

rancid geode
#

The system running doesn't mean that the entities.foreach is running

#

It just means that the OnUpdate is getting called

#

If any of the Entities.ForEach matches the system OnUpdate will be called, but the Entities.ForEacg may not be called (lile in your case due the mouse button not being pressed)

dark cypress
#

That makes sense.

rancid geode
#

It is a little confusing, but just because Entities.ForEach involves much "magic" (actually is just code gen, but is not all explicit what is happening without already knowing how it works or looking into the dots compiler)

#

Thus why I usually use IJobChunk directly instead

deft stump
#

what are the several ways i can do to check if an entity is still seen by the camera?

opaque ledge
#

maybe this can help

opaque ledge
#

new burst and platform package ๐Ÿ‘€

deft stump
#

I already got it

#

hahaah looking at the code

#

I dont know what I'm looking at

zinc plinth
#

also new mathematics package for the first time in like half a year lol

#

nvm a year*

north bay
#

Does anyone remember the link that contains all the different packages in a json format? That was posted here some time ago

deft stump
#

the different packages that you need to install manuall now?

north bay
#

No the json which i think the package manager uses to populate it's content

deft stump
proper silo
#

Quick question, I just want to be sure that I understand what is happening here on how to create/set a singleton entity (fond in the official documentation).
So the code goes something like:

  • get the EntityManager
  • Create an Entity with the component you want the singleton to be
  • Create a querie that will get the entity we just created (?)
  • Set the component of said entity to a "new Singlet" (?)

Is it what is going on? It feels not very "natural" so I have some doubts

deft stump
#

the last 2 lines is an example when you need to get a singleton entity in a system

proper silo
#

Oh, you do not have to specify that a component is a singleton when creating it ?

proper silo
#

Damn, I guess I wasn't looking at the correct/latest documentation! Thank you!

tight blade
#

have any of you guys used singletons? I want to increment a count during my conversion system, and access that count rather than having to query for the total number of entities in that archetype....

#

but singletons...

#

are so...

#

weird

#

oh damn look!

#

@proper silo is fighting the same battle!

#

have you had any luck?

proper silo
#

Hahaha @tight blade , right now I am just trying to create one, but I'll let you know if I manage to go further than that !

tight blade
#

ugh, man its enfuriating

solemn pelican
#

Why do you need a singleton to increment a static counter for a class?

tight blade
#

Do I not? theres a conversion system and a running system. the running system needs to get that count. is there some easier way to just increment some globally accessible integer?

solemn pelican
#

Singleton = you only want one of a class to exist.

tight blade
#

Im not a C# guy by trade

solemn pelican
#

In the awake/constructor add 1 to a static "numInstances" variable of the class. The static means that there's only one per class for all class instances, and they share it. :)

In the Destructor/OnDestroy/whatever, decrement the counter.

DOTSify this, contextually, however all that works. I just followed you here from shaders to help. But singleton probably doesn't mean what you think...it means "only one instance of this entire class can exist...one time."

tight blade
#

hahaha, thats awesome! thanks for following ๐Ÿ˜…

solemn pelican
#

IDK if DOTS already keeps some counter somewhere though.....

tight blade
#

Yeah, that would be lovely if it did. The description for get entity count says that it executes the query every time

vagrant surge
#

its so weird to not have native singletons

solemn pelican
#

I can't tell ya much about DOTS, so YMMV. Maybe you need a separate class or something that not DOTSy.

vagrant surge
#

i mean, it takes about 15 minutes to implement them into an ecs

#

i know because ive done it

solemn pelican
#

lololol.....and if you had a separate class to keep track of things, you'd probably want it as a singleton so you can reference it from other classes from anywhere....lol.

vagrant surge
#

i implemented them, on cpp, by just having a single hashmap

#

where key = type

#

and value = void* allocation of said singleton

solemn pelican
#

IIRC, regular C# classes can coexist with DOTS on the C# side, but you have to be careful of what you want to process.

vagrant surge
#

native singletons are super important in a ecs architecture

#

you need to store your system state somewhere

#

and stuff like accel structures

#

or bridges into external libs

dark cypress
#

What are different worlds used for? I want to understand when I'd want to use one.

tight blade
#

well, static integer incrementing works, so I guess I'm happy haha. I didn't know that static members were writeable.

deft stump
#

how expensive it is to change materials of an entity?

solemn pelican
#

Yeah, it's a throwback from C/C++ lang syntax. But static =/= const.

deft stump
#

i.e. I'm trying to flash a entity to yellow and back to blue over and over for 2 seconds.

#

given that its under a shared component. how expensive is this?

vagrant surge
#

@dark cypress you generally use different worlds to allow for better parallelism on stuff, and to run unrelated simulations

#

unity for example has its own ecs world for physics

dark cypress
#

How do worlds allow for better parallelism?

vagrant surge
#

whenever you execute a command buffer, that creates entities or adds/removes components, it requires a full multithread sync point

dark cypress
#

Oh, I see.

#

So if you have a structure that only needs to sync once per frame or something, but is otherwise separate, you can use that to cause less sync points on the main world.

vagrant surge
#

indeed

#

another great use for them

#

is for stuff like level loading

#

or procedural generation

#

you can have a background world where your "mid load" stuff is held

#

and then you copy the entities from there into the actual runtime world

#

copying entities beetween worlds is pretty cheap

#

but yeah those are the main uses of it

dark cypress
#

Thanks, that's helpful.

tardy spoke
#

Interesting

#

so, if you have the DisableRendering component on an entity with a RenderMesh, it will still get processed by HDRP
@zinc plinth I assume that's also true for URP? Because that's not ideal, haha.

#

Performance by default except for the most obvious things*

zinc plinth
#

I don't know for URP

tardy spoke
#

No worries, I'll check

zinc plinth
#

finished my mesh combining + hashing/batching

trying to think of what to do next ThinkMan

hollow sorrel
#

what'd you do for hashing

zinc plinth
#

math.hashwide on each vertice

#

add add the uint3 together while doing it

#

it's not optimized yet cuz the hashing itself could get thrown at a IJobParallelFor while it's a IJob for now

#

but since all of that is done at game start..

#

also

how do I create and playback a ECB myself ? if I call Playback myself I get an error saying it wasalready playbaked

dark cypress
zinc plinth
#

hoooo you create it yourself instead of from a system

#

I see

#

ayyyyyy

#

lost a full second to a system now that I use a ECB to batch all the operations for my grid tiles init

#

200ms of playback sweatymeow

hollow sorrel
#

daymn

zinc plinth
#

takes (1.2 + 1.8 + 2 + 0.9) = 5.9s to init a 200 by 400 grid resulting in 6ms cpu time afterwards

#

200 by 400 is roughly the size of the new massive island in one of anno 1800's dlc

#

and that's running with only 4 worker threads

dark cypress
#

6ms is a lot

#

16 ms is 60fps

zinc plinth
#

for 80K colliders it's not

#

I can't optimize my colliders how I want yet so I'll just wait for entities 1.0 where colliders will be impactedby NonUniformScale

solid flume
#

Please correct me if this is the wrong place to post this, but is there any way to give jobs access to large arrays without copying it for every job? I'm implementing marching cubes using the job system and have fairly large lookup tables

zinc plinth
#

and HDRP is taking half my cpu time on those 6ms

#

6 ms

#

not 16

dark cypress
#

@solid flume Why do you need to copy? A NativeArray is just a pointer, you can pass it anywhere.

mint iron
#

is that 6ms every frame?

zinc plinth
#

yea @mint iron

solid flume
#

I thought jobs copy all their data?

dark cypress
#

Yeah, they copy the pointer.

solid flume
#

Oh

dark cypress
#

And then use that pointer to refer to the original array.

solid flume
#

so native collections are basically collection pointers, and any other data is allocated separately for each job?

dark cypress
#

Anything that's not ref yeah.

solid flume
#

I'm assuming that if I want the array to exist indefinitely the Allocator needs to be Persistent?

dark cypress
#

Correct.

solid flume
#

Do I need to Dispose it on changing scenes? Or exiting the game?

dark cypress
#

If you stop using it you should dispose it.

tardy spoke
#

What's the best way to spread processing over multiple frames in ECS? For example, I have my subscene loader that needs to check 200 subscenes for distance to the player. It's easy to make it more efficient by just having it check for distance every couple seconds, but that still does all the processing on a singular frame.

Say I wanted it to check the distance to 1 subscene per each frame, so over 200 frames it would have checked them all. What's a good approach for that? Will it necessarily destroy parallel processing?

solid flume
#

It needs to be used intermittently throughout the course of the game

zinc plinth
solid flume
#

In that case, should I just have a normal c# array and Temp allocate it when i need to use it?

#

I was concerned about the potential time used in allocating and then clearing it

#

especially if I need to use it several times in quick succession

dark cypress
#

If it only happens when changing scenes it shouldn't be an issue.

solid flume
#

not necessarily. A runtime editable mesh needs that array a lot

#

I meant that its not necessary it'll be used only on scene load

dark cypress
#

Then keep it loaded. I have a global static native collection being always available for jobs.

solid flume
#

Persistent it is then. Thanks a lot

#

Do you have to dispose it manually or does it automatically get disposed if the game is closed?

dark cypress
#

OS disposes everything on process close.

solid flume
#

Is there a difference between the readonly modifier and [ReadOnly] attribute? Which should I use?

hollow sorrel
#

@tardy spoke 200 distance checks with ecs is prob so cheap that adding spreading might even be more expensive
but for things like this you could give them a batch id, then one frame process everything with id 0 then next frame everything with id 1 etc
dunno about best way but that's one way

tight blade
#

alright, here we go guys

#

@tardy spoke checkitouuuuut

#

simulatin muh water

#

dude, why are these videos never working??

#

you need to see the beginning!

tardy spoke
#

It worked for one play through for me, haha. It was incredible while it lasted!

tight blade
#

hahaha

tardy spoke
#

The green cube dropped and then things ... drifted in a way I assume they're supposed to

tight blade
#

yeah, okay if it worked for one playthrough thats enough. yeah, you can see them all appropriately interacting with each other's drag mechanics

#

im real happy anyway

tardy spoke
#

Haha excellent. Upload to Steam store ??? profit.

tight blade
#

profiiiiiiittt

tardy spoke
#

Hmm frame debugger shows the batches and everything but doesn't actually show the rendering of the frame yet with hybrid renderer seems like

solid flume
#

If I need to initialise a job with an array, does it have to be a native array even though I dont need it to be a pointer?

dark cypress
#

All arrays are pointers. Native collections just wrap it into a value type with their own safety checks to allow it to work in DOTS.

solid flume
#

Oh right I should've remembered that. I'm do dumb stuff sometimes

#

Forgot arrays are pointers

gloomy timber
#

. . .

tardy spoke
#

This is probably a pretty trivial question, but what's the best way to refactor this out? I'm going to end up with a bunch of "state" info for the player that a lot of systems will need access to... is there an ECS best practice for that kind of thing?

tardy spoke
#

Would it just be using a NativeHashMap in a singleton class or something and writing/reading data from/to it from Systems? Or is that way wrong? Hahah

#

Like a 'lil database!

tight blade
#

you mean like other than putting more fields in your singleton component?

tardy spoke
#

Yeah, because otherwise all that boilerplate will be needed for every single system, I believe

#

that requires that info haha

tight blade
#

yeah man I have no idea with that absurd singleton api

#

im amazed you got it to work at all

tardy spoke
#

GetSingletonEntity you mean?

#

Yeah, I don't know how Set works, but Get will just get the entity if only one entity has that component on it. I never actually "set" it at all, but maybe one of the conversion systems figures that out and sets it

tight blade
#

oh, is that easier? I was trying to use the GetSingleton and SetSingleton and tried a lot of permutations with no success

tardy spoke
#

I'm not sure lol

#

I was talking about a using a singleton design pattern in a class, not that method

#

like create a database by making some class that all the systems can access that's holding the player state, but I'm not sure if that's remotely correct and if that will have adverse effects on running jobs in parallel or not

#

Most of the systems would just need to read from it most of the time

tight blade
#

yeah I mean from what I see written about it, all that boilerplate seems to be pretty much necessary for the singleton system. Also, as for paralleling, it works like a regular archetype reference, so I guess every system that accesses it would have to be scheduled sequentially

tardy spoke
#

I think we're talking about two different things, what is this "singleton system" you're talking about? Hahah

mint iron
#

there isnt a set i dont think you just create an entity and make sure there's only one with that component

tardy spoke
#

Ohhh, is there a way to do a "singleton class" but ECS style in some sort of fancy "singleton System" ?

#

I haven't even heard of that

tight blade
#

not really, but yes.

#

there are some API's that are in there, but it seems like its gonna get improved on

#

its basically just an abstraction over asserting that theres only one of that archetype

mint iron
#

what i end up doing is write an extension that wraps it all like `world.GetOrCreateMyThings<Stuff>() which is basically the same as what you would do with a system, except you can define the interface and skip unitys base class bloat

tardy spoke
#

@mint iron yeah I got that confused, there's a "setSingleton" but no "setSingletonEntity"

tight blade
#

I mean I assume that's because its an entity, so you would use an entity manager setcomponent - right?

#

of course that would totally break jobs.

tardy spoke
#

What about "System State Components" ?

mint iron
#

yeah its pretty weird, GetSingleton/SetSingleton just gets/sets the component lol with a check to enforce there's only one. I guess it declares your intent which is good.

tardy spoke
#

maybe it's useful for testing or something

tight blade
#

lol, Im glad I have no global state needs yet and could just get away with a static var

tardy spoke
#

Yeah I need like a true database style state system I believe haha

tight blade
#

nahhh, you just need a good CAS

tardy spoke
#

for things like quest progress, player location, items, etc

tight blade
#

"check and set"

tardy spoke
#

I need Redux ๐Ÿค”

tight blade
#

hahaha

#

get out here, you web programmer scum

tardy spoke
#

Haha I'm terrible at web programming, I'm probably better at this than I am at that now, as scary of a thought as that is

tight blade
#

sounds like you're ready for seed capital to me

tardy spoke
#

I can't find any examples on google of anyone building a state system in ECS

#

Hmm... well this is kind of the same idea except instead of storing all state data in some sort of singleton class you could just have it floating around as various components? ... Is that... better?

Have some systems set those components and then some read. If I'm not mistaken a system simply reading IN that component could still run in parallel right? Particularly depending on the time read in that data, IE pass it into the job as a value before executing in parallel?

tardy spoke
#

I think just making a "globalState" entity is probably an alright way to proceed, but it doesn't do much about all that boilerplate in all the systems.

boreal kettle
#

So just a lil' question! Me and a friend just started developing a game using DOTS, and I'm doing all the 3D asset creations (he scripty boi). I'm not really a good programmer so I don't understand it too much, we just communicate what does what for stuff. Anyways! Should I do anything different when making assets? Since it is entity stuff, or is everything pretty much as usual? and he can just convert to entity on runtime and blip it do thing good?

dark cypress
#

You're good.

boreal kettle
#

Awesome :D

zinc plinth
#

got the singleton stuff, I just create a single entity with a SingletonTag and add all the shit I need on it; just need to make sure to only create it once Shrugging

#

SystemGroups are amazing acegikSparkles

#

things get so neat

tardy spoke
#

@zinc plinth how do you access it from systems?

zinc plinth
#

entity query with the tagGWaobloChildPepeShrug

tardy spoke
#

imagine player was "SingletonTag"

#

I'm just looking for a smart approach because it'll be no time before I have like 30+ systems and it will suck to have to change 'em all haha

#

particularly when you get to like 200 systems or more ๐Ÿคทโ€โ™‚๏ธ

zinc plinth
#

but it depends

cuz like for my InputState component in the singleton I have this, and then I GetExistingystem and grab my component

    [UpdateInGroup(typeof(StateUpdateSystemGroup))]
    public class InputStateSystem : SystemBase, GameControls.IBuildingActionsActions
    {
        public InputStateSingleton InputState;
        private EntityQuery _inputQuery;

        
        private GameControls _inputs;

        private ButtonControl _selectControl;
        private ButtonControl _alternativeBuildingModeControl;
        private ButtonControl _rotateControl;

        // https://hatebin.com/hzgncyknqh
        protected override void OnCreate()
        {
            base.OnCreate();

            _inputQuery = GetEntityQuery(typeof(SingletonTag));
            _inputs = new GameControls();
            _inputs.BuildingActions.SetCallbacks(this);
        }

        protected override void OnUpdate()
        {
            //Debug.Log("Start of frame");
            Entity singletonEntity = _inputQuery.GetSingletonEntity();

            InputState.Select = (_selectControl != null && _selectControl.wasPressedThisFrame);
            InputState.AlternativeBuildingMode = (_alternativeBuildingModeControl != null && _alternativeBuildingModeControl.isPressed);
            if (_rotateControl != null && _rotateControl.wasPressedThisFrame)
            {
                InputState.Rotation = InputState.Rotation.Next();
                Debug.Log($"new rotation: {InputState.Rotation}" );
            }
            
            EntityManager.SetComponentData(singletonEntity, InputState);
        }```
#

so I don't have 500 times the same query, but components being public from the system they're set on

#

and then I have a SystemBaseWithInputs when I need inputs in my system ```
public abstract class SystemBaseWithInputs : SystemBase
{
private InputStateSystem _inputStateSystem;
private InputStateSingleton _inputState;
protected InputStateSingleton InputState
{
get => _inputState;
}

    protected override void OnCreate()
    {
        base.OnCreate();
        _inputStateSystem = World.GetExistingSystem<InputStateSystem>();
    }

    protected override void OnUpdate()
    {
        _inputState = _inputStateSystem.InputState;
    }
}```
tardy spoke
#

Interesting! I shall research this, haha. Thanks!

zinc plinth
#

np

toxic mural
#

Are we not supposed to use SerializeUtilityHybrid? Like is it just for the hybrid conversion workflow

#

It looks like it makes assumptions about gameobjects being prefabs when not in the editor

#

I think I just saved myself a coupe hours of playmode debugging

safe lintel
#

heh i have no idea

#

i asked for clarity on it on the forums too and no answer

#

i really hope they find a way to make it just work so you can literally just call serializeworld and not need to do extra busywork

toxic mural
#

yeah I'm dreading having to get into this entity remapping after deserialization stuff

#

i can afford to put off saving/loading until (if) they spruce up the usability

#

spawning entities from JSON would be neat too

tight blade
#

anyone know of a mathematical operation to push normalized values away from 0.5? like I want 0.4 to go closer to 0 and 0.6 to go closer to 1

tight blade
#

man this is killing

#

me. I want to increase variance

tardy spoke
#

What about simply multiplying it by itself to put it into an exponential curve... haha. 0.4 * 0.4 = 0.16, 0.6 * 0.6 = 0.36 .

#

Then an additional operation on top maybe could get you where you need to go. Needless to say, I'm not super great at math. Good at problem solving though. ๐Ÿคทโ€โ™‚๏ธ

tight blade
#

right, and then id need to renormalize that

tardy spoke
#

And you do not want to renormalize it? ๐Ÿ˜ฎ

tight blade
#

no, I do want to renormalize it

tardy spoke
#

Yeah, the only thing is depending on the "curve" you want it might not be in the right "place".

tight blade
#

so, squaring it doesnt work because it moves numbers away from 1, even though it succeeds at increasing variance

tardy spoke
#

Right

tight blade
#

so like Im trying to figure out how I would remap that onto a scale between 0 and 1

tardy spoke
#

Someone will need to bust out the old TI-86 and figure out how to move the curve, haha.

tight blade
#

so that .9 is pushed closer to 1 and .1 is pushed closer to 0

#

lol, its like at that point in the night where I'm too tired to be smart enough to let this problem go for now

tardy spoke
#

I might've seen a tutorial a couple days ago that does something similar, let me have a look

tardy spoke
#

@tight blade There's also a comment at the very bottom by someone who retrofitted it to remap to different ranges. The answer is probably in there somewhere, haha.

solid flume
#

I have around 8k jobs running, and according to the profiler they take basically no time to complete, but the GC alloc from disposing of all the native arrays is taking ages. Is there any way I can avoid that?

#

Can each job dispose of its own variables at the end of execute?

#

Doesn't seem to make a difference

#

Also, I have 4 static persistent nativearrays as lookup tables, since I need them often. Every time unity builds, it throws an error that it hasn't been disposed resulting in a memory leak. How can I avoid this?

dark cypress
#

There is probably an editor hook for rebuild.

#

Could write a script for that.

solid flume
#

Do you have an idea for the GC Alloc issue? If the array is small and a fixed size (always 8 elements) is it better to have 8 variables?

dark cypress
#

I'm not informed on NativeContainer GC stuff, unfortunately.

solid flume
#

Ah. Never mind then, the solution has to exist somewhere in the docs/forums

solid flume
#

Is there anything like a nativeIntPtr?

#

So every job doesn't get a copy, but a readonly reference to a value

opaque ledge
#

i think thats only in Editor, its stripped in actual build

#

iirc it was called Disposable Sentinel, which is there to track safety for multithreading

solid flume
#

Apparently IJobParallelFor doesn't allow parallel writing

#

Is there any job that does?

minor sapphire
#

Pretty sure you just disable the restriction if you can guarantee you won't write into the same index from different threads

opaque ledge
#

โ˜๏ธ

solid flume
#

I'm using NativeList.Add

#

does that count?

opaque ledge
#

[NativeParallelDisableRestriction] i think is the attribute's name

#

you have to use NativeList.AsParallelWriter()

#

you have to make sure there is enough size before you send it to job because there is no Add method on ParallelWriter, only AddNoResize

solid flume
#

Oh

#

I don't know the size I'll need, but I can probably make a hard cap

#

I need read and write, so I guess every time I write I call the function?

#

Does that have a memory/performance impact?

opaque ledge
#

well you generally create a new native list with Allocation.TempJob before you send it to job

solid flume
#

The list is persistent. It might need to be edited very frequently so I didn't see the point in reallocating it every time

opaque ledge
#

then yeah, you have to clear/resize it everytime you are about to send it to job

solid flume
#

Is 35k too many float3x3?

opaque ledge
#

i think so ๐Ÿ˜„

solid flume
#

sigh

#

I'm doing marching cubes

opaque ledge
#

i mean you can just try it and see how it works out

solid flume
#

True that

#

Lets hope unity doesn't crash

#

I still need to mark it with the[NativeParallelDisableRestrictionAttribute]? Because its throwing the same error even with the parallel writer

#

Also it seems to be called either [NativeDisableParallelForRestriction] or [NativeDisableContainerSafetyRestriction]. Can't decide which so guess I gotta try both

opaque ledge
#

i think former

solid flume
#

Both of them work but I get separate answers

gusty comet
#

well im a god in dots

#

get it?

#

godot

#

;-;

deft stump
#

here's a clap for you

#

๐Ÿ‘

solid flume
#

I really need to find a way around static nativearray lookup tables

#

Its messing with the editor

zinc plinth
#

What do you use them for?

solid flume
#

Marching cubes

#

I think I'll just learn compute shaders and use the job system for chunking

#

Makes more sense

#

Right now this is such a pain

deft stump
#

@solid flume blob assets?

solid flume
#

Whats that

#

I fixed the lookup table issue

#

It's not an issue now

deft stump
#

ah alright

#

because blob assets are best used in scenarios such as look up tables.

solid flume
#

But the restrictions and stuff around how jobs interact with data makes this a pain. I know the fundamentals of the compute shader approach, event tho I don't know how to write one

#

What are blob assets?

deft stump
#

they're just immutable data that you can ref to and take data from.

violet cosmos
#

hehe, in .ForEach().... ref params must become before in params. Is there a reason for this?

zinc plinth
#

is there a way to prevent specific EntityQueries to enable/disable systems ?

violet cosmos
#

I'm new at this, but there's two ways: Add a "tag" component that is empty of values, but just filters the .WithNone, OR add a flag that must be processed on a component, but will be processed for each entity. There's obviously pros and cons to both

#

Hmm, what's the equivalent of setting Transform.forward with ECS? LocalToWorld is readonly

tight blade
#

@tardy spoke good tip on that post. It wasnt quite the answer, but it got me far enough to develop what I needed

coarse turtle
#

Hmm, what's the equivalent of setting Transform.forward with ECS? LocalToWorld is readonly
@violet cosmos quaternion.forward(rotation)

violet cosmos
#

math.forward(rotation.Value); ?

#

translation.Value = newPos * math.forward(rot.Value);

coarse turtle
#

Yep - just pass in the quaternion - it'll return the forward direction

violet cosmos
#

OK, sane enough. Just don't know enough API obcscura yet

tawdry lotus
#

anyone knows why PostUpdateCommands AddComponent<T> is not AddComponentData like the EntityManager method?

tardy spoke
#

@tight blade I was actually fairly drunk last night and realized that wasn't right either this morning.

I'm pretty sure you were looking for a Sigmoid curve or Richard's curve or similar. Glad you figured it out, hahah.

deft stump
#

does the Iconvertgameobject interface only gets run when I have the convert to entity script attached to the GO?

violet cosmos
#

In [GenerateAuthoringComponent] for IComponentData, is there a way to initialize based on current editor (or another componets) values? I have a value that I want to set once based on editor data (in this case, it's a cached Last Position)

tardy spoke
#

@deft stump I'm pretty sure it only works when attached to GO

#

@violet cosmos yeah, put it on a GameObject and set the values?

#

I'm probably misunderstanding you haha

deft stump
#

@tardy spoke I mean, yeah it is attached.
but does it need the Convert to Entity component to run the interface?

violet cosmos
#

@tardy spoke Well, in this case lets say you're tracking motion vectors. You need to initialize something as the "previous", if it's just zero then it's weird, right?

tardy spoke
#

Hmm, good question, I believe it doesn't need to convert to entity to run the interface because I think I had it instantiating a GO twice to two different entities and then disabling the GO

deft stump
#

hrmmm

#

I'll test it. I just needed a sanity check

tardy spoke
#

@violet cosmos you could put two pieces of data on the component, one as an initial previous value or something?

#

again, might not be understanding exactly what you mean, and also that solution may not be ideal, haha

deft stump
#

maybe he needs to save data from a previous run of the game

#

is that it?

violet cosmos
#

That's unnecessarily complex. If I initialize something on frame 45, then it has a world space position but hasn't run yet. On frame 46 it runs, and we can assume it's moved, but I need to know the position on Frame 45 the first time to accurately track the motion vector

#

So, I have a "Last Position" cached in the struct to perform calculations

tardy spoke
#

Ah, gotcha

deft stump
#

then um... why not just store it in some component?
name it LastPositionComponent

violet cosmos
#

Same problem, how do I initialize it

#

Also, if it's a component like that, then theoretically anything could touch it

tardy spoke
#

LastPositionComponent.Value = currentPositionComponent.Value - 1 ... haha

deft stump
#

initialize?
the moment it runs its already initialized.
you just need to ref it Entities.ForEach

violet cosmos
#

So, I don't like that idea

deft stump
#

Also, if it's a component like that, then theoretically anything could touch it
in practice anything can be touched

violet cosmos
#

Unless it runs last, but then it's never ran first and we're back to square one

#

So, the easiest way is to just have some sort of "constructor" paradigm. That's really what I'm asking for... What's the Initialize/Constructor process in ECS?

#

(for the entity)

tardy spoke
#

When you add a component you can set a value

deft stump
#

well for initializing it.
you CAN set/add the component in runtime via EntityManager.
And you can throw in your data while you're at it too

tardy spoke
#

If you're doing it "ECS" style I think since you have data it has to be held in a component somewhere, so I think that "lastLocation" component may need to exist. There's probably other ways of doing it but I think that would be the "normal" way?

violet cosmos
#

I guess I could have a specific job that is looking for MyComponent without a MotionVector component, then add that MotionVector, and have that run first. Seems like a wasteful lookup because then it needs to be run every frame too

#

I have LastPostion as a value in my component. The question I'm asking is about initialization based on runtime values

tardy spoke
#

btw @deft stump I just looked through some old code but couldn't find anywhere where I used IConvertGameObject so now I'm not sure if it has to be an entity or not. I'm thinking it probably does have to convert to entity, because otherwise I probably would've used it. Ended up going a roundabout way using the "GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObject, settings);" functionality a lot and I imagine I ended up doing that because IConvertGameObject converts to Entity and I couldn't grab the game object again (because it had vanished, haha).

#

If I have a value of last position that is set upon initialization, and then I have the value of next position that is calculated the very next frame, could I not calculate the vector from that?

#

because I have both pieces of data at once

#

and then set the component to new "last position" after the calc

#

A bit confusing but I think you may want lastPosition and velocity on same component?

violet cosmos
#

I do, it has the values needed on the component, including LastPosition. Just needs to be initialized correctly (and hopefully in a sane manner that I can maintain)

tardy spoke
#

Hmm, I have an example at authoring time, but I don't have one for instantiating at runtime.

#

I imagine the runtime one would be similar with AddComponentData upon instantiating and then setting the value

deft stump
#

hrmm

violet cosmos
#

Convert might be OK, just a bit annoying because so far I've got plans to make MonoBehaviour free Prefabs using GenerateAuthoringComponent instead

deft stump
#

sanity ccheck

violet cosmos
#

So I need to use an MB to initialize, which could have easily handled with some markup in the struct. Maybe I'll add that ๐Ÿ˜‰

deft stump
#
dstManager.AddComponentData(gridPanel[i], new PanelRenderBlobData {                          
PanelRenderMeshBlobAssetReference = blobAssetRef,
index = 0
});
gloomy timber
#

...

deft stump
#

this is how to add a component right?

tardy spoke
#

@deft stump I just checked, IconvertGameObject needs the GO to have convert to entity script or be in subscene

#

@deft stump I'm not a C# master but don't you need the generic type of the component there?

#

<Whatever>

deft stump
#

that works too according to intellisense

tardy spoke
#

yeah cool, just making sure, haha

deft stump
#

Intellisense is never wrong

#

probably

tardy spoke
#

It's as never wrong as the code you're writing right now.

deft stump
#

dont quote me

tight blade
#

@tight blade I was actually fairly drunk last night and realized that wasn't right either this morning.

I'm pretty sure you were looking for a Sigmoid curve or Richard's curve or similar. Glad you figured it out, hahah.
@tardy spoke

Hahaha, same, more or less ๐Ÿ˜—

tardy spoke
#

Failing at ECS leads me to drink which leads me to fail at ECS more. Vicious cycle.

radiant sentinel
#

Hello, my World.update not working
I have made a world and im using new player loop by scriptBehaviorUpdateOrder.appendWorldToPlayerLoop
Whene i call update its not work

deft stump
#

weird that I get more stuff done when I drink

opaque ledge
#

@tardy spoke where are you failing

radiant sentinel
#

Hello, my World.update not working
I have made a world and im using new player loop by scriptBehaviorUpdateOrder.appendWorldToPlayerLoop
Whene i call update its not work
@radiant sentinel
Its work if i set that player loop as current player loop

tardy spoke
#

@opaque ledge haha nah I'm killin' it, all good. ๐Ÿ˜Ž

Actually todays project has me a bit confused though, Torsina gave me a good example of implementation but it went a bit over my head just because I'm not familiar with some OO concepts like abstract classes yet, but I'm trying to figure out a good way to hold gameState in a component or some sort of container that can be called from any System

deft stump
#

what's the world called where the conversion of go happens?

tardy spoke
#

I don't mean to sound patronizing but isn't it literally called the ConversionWorld ? haha

#

Don't quote me on that

deft stump
#

well I'm trying to get its EM

opaque ledge
#

ah good good^^ I had lots of problems at beginning, thinking about ECS structures and learning you can actually put classes on your entity helped me a lot

mint iron
#

the base class approach from torsina is a good easy way to do it.

radiant sentinel
#

guys Can i have multiple world that updating without setting as current player loop?

tardy spoke
#

Yeah, I just have to do some research on OO stuff to figure out what abstracts do exactly, then I should be able to just implement it.

I don't like implementing code I don't understand because I know that'll eventually lead to disaster, haha.

mint iron
#

abstract just means its intended to act as a base class and usually has abstract members that must be implemented when u derive it.

tardy spoke
#

@opaque ledge put classes on your entity in which way are you referring?

opaque ledge
#

you can put class ICD on your entities and run a system on it with "WithoutBurst" and "Run"

#

and you can also add MB with AddComponentObject

tardy spoke
#

Right, that's how I've been doing it, haha. ๐Ÿ™‚

MB ?

opaque ledge
#

Monobehaviour

tardy spoke
#

Right, sorry, haha

violet cosmos
#

Uff, I'm having a slow brain day on this math

tardy spoke
#

I actually didn't know you could add monobehaviours to entitys... I guess it makes sense. I have a couple references to camera GO's and stuff

opaque ledge
#

i have wasted lots of time to think how should i implement UI stuff and then i learnt you can add class ICD, which made things much easier ๐Ÿ˜„

tardy spoke
#

My only issue is that currently virtually all my systems are .withoutburst and .run which makes me wonder about my software architecture skills, hahah.

#

because a lot of the ones I'm working on now need access to the player's state (location) which they have to reference

opaque ledge
#

thats not good tho, i am not really pro or anything, but why ECS is better than MB is being able to use burst which requires you to use (blittable)structs only

#

you can just take the 'snapshat' of the player state in OnUpdate method and use that in your job

tardy spoke
#

Exactly. That's why I'm trying to figure out how to hold the player/games's state in a way that will allow burst/parallelization if they just need to read it

opaque ledge
#

like

float playerHP = ManagedClassPlayer.GetPlayerHP();
ForEach(stuff) =>{
  int someRandomVariable = playerHP / 2;
}
deft stump
#

soooo

#

I have a problem

opaque ledge
#

sure

deft stump
#

and here's the code.

radiant sentinel
#

How can i update world?

tardy spoke
#

Right. Could I use a singleton class or similar for that @opaque ledge ? And then just have the systems that write to it run without burst or whatever, but the ones that read it just store it locally and run with that?

opaque ledge
#

yeah exactly

tardy spoke
#

Yeah, that was my original idea, I just wasn't sure if that was a "proper" way to do it or would lead to disaster!

radiant sentinel
#

@hollow sorrel hello, i have created worlds but i ihabe update problem

tardy spoke
#

@opaque ledge one last question, what would be the best type of container/object to store the state in? NativeHashMap?

opaque ledge
#

hmm not sure mfragger, i never did that kind of stuff, there might be a chance that GridPanelTag entities havent get created yet

#

NativeHashMap for multiple keys/values yeah

#

if you want to go for key => multiple values, you can use NativeMultiHashMap

hollow sorrel
#

@radiant sentinel whats the issue

deft stump
#

sooo how do I get the EntityManager of the ConversionWorld?

#

that MIGHT answer my problem

radiant sentinel
#

@hollow sorrel im using different player loop for each world
When i setPlayer loop of one world as current player loop, other worlds not updating

opaque ledge
#

as would wise Eizen would say..

#

"Check the source code"

tardy spoke
#

@opaque ledge awesome! I've never even heard of an object that holds a single key to multiple pair values (that's definitely not often used in javascript...), so I'm excited to find out what kind of animal that is, hahaha.

In JS you just nest arrays and objects inside other arrays and objects which is then called a nightmare. To make it even more confusing arrays are objects in JS... I wonder if they are in C# also. ๐Ÿค”

opaque ledge
#

๐Ÿ™‚

#

yeah i think so ๐Ÿ˜„

#

tho nativehashmap wont allow you to do it

#

you cant nest native containers to each other

mint iron
#

@tardy spoke https://rb.gy/lo7our this is thing for burst accessible storage - lookup databases etc. It looks scary but its not really, its just a uniform way to manage and access custom native containers.

tardy spoke
#

I have so much OOP and comp sci basics to catch up on, hah.

#

@mint iron perfect! For what I'm doing it's more important to understand the eventual goal than to implement it today. Realistically my project will take years and it's good to hit some limitations on implementations and understand the "why" of moving to different solutions, haha.

opaque ledge
#

well, if you are going for pure OOP, you cant use them in ECS anyway

#

you cant use interfaces or abstract classes (or classes at all) in jobs

tardy spoke
#

No, I mean just how the ECS system is wrapped in OOP adds a bit of a layer of complexity for me since I'm not familiar with a lot of OOP paradigms

#

even the basics of understanding what an interface is vs an abstract class etc

radiant sentinel
#

No, I mean just how the ECS system is wrapped in OOP adds a bit of a layer of complexity for me since I'm not familiar with a lot of OOP paradigms
@tardy spoke
Objevt oriented programming?
Search and learn about design patterns
Or you should learn about architectures

opaque ledge
#

which actually wont help you in ECS ๐Ÿ˜„

tardy spoke
#

Yeah totally, my very limited background in programming is all functional programming lol

opaque ledge
#

but yeah, its generally good idea to learn them in time

tardy spoke
#

which is why I like ECS, but the thing is to use ECS in Unity it really helps to know some OOP

radiant sentinel
#

which actually wont help you in ECS ๐Ÿ˜„
@opaque ledge
Finally you need oop to create an architecture

tardy spoke
#

even though yes, ECS is not technically functional programming, etc

#

You don't need OOP to create software architecture

radiant sentinel
#

You don't need OOP to create software architecture
@tardy spoke
You need concepts of that

deft stump
#

^

tardy spoke
#

You need design patterns for sure

#

IE most web-apps to my knowledge are not OOP, since javascript only implemented classes (and they're not really a full implementation) in ES2016

coarse turtle
#

functional programming ftw? ๐Ÿ‘€

deft stump
#

btw, which side are you guys on?
the I-hate-OOP side? or the I-love-OOP side?

#

I'm the former...
good lord how I hated c# when i first used it. C++ was my first love

coarse turtle
#

more in the middle, I can see how some concepts in OOP work nicely, but I've mainly came from using a C background / functional background

tardy spoke
#

I'm currently on the I hate side, but there's numerous reasons:

  1. I don't understand it well enough to understand the potential benefits
  2. My bro and dad are LISP programmers (bizarre, yes. Bro is actually employed as a LISP programmer, which is super odd. D-wave programs their quantum computer back ends in LISP - those are probably the only lisp programmer jobs that exists currently, hahah) so they're obviously biased towards functional as well
  3. You can still talk about design patterns without OOP, but a lot of people don't seem to understand that, haha. Classes are just functions holding functions.
deft stump
#

man, I remember back in college my C# prof used to grill me because I do OOP wrong.
and started... slowly... hate it AHAHAHAHA.

violet cosmos
#

OK, I'm having a serious brain fart... Can someone help me convert this. My previous routine was using Transform.forward to move and angle the object, but I'm having a bit of a struggle getting this equivalent in Transform working in ECS

            transform.position = newPos;
            transform.forward = newPos - currentPos;
tardy spoke
#

After using javascript though, C# is a beauty of a language. Typescript fixes a lot of Javascript's issues, but it's like... you gotta set it up and it adds overhead, and you gotta keep it upgraded to the right version which breaks things... having a native strongly typed language is awesome.

radiant sentinel
#

@hollow sorrel
Finally im updating a parental group at my world and its working. World.update is not working
What is problems of group.update

#

?

tardy spoke
#

@deft stump that's always the worst when you have a teacher that is so bad they actually make you despise something, haha.

deft stump
#

oh no. he's a pretty good prof. Data Struct, a subject I failed 2 times because the profs were so bad at explaining stuff, he made it very easy to understand (given with the context that its my 3rd try).
He's just an OOP fanboy. A DIE-hard-#1-OOP-Simp fanboy

tardy spoke
#

Anyone who uninspires people can be very damaging

deft stump
#

I still love C#. great language. f'n amazing!
I jsut dont like OOP

tardy spoke
#

Which imo is a teacher's main job, more so than instilling tangible knowledge itself. Most learning is self-guided throughout life in my experience.

violet cosmos
#

I think I got it with some help from the forums

                rotation.Value = quaternion.LookRotation( math.normalizesafe((newPos - placement.LastPosition)), ltw.Up);
tardy spoke
#

Agree, C# is dope. Apparently it's a clone of Java, so I feel like I'm getting twice the value, hahaha.

violet cosmos
#

Yay, ballistic motion. Need more testing but most of my previous algo seems to work now

deft stump
#

Oh Java,
I hated it the moment I wrote Hello World

#

๐Ÿ˜„

#

Passed my java course jsut by copy pasting code from my seatmate

violet cosmos
#

My favorite language was ActionScript 3

tardy spoke
#

@violet cosmos nice one! Also you may come across this but sometimes you will need to use math.mul() instead of * in various situations with the new math library, just so you're aware, haha.

#

in case you ever run into that

violet cosmos
#

Yah, I'm just trying to get it working first

#

Second day on ECS, first thing I'm converting that is mroe complicated than "move it along a line"

#

I need to keep code readable now. Micro-optimizations are later

tardy spoke
#

ActionScript 3? is that Flash? Hahah

deft stump
#

I need to keep code readable now. Micro-optimizations are later
why make comments if you can make the variables very descriptive

violet cosmos
#

Yah, I was a professional Flash dev for years. I honestly am suprised I didn't make any Flash games. Psyched myself out that I couldn't do it

tardy spoke
#

Haha programmers are interesting sort. They're super conscious about their code and see it as a representation of themselves. I wonder if that'll change in the future.

violet cosmos
#

Now I use Unity enough where I need to pay for a premium version. Which is good, and have my own VR game in progress

tardy spoke
#

What do you need the premium version for?

#

The good reason? You made over 100k with it? Hahah

deft stump
#

unity mars?

violet cosmos
#

I work with clients who have deep pockets, and so I'm obligated to buy premium

deft stump
#

aaaah

tardy spoke
#

ah, right

violet cosmos
#

It's not just my income, but the income of the people that use the end result

tardy spoke
#

Makes sense, and I mean Unity for the sophistication of the software is pretty affordable

violet cosmos
#

Yah, $30 a month is nothing for what I'm getting out of it