#archived-dots

1 messages Β· Page 87 of 1

slow epoch
#

Yep, that's why i'm thinking about having a single component with a delegate or something like that that stores the logic and something external sets the logic to the component and that logic is executed in the system

#

But i'm not sure if you can actually do that with jobs

#

Or if it follows the data oriented design

mint iron
#

you could switch based on a command type and execute a different function based on it, but problem is you can't infer a generic type from data in the component, unless its declared in the job definition. And that's not practical with hundreds of command types. An example of a job executing a generic function: https://gist.github.com/jeffvella/f4f922b21f2faf9fe67d2ad580bab033

Gist

GitHub Gist: instantly share code, notes, and snippets.

#

i think i would have a single job that goes through every command, switch on command type, and call different static methods.

slow epoch
#

Yeah that might be the best solution

#

I remember reading somewhere you shouldn't call static methods from jobs?

#

But dunno the reason why

#

Also i see a lot of ppl using static methods so i assume i'm wrong or it's some specific situation

mint iron
#

i haven't heard a good reason not to, especially if those methods are isolated to a single system/area and not being shared. its really no different than having the methods locally in the job.

slow epoch
#

I've seen ppl passing structs with the logic but i don't think that's actually needed in this case

#

But nevermind that post actually gave me a better idea of how to do it

#

Thanks πŸ‘Œ

mint iron
#

np!

vagrant surge
#

static global methods with ECS is a really good pattern and highly recomended

#

of course, pure functions so they dont give issues

tawdry tree
#

TBH pure function statics are great for helper and utility code, in general.

quaint blade
#

Hello,

Im having an issue regarding building for linux with the burst compiler package installed. I decided to work with the new Entity Component System but whenever i try to makt a linux build it gives me a couple errors. Making a build for windows works fine tho.

#

building for windows works just fine tho

mint iron
#

i'm wading through burst build issues, i feel your pain.

#

is there more detail when u click on it

stiff skiff
#

@quaint blade There is no support for cross compilation with burst

quaint blade
#

i see

#

thanks

stiff skiff
#

And where previously this would simply display an error and not fail the build

#

this was changed somewhere 2019.1.13 I think

#

Sadly they seem to have no interest in changing this

mint iron
#

its a bit of a nightmare right now, perhaps they're trying to upsell us on using cloud build

stiff skiff
#

We've had to turn off burst for all platforms in the projects we provide

#

Which is a shame, since burst really does help

mint iron
#

why is that, build issues or crashes and other things?

amber flicker
#

fyi pretty sure there are major issues with cloud build atm too? apparently no windows machines in the cloud even? they did say they hope to start on cross compilation support at some point...

mint iron
#

yeah i heard mac builds were failing with burst on the forums.

amber flicker
mint iron
#

last couple days i've been putting together a VM with High Sierra for IOS builds, and its been a lot of drama.

#

i do have a macbookpro from 2012 but ive run windows on it since day one haha

amber flicker
#

it is v frustrating - just as it felt like their build tools were maturing too, cloud build, performance benchmarks, it felt like it was all starting to come together... this sets things back a year or more in that regard I guess

#

#pricewepayforperformance

mint iron
#

it's hard when all the hype is on ECS and burst and all these fancy new packages but very few of them are even close to reliable right now, probably for a while yet. Maybe im just starting to get jaded.

quaint blade
#

we needed a linux build cause our server is running on linux rip

#

we were working on networking ecs stuff

#

to try some things

#

but i guess we either have to change our hosting to windows or not use ecs lol

mint iron
#

btw, since a bunch of us a going to the unity office to give feedback on alpha/beta stuff, packages/submitting bugs, releases etc if you guys here have anything you want to mention or emphasize while we have the opportunity let us know.

trail burrow
#

@mint iron also getting fed up with the constant "oh this new shiny thing... btw yeah not ready to be actually used yet" ?

low tangle
#

its really really hard to switch to ecs rendering in hybrid projects @mint iron

#

I can't on my side bulk convert things at runtime because my users all dont use the very cumbersome subscene system to make their modded worlds and content

pliant pike
#

@mint iron It would be cool to get more info/clarity on exactly how Systems work, like why they start and stop running

safe lintel
#

@mint iron what about asking for bugs that have been reproduced to be auto added to the issues tracker

wanton girder
#

When instantiate creates a new gameobject from a prefab, it seems it makes copies of all of the objects created through the serialized fields of that game object, and updates the references to point to the newly created objects. Moreover, the components of the prefab are accessible but attempting to read a property of a component of the prefab gives a null reference exception (rather than an inaccessible exception). Right?

wanton girder
#

Therefore it is not necessary to copy any data from the prefab; it is all available in the instance and furthermore it is impossible to do so. It also means that you can never accidentally change a prefab asset through code executed at runtime, except for code that directly changes files, etc.

stiff skiff
#

@mint iron Sorry for the late response. Its not due to crashes or other issues. Its simply that all cross platform builds will fail.

#

If we leave burst on for all platforms, then everyone using our example will have to fiddle with the burst settings before compiling for windows and mac. Instead of things just working straight up.

dull copper
upper tiger
#

Hey guys, I want to create an entity in a job using a command buffer but also add that entity to a dynamic buffer. Is this able to happen in the same job or do I have to wait for the entity to be created during playback before it is added to a dynamic buffer?

tawdry tree
#

Haven't used ECBs much, but pretty sure you can't get a reference until it exists.... which does not happen in the job. You can probably do job1->ECB runs->job2, though. I think you can make the ECB run the commands between jobs?
At any rate, splitting it up like that sounds more correct for separation of concerns, assuming you do more than just add it to the buffer afterwards. If that's all you do, you probably don't even need job2, and could just do it main thread?

pliant pike
#

yeah I have a job that specifically does that, you have to have 2 jobs and call complete on the first job to make sure it doesn't conflict with the second job

safe lintel
#

I do the two job thing as well(create an entity with the temp entity and buffer refs on it) but I don't call complete, it just has nothing to work on

#

Though I use endframe as my barrier of choice. I created a thread about this(though travelling can't pull it up atm), I thought getting a temp ref to the buffer to be able to do it all in one single job/ecb would be a nicer workflow

stuck saffron
#

Is there a particular reason why CopyTransformFromGameObject doesn't update Translation on the corresponding entity?

hollow sorrel
#

@stuck saffron does it have a LocalToWorld component

stuck saffron
#

Yeah

#

LocalToWorld is updated

hollow sorrel
#

did you add the transform to the entity as well

#

oh

#

yea seems it only updates LTW

stuck saffron
#

Exactly

#

Seems weird

#

Like behavior wise

#

Translation and Rotation aren't updated with LocalToWorld when the CopyTransformFromGameObject is present. Its not actually an issue for me. But like I said, I don't get why it wouldn't

hollow sorrel
#

yeah seems weird

pliant pike
#

hass anyone else come across this error "cannot implicitly convert type Unity.Mathematics.bool3 to bool"

#

and knows how to deal with it

dull copper
#

convert it manually?

pliant pike
#

yeah I just converted float3 to a Vector3 and that seems to work

#

hopefully they are going to fix it and make it work with float3

coarse turtle
#

Hmm if you use unity's gl immediate mode to draw primitive lines, you also end up drawing it on the entity debugger's histogram

hollow sorrel
#

lmao

mint iron
#

Haha that’s awesome

#

@pliant pike you can also do β€œmath.all()”

pliant pike
#

that works thanks @mint iron

stuck saffron
#

How do yall handle casting/unboxing of a component from a List<IComponentData> without knowing the specific value type? I have done it two ways:

  1. enum that holds the component type. Based on the enum do an explicit cast to the correct type
  2. use the dynamic keyword and convert the type to whatever the .GetType() is

Just wondering of better ways to do it

dire frigate
#

Is there a multithreaded solution or equavalent to the CharacterController?

#

Wanna use JobComponentSystem but the CharacterController sort of limits me to use ComponentSystem...

pliant pike
#

I think you will probably have to make your own

safe lintel
#

@dire frigate there is a basic one in the physics examples that i used for my own base

muted flare
#

Do you guys have some samples with Dynamic buffer ?

vagrant surge
#

automatic wrapper component for ECS

#

about fucking time

coarse turtle
#

fluent API for job scheduling too πŸ‘

amber flicker
#

animation engine..?

vagrant surge
#

non-retarded ECS editor, at last

#

that conversion workflow auto-boilerplate and preview is so much better

coarse turtle
#

so that's what live link is all about πŸ€” been wondering about that for a while

vagrant surge
#

if you can live-edit entities by changing the GO and have it auto recreate, then thats really great

vivid relic
#

It looked like you could. He translated and duplicated a couple of GO's

low tangle
#

yeah

#

awesome stuff

#

just wish the packages were public already

dreamy willow
#

Hi guys

#

We started implementing Jobs into our code and noticed that it actually cut our speed in half

#

How is this possible?

#

If you happen to know the answer please tag me.

amber flicker
#

could be a few things but the most obvious things is safety checks - this profiling comparison was done in a build?

#

second question would be when you profile, do you see full core usage for the code that's jobified?

dreamy willow
#

@amber flicker What do you mean by full core usage

safe lintel
#

there are safety checks for the job system, and burst that will probably slow your project down unless you disable them. additionally full performance should only be judged in a build

#

i really want that animation package πŸ˜‹ one step closer to ditching gameobjects forever

low tangle
#

ikr

#

I want the animation package so bad

#

finally can finish my ecs ik system

#

just need to render that data 😩

coarse turtle
#

im looking forward to the changes to the transport layer

safe lintel
#

some new DOTS packages just showed up on the package manager for me, DOTS Platforms [Windows/Android/ios etc] ? and a Device simulator

amber flicker
#

@dreamy willow the point of jobs is to use multiple cores to work on something in parallel - so using the profiler to check the parts you expect to be parallel are indeed so (you should have a β€˜Jobs’ part of the profiler showing other core occupancy). There could be issues within your job(s) causing them to mostly run on the main thread for example.

dreamy willow
#

Ok, I will look into that

#

Thank you

honest dirge
#

So the conversion system hasn't really changed but they fixed the workflow up a bit? That's a nice fix.

kind trench
#

So I'm a relative noob with ECS. I'm having trouble figuring out how to get a reference to an entity with a particular ID component. Any advice?

#

Like, I have Entity A, but he needs to do some calculations based on data that Entity B has. How do I give Entity B's data to Entity A?

safe lintel
#

store an entity on a component and then use ComponentDataFromEntity to lookup that entity

kind trench
#

So, give Entity A a component that stores Entity B, then use the above method to get Entity B's data?

#

I'm struggling to figure out how to find Entity B in the first place.

low tangle
#

do a search that looks it up then

safe lintel
#

you mean like finding an entity by using something else like a raycast?

kind trench
#

Basically, Entity A has a Parent ID component that matches an ID on some other Entity B. I basically want to take Entity A's Parent ID and find the correct Entity B with it.

safe lintel
#

so entity b is the parent of entity a?

kind trench
#

I wouldn't say it's the parent; just that Entity A needs to do some calculations that depend on Entity B's data. And Entity B can change. I basically just need a way for Entity A to say "I have this ID, now I need to find the correct Entity B with it."

low tangle
#

get a native array of all the entities you need a ref on from a query.tonativearray(jobhandle)

#

go though your childs and ecb add refs to the parents by looping though the parent array looking for the correct id

#

hashmap instead of array if you need faster lookup

coarse turtle
#

yea ^, I was thinking that too

#

if you have the ID of the Entity B, you can build a hashmap of Entity's data -> ID and do a look up

safe lintel
#

am i missing something that componentdatafromentity wouldnt be appropriate? ie
`
translationData = GetComponentDataFromEntity<Translation>();

if(translationData.Exists(entityB))
myTranslation = translationData[entityB].Value;
`

coarse turtle
#

No I think yours is a valid idea too

#

I was just using the hashmap idea because that's what I ended up doing in my game

low tangle
#

nothing wrong with that at all

#

but because its two entities and he doesn't know the other one, we cant just look at the other one like that

#

have to first get a refrence to entb

kind trench
#

Figured it out! Thanks, guys. The hashmap idea worked great @coarse turtle.

kind trench
#

Is it normal for a JobComponentSystem to have this much overhead? (It contains no logic whatsoever.)

low tangle
#

you are looping over all entities

#

also dont cache the entity manger

#

its already there

kind trench
#

Ah, that makes sense! And thanks for the tip.

low tangle
#

πŸ‘πŸ»

safe lintel
low tangle
#

is it happening?

#

FINALLY?

safe lintel
#

poking through it, doesnt seem that meaty of a package

#

i dont know if all this stuff needs a later version of unity but so far i cant see any new menu options after installing it

low tangle
#

yeah its only one file

#

gonna stop waiting and check back tomorrow

frosty siren
#

How much meshes are unique? All? 90%?

upper tiger
#

Is there a variable type I can give to a IJobForEach that is thread safe for read write?
For instance I have a job that simply grabs an integer and increments it by 1, but this integer is shared amongst all the parallel instances of the job that are running.

#

So if the job had 5 parallel instances running, the variable at the end would be incremented to 5

amber flicker
#

you can use an interlocked int or something I believe but from what I understand, this is potentially brutal for performance (esp as the project size/complexity grows) - could you e.g. increment by 1 and pass that value into the job instead?

mint iron
#

you could maybe have an array/list that is sized to max job thread count and have each thread write to their index (which you'd get from IJobForEachWithEntity), then i guess you could add them up afterwards or in another job, might be slower than just using an interlocked solution im not sure.

upper tiger
#

@amber flicker The idea was to get all the "Projectile" entities in the system, check if they had hit their target and if so take health off that target. This breaks when multiple Projectiles try to hit the same target at once and I run into the race condition. Guess I'm just going to have to single thread that operation until I can think of a better way to handle the data.

#

or I could IJobForEach the targets, check all the projectiles, tally the ones that hit it and do it that way

amber flicker
#

yea either that or an intermediate multihashmap or something

mystic mountain
#

possible to have a string, or fixed sized char array in IComponentData?

low tangle
#

Disable safety, run a single job not a parallel one

#

@upper tiger

#

@mystic mountain NativeString64 512

#

@upper tiger actually a even better way would be to chunk iterate and slice up the int ranges. Unless the value depends on the int in the component

mystic mountain
#

@low tangle Thanks! I assume it's not possible to get the char array to directly ref copy into?

low tangle
#

I believe you can. I've never needed it though

#

There's constructors for string and other native string

mystic mountain
#

Using the DOTS multiplayer DataStreamReader

#

so would be nice to be able to read it directly into the Component : )

mystic mountain
#

Havent been able to get the buffer from NativeString yet, public char this[int index] { get; set; } trying to get by doing (byte*)&m_string[0], but doesn't seem to like that.

low tangle
#

Oh I was going to look into that today actually

#

They do code gen for their messages, might have to look at how they did that

safe lintel
#

dots project to be released later this year from the blog 😩 hope that doesnt hold back the packages

hollow jolt
#

when working with ECS what are some of the pre made classes to be aware of ( like Unity.Transforms )

coarse turtle
#

ComponentSystem, JobComponentSystem, EntityManager, World? a lot your of data are simply going to be structs more than classes πŸ€”

hollow jolt
#

no i mean the pre made data classes

safe lintel
#

components you will likely use a lot - LocalToWorld,Translation,Rotation,Scale
possibly - Parent,LocalToParent, Disabled
sharedcomponent -RenderMesh
buffer - LinkedEntityGroup

hollow jolt
#

^

coarse turtle
#

Ah that's what you meant

hollow jolt
#

true forgot to check the docs, watching tutorial vids now

#

is there a way to inspect archetypes ?

coarse turtle
#

Usually through the EntityDebugger

safe lintel
#

pinned message here has good info too

hollow jolt
#

like if i create an entity only from 1 type without the archetype its possible to click and inspect the value

coarse turtle
#

if you create an entity with 1 type -> the entity has an archetype of 1 type

#

so an entity with MyCustomData - would have an archetype containing MyCustomData, but you can still view it through the EntityDebugger

hollow jolt
#

oops that was some bug with my editor (...?) i re compiled and now i can inspect normally via the entity debugger, thanks

coarse turtle
#

np

hollow jolt
#

not sure if that's a bug or not but selecting on the right panel will update the all entities middle tab but not the inspector

coarse turtle
#

Might be, I have the same behaviour too

hollow jolt
#

i get it now, they done it when working with large quantities of entities ( in the vid there are only 2 ) so there are groups on the right side that will filter X amount of entities on the middle panel. ( as a UI designer it was a bit counter intuitive for me at first sight ).

low tangle
hollow jolt
#

@low tangle that would be extra work for a very narrow use case, thanks for the link tho

#

but yea the whole thing as of right now is very limited and nearly none interactive compared to the regular mono behaviours, i suppose that its is not an issue since it will be used by technical savvy developers

#

is anyone else using ECS with VSCode ?

#

i got 70K+ problems in a empty projects including the experimental packages this really slows down my editor ( OmniSharp was bugging out )

hollow jolt
#

is there a way to create a ComponentSystem variable that will be editable in the inspector similar to mono behaviour ?

safe lintel
#

only if you make a monobehaviour for your system

hollow jolt
#

i guess i can do something like this:

public class SystemMono : MonoBehaviour
{
    public static int value = 30;

    [SerializeField, Range(0,100)]
    public int _value = 30;

    void Update()
    {
        value = this._value;
    }
}

public class MySystem : ComponentSystem 
{
    protected override void OnUpdate()
    {
        int val = SystemMono.value;
        // ...
    }
}
#

might as well create an empty mono behaviour with custom editor

#
#if UNITY_EDITOR
using UnityEditor;
#endif

public class MySystemInspector : MonoBehaviour {  }
#if UNITY_EDITOR
[CustomEditor( typeof(MySystemInspector) )]
public class MySystemEditor : Editor
{
    public override void OnInspectorGUI()
    {
        MySystem.myValue = EditorGUILayout
            .Slider( "My Value:", MySystem.myValue, 0, 100f );
    }
}
#endif

public class MySystem : ComponentSystem 
{
    static public float myValue = 3f;

    protected override void OnUpdate()
    {
        float v = myValue;
        
        // ...
    }
}
dire frigate
#

Is there no workflow currently to show entities in a scene? Trying to play around with Jobs and Unity Physics but everytime I press play, it freezes for 4-5 seconds and everything just disappears

#

Both in 2019.3 and 2019.2.6

hollow jolt
#

@dire frigate show ? like inspect their data ?

dire frigate
#

Just wanna see them in my scene to begin with πŸ˜„ They just disappear

#

On play, that is

hollow jolt
#

check if they exist in Entity debugger ?

dire frigate
#

They do, just not "visible" in the scene

#

Like a standard capsule

#

smack ConvertToEntity on it

#

and poof

hollow jolt
#

use GL draw at their position ?

#

i mean if they exists and there is a translation data on each one , the GL will draw it for sure

#

so it won't help you much

#

maybe you have no renderer ?

#

ConvertToEntity

oh...

#

i'm not there yet, sorry can't help

dire frigate
#

no worries, although cheers πŸ˜…

hollow jolt
#

i just peeked the source code for this class there are 2 different modes

#

maybe try ConvertAndInjectGameObject ? ( ConversionMode )

dire frigate
#

Just not showing in the scene

#

Atleast the JobComponentSystem works

#

Just moving with WASD

#
struct Move : IJobForEach<Translation>
    {
        public float moveX, moveZ;
        public float deltaT;
        public void Execute(ref Translation c0)
        {
            Debug.Log(c0.Value);
            float3 movement = new float3(moveX * deltaT, 0, moveZ * deltaT);
            c0.Value += movement * deltaT;
        }
    }
low tangle
#

do you have the hybrid renderer package added?

dire frigate
#

That worked, cheers June πŸ˜„

stuck saffron
#

That is such a common occurrence, they should make it super obvious that you need the package to render

dire frigate
hollow jolt
#

eyyy !

#

ecs physics character controller ?

dire frigate
#

Yeah working on it to replace my networked Character Controller

#

Using DarkRift2

hollow jolt
#

nice, is that for a personal project ?

dire frigate
#

Just a hobby project

hollow jolt
#

send updates when u can πŸ˜„

#

( screen recorder is lagggy... )

dire frigate
#

looks mesmorizing πŸ˜…

grave turtle
#

anybody interested testing a quick test implementation of a debug gizmo drawer system ?

hollow jolt
#

are you drawing via GL for each entity translation ?

#

@grave turtle what is that ?

grave turtle
#

I use Gizmos.draw etc. I have a JobComponentSystem that has NativeArrays with GizmoInformation and a simple API like "JobGizmo.DrawWireSphere(c0.Value, 1f, Color.blue);" the drawing is done via a static DrawGizmos callback

hollow jolt
#

so gizmos are used for not in play mode, right ? how do you work with entities while still in editor ?

grave turtle
#

Oh no currently it's just a quick test for how I could draw some gizmos from jobs so only at runtime right now.

hollow jolt
#

interesting, i would like to see, do you have a demo scene as well ?

grave turtle
#

yes the screenshot

hollow jolt
#

that above my level, im just starting with ecs to get into dots physics for a project

#

share this on reddit as well πŸ™‚

coarse turtle
#

looks cool

#

I think I'll give it a shot @grave turtle

grave turtle
#

Let me know if/how it works for you.

frosty siren
#

@gusty comet so 10% will be batched. I understand that it will cause 90 separations per chunks (with 100 rendered objects) but u can try to go with default DOTS solution and worry only if it will ruin performance.

#

U can define your own IComponentData MeshRendererPerEntity with exactly the same fields and rewrite mesh draw system

sacred sigil
fringe sinew
#

Wait, what do you mean "We are running the Burst compiled code on the main thread"?

#

So if I schedule a job and it gets executed on another thread it will use a non-burst code?

#

I am pretty sure that is completely false.

#

I remember quite clearly having my jobs executed on separate threads and benefit from burst (turning off compilation substantially increased execution time).

#

So, can anyone clarify what that line means exactly?

mystic mountain
slow epoch
#

You are scheduling two jobs using the same native array

#

To avoid they are not modifying the same stuff at the same time you must declare one of the jobs as a dependence for the other

mystic mountain
#

Aren't InputDeps doing that?

slow epoch
#

Not so sure what's that but i usually do itcalling Schedule(JobHandle dependence)

mystic mountain
#

JobHandle *

#

Doesn't it do this automagically when I schedule job using JobHandle from OnUpdate call?

slow epoch
#

Nope you must pass the dependence if they are using the same stuff

#

But if you are not modifying the native array, you can use ReadOnly and that can work too

mystic mountain
#

It's dots networking systems, so the first job is calling the internal Update and writing to the nativeArray I imagine.

slow epoch
#

I haven't use networking yet so maybe there is another solution in this case

#

I know also that using WriteOnly, ReadOnly and updating systems before others can work too, but i haven't see a lot of info about it

mystic mountain
#

Yeah, I'm a bit confused. The sample code doesn't need to add the dependency separately from what I can see.

mystic mountain
#

Moved the code to a new project, same error. Now trying to cut it down until it stops complaining xD

mystic mountain
#

Finally found it, and it even says in sample lol...

        // Group used only to get dependency tracking for the driver
        GetEntityQuery(ComponentType.ReadWrite<PingServerConnectionComponentData>());
mint iron
#

@fringe sinew I've heard if you use .Run() instead of schedule then it runs on the main thread.

fringe sinew
#

Is that a workaround to using burst for very small functions on the main thread?

mint iron
#

I don't think it's a work around, just for if you want to run synchronously on the main thread. Burst pretty much gives you at least twice as fast performance so it can make sense as soon as the amount of work being done exceeds the scheduling overheads.

fringe sinew
#

Alright, thanks for clarification. That was some strange wording on the slide though

mystic mountain
#

Do you always need to add m_barrier.AddJobHandleForProducer(inputDep);when using commandBuffer, or only when using the concurrent one?

low tangle
#

Always, that's handing the jobhandle to that system so that it can do the equivalent of . complete when that system runs later in the frame

coarse turtle
#

adding a job handle to a barrier allows jobs to complete first before the ecb runs

final gyro
#

ECS lords I have a question. If I am going to instantiate and destroy objects a lot, something like an endless runner, do I have to still make a pool system or that is what ECS is for and just create and destroy entities?

turbid sundial
#

destroy/create is really fast

vagrant surge
#

@final gyro the ECS IS a pool

#

on itself

#

basically everything is pooled by default

final gyro
#

Aha I knew this!

#

Wait a minute I know you @vagrant surge πŸ€”

#

Ok so I know how to create an entity but how will you destroy one πŸ€”?

coarse turtle
#

using CommandBuffers to destroy the entity

#

EntityCommandBufferSystem if you need the system

#

PostUpdateCommands.Destroy(Entity) -> ComponentSystem
EntityCommandBufferSystem.Destroy(Entity) -> JobComponentSystem

amber flicker
dull copper
#

That has to be from this years hackweek originally

#

At least I have a faint memory of people doing few dots games there (based on the git repos they briefly had set public there)

coarse turtle
#

yea same, one was with project tiny and web controllers

final gyro
#

Do I recommend I use the job system for my use case @coarse turtle ?

coarse turtle
#

You can, I don't see a problem with it πŸ€” unless you're doing like a hybrid approach where you need gameObjects

#

that gets a bit cumbersome imo

final gyro
#

No I am doing Pure ECS

coarse turtle
#

yea should work, I dont see why it would be an issue

#

I'd just look into the EntityCommandBufferSystem

#

Lol, I'm actually in a pickle atm with spawning an entity, but it's actually just a gameObject, I might have to queue the request and do an instantiate in OnUpdate() πŸ€”

pliant pike
#

I'm not using a postupdate command to destroy entity's I'm just using EntityManger.DestroyEntity() in a component system is that not a good idea πŸ€”

coarse turtle
#

AFAIK in the latest package, EntityManager.DestroyEntity() should be deferring it and allows structural changes

#

on a ForEach

pliant pike
#

cool thanks

#

along those lines how do I use systemstatecomponents, like is this a good accurate way of counting destroyed entities

#
Entities.WithNone<ToCurrentWaypoint>().WithAnyReadOnly<RobotCustomerSystemState>().ForEach((Entity emo) =>
        {
            CountDestroyedCustomRobots += 1;
            Debug.Log("Number of Entity's destroyed'" + CountDestroyedCustomRobots);
            EntityManager.RemoveComponent(emo, typeof(RobotCustomerSystemState));
            
        });```
coarse turtle
#

Yea that's a way of doing it

pliant pike
#

yeah it seems to be accurate i can never be sure with these things

#

if I'm understanding system states correctly they work just like normal components but they just persist after destroying

coarse turtle
#

yea, and they are only destroyed when the ISystemState is removed

ivory tinsel
#

so I was pretty excited when I heard that Unity has added ECS. How awesome has it been?

safe lintel
#

its a bumpy hell of a ride

ivory tinsel
#

hard to tell if that's a good thing or a bad thing yet, heh.

safe lintel
#

its good but its not without its frustrations

#

like right now i have some bug where if i use a subscene, it hampers the entity destruction or the hybrid renderer or something. so now i make a blank new scene, entities of what i was just playing with still appear in my scene view 😩

dull copper
#

In general, things it does are pretty amazing but the lack of tooling and integrations on Unity side + constant api changes have made it easily IMO hardest preview tech to keep up with. If you really want it, you have front row seat to the Unitys future here, but it'll require a lot of work to keep up with the iterations + misses so much even today

#

For example they are slowly expanding on the engines dots feats but there are still many things that doesnt have any official solution

safe lintel
#

yeah when its working it works amazingly. but the downside is in old unity you could google your way out of almost every problem, now every issue is unchartered waters πŸ™‚

final gyro
#

What is the recommended way of destroying entities? PostUpdateCommands.Destroy or EntityManager.Destroy

mint iron
#

I'd say destroy by EntityQuery overload

amber flicker
#

PostUpdateCommands.Destroy is just a delayed version of EntityManager.Destroy - as destroying an entity will cause a layout change, postupdate allows you to iterate an array of entities and mark them to be destroyed without the array becoming invalid. If you're fortunate enough to want to destroy all entities of a particular archetype, definitely use one of the bulk operators like @mint iron mentions

pliant pike
#

I got feedback for a bug I reported a few days ago from the devs

#

to quote It seems that the function EntityManager.Exists(GetSingletonEntity<T>) doesn't return a NULL value, it's not designed to do so. What happens is that your If statement never returns a True value on OnCreate() in the CountRobotsatWaypoint System, so the System is never created to show up in the list. There's a workaround to use HasSingleton<T>() function instead, or you could implement an EntityQuery and see if the Singleton is empty. And that should pretty much solve your problem.

#

so that's why it wasnt working and doesn't create the system

final gyro
#

@amber flicker Thing is, I will be instantiating and destroying a lot, something like an endless runner. So I am really confused on what to use. Should I use Jobs or is ECS just enough?

slow epoch
#

You can always pool the entities

#

Or loop them from behind to the front

final gyro
#

But I was told ECS already implements the pool system πŸ€”?

pliant pike
#

yeah, I'm instatiating and destroying a lot with my prototype just using single threaded ecs

final gyro
#

Any chance you could show your script Calabi?

amber flicker
#

so.. there are several things that maybe I can try and help clarify. Some things need to take place on the main thread. Currently these include instantiation, destroying, adding & removing components. Therefore, by using a job, any perf improvement you get is from iterating through the entities and doing the check for if you want to destroy them or not (relatively, a very small part of the cost compared to destroying the entities). You could make it a job but imo just start with a regular component system if you like.

#

Even using a job, the actual destroying is just deferred until the job has finished and then it executes on the main thread.

pliant pike
#

well it's not that complicated, I'm creating one entity every millisecond currently but I can push it to 100 and above every milisecond pretty easily no problem

#

unless you are pushing beyond 100,000 or so it shouldn't be problem

pliant pike
#

I found something interesting I was just testing creating 100 entities every millisecond total 6000 entities alive at any one time

#

and I was getting major slowdowns, it turns out counting the number of entity's at a waypoint does it

#

without the counting I get 140fps average with it drops to almost 30

#

I'm guessing its because I'm adding them to a list

wary anchor
#

Hi all, I've been struggling with shaders for a while now, and I'm trying to think of ways around the problem.

I have exposed in a system the following NativeMultiHashMap which I'm using as an acceleration structure for finding sphere details (the float4 value) from grid positions in space (the unit stores a hash of the 3D grid position).
public NativeMultiHashMap<uint, float4> AtomDataGridMap;

I need to access this same data within a raymarching shader. So far I've tried making a 3D render texture to calculate the same data and plug that in - it half works but I end up with lots of weirdness that I can't seem to diagnose.

If I raymarch all my spheres at the same time, it slows to an absolute grind for obvious reasons, hence needing the acceleration structure.

Am I just barking up the wrong tree here?

final gyro
#

I KNOW YOU @wary anchor !

#

So yeah I guess it won’t matter if I use Jobs then really @amber flicker Much love man

low tangle
#

Hm, I'm not sure if the hashmap can really just 1:1 go over. You would likely have to do it in a compute shader, or build a linear friendly / GPU friendly one then bind it to the shader as a uniform

wary anchor
#

Yeah I think that's where I am going wrong. My compute shader seems like it should be doing the right thing, but I can't verify easily. Need to check out renderdoc I think see what's actually in there. Thanks @low tangle will have a think about how I can construct a linear-friendly version.

low tangle
#

gpu gems has a lot of gpu related things and can help you learn how to do gpu linear structure type stuff

#

like to flatten a nodegraph into a array of nodes with index offsets to traverse

dire frigate
#

Is there a way to rotate something? I tried to add mouse axis to the player rotation but it seems like it always returns to the default rotation of (0,0,0,0)

class PlayerJobSystem : JobComponentSystem
{
    [BurstCompile]
    struct Move : IJobForEach<Translation, PhysicsVelocity, Rotation>
    {
        public float moveX, moveZ;
        public float mouseX;
        public float deltaT;
        public void Execute(ref Translation c0, ref PhysicsVelocity c1, ref Rotation c2)
        {
            c1.Linear.x = moveX * deltaT;
            c1.Linear.y = -9.8f * deltaT;
            c1.Linear.z = moveZ * deltaT;
            c2.Value = quaternion.RotateY(mouseX);
        }
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new Move() {
            moveX = Input.GetAxis("Horizontal"),
            moveZ = Input.GetAxis("Vertical"),
            mouseX = Input.GetAxis("Mouse X"),
            deltaT = Time.fixedDeltaTime
        };
        return job.Schedule(this, inputDeps);
    }
}

https://gyazo.com/150b2c72ffb7471e440acbe1adee34d5

low tangle
#

rotation is absolute, you are only feeding it per frame delta of the mouse movement

#

accumulate it instead

dire frigate
#

Just to be extra difficult, what is meant by accumulate?

#

Oh crap nvm I got you
c2.Value = math.mul(math.normalize(c2.Value), quaternion.EulerXYZ(0, mouseX, 0));

#

Works now, cheers. I noticed you can't multiply the rotation with the movement vector (float3), would there be a way to take into account the rotation of the capsule before moving, so it would move in the direction that it's looking?

low tangle
#

mul(quat, float3)

dire frigate
#

Well that's just me being dumb as usual, cheers once more

low tangle
#

πŸ‘πŸ»

coarse turtle
coarse turtle
#

Hmm looks like UIElements runtime will come in 2019.3 at least the early preview of it πŸ€”

#

Wondering if it'll have basic support for entities by then

frosty holly
#

Any advice/further reading for entities / data that need to reference children and parent data

Example of code how it roughly exists now

public class A:
{
    public List<B> B;
    
    // Data related to class 'A' here
    // strings, ints, floats, etc
}

public class B:
{
    public A Parent;
    public List<C> C;

    // Data related to class 'B' here
}

public class C:
{
    public C Parent;

    // Data related to class 'C' here
}
dull copper
#

@coarse turtle I think the runtime package has been there for like month or two already there?

#

at least I remember stopping that somewhere before it was announced

#

ok, since early august

#

they just updated it like a week ago

#

the runtime support is one thing, but the biggest thing for most users is the ui builder

#

the early versions I tried from that were super clunky but the short gif on the keynote looked like they've evolved a lot from that now

#

I've seen the new packages on that but haven't had time to test it recently

mint iron
#

@frosty holly generally you’ll want to figure out how you can break it apart as much as possible by the role of the data inside and how you’re using it. Avoid trying to just reproduce the class representation in components. Think about how you’ll need to access it and transform it for each task inputs/outputs and check that against your current plan for how the data is organized. Check YouTube for some of the unity dots videos and the pins in this thread.

frosty holly
#

Yeah I think I need to use something like native hashmaps when looking at there boids example

#

Definitely some things are a bit tricky

mint iron
#

Yeah they get away with that because it’s spatial data so essentially deconstructing a dictionary and using collisions to group is a nice trick.

radiant sentinel
#

Hi how can i detect collision or trigger enter on dots package?

#

Physics package

dull copper
#

@radiant sentinel you can probably find example for this on the ECS sample repo (there are separate physics samples there)

#

repo link is on the pinned message on this channel

#

that was fast πŸ™‚

upper tiger
#

Anyone know if you can use particle effects with entities yet?

#

or convert them to entities rather

coarse turtle
#

Ah @dull copper cool, didn't know it was in very early preview before

#

@upper tiger I dont think shuriken particle effects are fully converted to their entity format

frosty siren
#

The conversion system is just awesome. But i have a couple of question. Maybe it can be short answered)
In my project i have no prepared object, all spawns dynamically, all is procedural (map, buildings, npc, etc). So i need some dictionary with ECS objects that i need spawn at runtime. The first problem that i assume that i want to convert once and then just spawn. I don't want to do conversion every time that i need to spawn the ECS building. In this presentation https://www.youtube.com/watch?v=TdlhTrq1oYk i saw that conversion supports referenced prefabs, so i thought about converting all i potentially need at runtime once at start and then instantiate referenced entities. But i can't understand how this works. When my GO have an array of prefabs (from project) system will discover and convert all referenced prefabs in ECS format, and at the end i will have dynamic buffer with entities that represents referenced GOs (right?). But where those entities are? Does it means that to have a possibility to instantiate referenced entity i need to have 1 exemplar of it in the default world?

safe lintel
#

an entity with a prefab component is kinda similar to an entity with disabled, it doesnt get processed by systems by default so it lives in the scene but is just invisible and inactive

frosty siren
#

But when i will instantiate from it, it will be automatically converted to regular entity?

amber flicker
#

afaik an ecs prefab is simply an entity with the correct components with the addition of a 'Prefab' component - so when it's instantiated, that specific 'Prefab' IComponentData is removed and it's just like a new entity based on the corresponding archetype. Whether that's exactly how it works under-the-hood I'm unsure.

frosty siren
#

if so then it is excellent. thanks for the clarify

trail burrow
#

@dull copper nice meeting you in copenhagen btw πŸ™‚

dull copper
#

you as well, sorry for ruining the anonymity thing, just couldn't help it πŸ˜„

trail burrow
#

haha no problem

#

most people that know me online, know that i work for exit games/photon, so wouldn't be hard to find me lol

#

@dull copper what's your take on the dots/netcode presentation you linked btw? I watched it this morning

dull copper
#

yeah, it wasn't hard at all, saw you the day before but you were always busy πŸ™‚

#

I haven't watched it yet, still quite exhausted after the trip πŸ™‚

trail burrow
#

feature set seems to be the same as what's on github, but with a slightly more cleaned up workflow

dull copper
#

I mean, I did quickly browse the beginning and it seemed very intro like but can't comment on the rest

trail burrow
#

give or take

dull copper
#

for workflow it also seemed simpler but I never really dove into the earlier version as I've been waiting for this to mature first

trail burrow
#

it's pretty far from mature from the looks of it (netcode part that is, dots itself is coming a long nicely tho)

dull copper
#

I missed most of the DOTS talks while at the event, always had something I needed to attend elsewhere when those were happening but will try to catch up next week as the videos keep popping up

trail burrow
#

i mean DOTS is starting to look really nice, at least when the stuff they showed at unite is out

dull copper
#

it's nice that they finally start uploading these asap and not having to wait that typical 3 weeks for the most anticipated ones

trail burrow
#

yeah

dull copper
#

and yeah, I'm all for reducing boilerplate

#

editor workflows also need those improvements badly

trail burrow
#

their networking still relying on codegen

#

feels pretty bad tbh

#

easy to get into states on complex projects, where it becomes impossible to compile without having to go in and manually edit/remove generated code, etc.

#

it gives it a bit of an 'asset store' feel imho

gritty isle
#

Hi Can someone please explain how WorldToLocal component works..I understand LocalToWorld component. but Googling about WorldToLocal Didn't give any good results,..so mainly I have an entiry where there is both World to Local And local To World component along with all the basic transform components In Local To world component the position (c3) shows
.6,0,0
but the world to local component's position(c3) shows
-1.2,0,0
can someone please explain how these calculation between world to local and local to world and translation componet works

coarse turtle
#

Given a LocalToWorld component, you inverse its matrix to get the WorldToLocal values

#

so position/translation would be => column3.xyz / column3.w if you need a vec3 like coordinate data

radiant sentinel
#

@dull copper thank you but i have not enough time to check example projects, i will implement other part of game then my friend should think about physics

gritty isle
#

@coarse turtle is there any way to translate in world space if an entity is child of another entity?

coarse turtle
#

yeah, inverse the matrix from local /object space -> world space

gritty isle
#

Is there any code demo..? i thought LocalToWorld componet contains the world space coordinate by default..?Do I need to inverse LocalToWorld component value? @coarse turtle

coarse turtle
#

inversing LocalToWorld provides you local space coordinates, inversing WorldToLocal provides you world space coordinates

#

if you need a code example, I'd look at the transform systems in Unity.Transforms package

#

and yes LocalToWorld provides world space coordinates

#

Here you go, it's a simple example, but accessing the LocalToWorld should be what you need

#

If you shift the parent from (0, 0, 0) -> (1, 0, 0) your LocalToWorld on the child should be (2, 0, 0, 1) on c3 in the matrix

gritty isle
#

@coarse turtle thank you very much for the help..I get it Now..

#

Now can someone please explain if i have a child entity who's translation x value is 5 and if i want to move the child to world space 10,0,5 do i need to manually calculate the translation value for the child component or is there any way to directly move in world space like in case of normal transform i could directly set the value of transform.position to move in world space..

pliant pike
#

the way these componentsystems just stop running is really annoying

#

I made a pause system that just stop's running for no reason that I can understand after pressing the button twice

slow epoch
#

Is there any way to convert unity components that doesn't have an auto convert yet like Sprite Renderer?

coarse turtle
#

not out of the box, most ppl have implemented their own versions, which usually takes a texture and render it to a mesh

stoic mulch
#

What do I need to do to a camera to make a ECS-converted object visible in it?

low tangle
#

unity hybrid rendering

#

package

#

dont convert the camera gameobject to entity

stoic mulch
#

ohhhhhhhh duh

#

Thanks

#

I'm a bit confused as to how the future of ECS will work, like will MonoBehaviour eventually go away?

#

Or no longer even be the default?

#

Or is ECS meant to be an optional thing rather than replace our current system entirely

vagrant surge
#

@stoic mulch will replace everything

#

but monobehavior will stay for a very long time

#

at the moment, they are leaning on the conversion workflow. You use monobehaviors for "edit time" and editor properties

#

and then convert to pure entities

honest dirge
#

@slow epoch render mesh as a conversion works, but doesn't cover anything to do with sorting which mostly makes it useless right now. You have to run over every sprite and Sorting Group and sort them all yourself. By default it just draws in creating order as far as I can tell.

lament orbit
#

any word on when DOTS 1.0 is going to release?

tawdry tree
#

The closest thing to that is the roadmap graph which says about half of DOTS should be here some time mid-late 2020, and most of it should be out by end of 2022, if I recall the numbers correctly. Though what 'half of DOTS' or '90% of DOTS' mean is unclear.

twin raven
#

In DOTS menu there is LiveLink -> and some experimental options. Are they working? I don't remember it being published outside yet.

#

And also GameObjectConversionUtility.ConversionFlags.SceneViewLiveLink

final gyro
#

How would you make a coroutine like system using ECS? Something like having a list of objects, picking a random one, instantiate then do the same every 2 seconds or so

tawdry tree
#

Create an entity which somehow tells a system to do those things?

#

A component like this for marking something as a coroutine:

public class CoroutineComponent : IComponent {
  public float TimeCreated;
  public float Interval;
  public int TotalRepetitions;
  public int CurrentRepetitions;
}

and another one, specific to the system which does the thing, to tell it do do the thing. For example this, which, together with the other component, would be used to play a beeping sound every so often.

class PlayBeepComponent : IComponent {
public  float PitchModifier;
}
final gyro
#

Excuse my ignorance, how would this exactly work?

#

@tawdry tree

tawdry tree
#

Your goal is to run something every X time, right?

final gyro
#

Yes

#

Basically instantiate entites

#

Every X time

tawdry tree
#

The simplest way would be to just make some variables on the system, and depending on your requirements, that might be the way to go

final gyro
#

I thought of just using the Monobehaviour Update and check for time elapsed then spawn

#

Not sure if this is efficient or will work for Pure ECS

tawdry tree
#

But if you need it more dynamic, or support potentially a bunch of these coroutines (repeated events), then something like what I outlined above would work

final gyro
#

No repeated events. This is an endless runner kinda game

tawdry tree
#

I assume you want to potentially have multiple spawners with different times etc?

final gyro
#

A single spawner, same time

tawdry tree
#

If it's one-off events that happen rarely (less than once/sec), then it would probably not be a big deal to just use monobehaviours

final gyro
#

Every 2 seconds or so

tawdry tree
#

As long as it's only one thing, then you could just do something like this:

public class WaveSpawnSystem : ComponentSystem{
  private int _wave; //Not really used in this example, but probably useful to you
  private float _interval; //Make sure to set this, otherwise it will spawn every frame. Unless that's what you wanna do
  private float _previousSpawnTime; // time.Time from previous spawn
  
  void OnUpdate(){
    //If it's time for next wave
    if(time.Time < _previousSpawnTime+_interval){
      //exit early
      return;
    }
    _previousSpawnTime = time.Time;
    wave++;
    //Spawn stuff
  }
}
#

Obviously doesn't work too well if you start having multiple spawn points or something, BUT when you spawn a wave you could change the interval, for example if give the player a break after wave 5 or some such, and the components I wrote above is basically taking the settings out of the system and into components so you can have several things going on at the same time. The CoroutineComponent would be reusable (and is more like a timer, really)

final gyro
#

SpawnStuff is supposed to create entities

#

I don’t think you can do EntityManager.CreateEntities inside a System no πŸ€”?

tawdry tree
#

Yes you can

final gyro
#

Oh!

tawdry tree
#

That's usually where you would do it, isn't it?

#

Have you looked at the samples?
It can be useful to go over the code, if only to see what things you can do in the code

final gyro
#

All of the examples I have seen they usually create entities at the start

#

Of a Monobehaviour

#

Haven’t seen one created inside a system

tawdry tree
final gyro
#

Haha! Much much thanks Hod!

#

One final question if you may xD?

#

How would you have a list of prefabs? As of now it is not possible?

tawdry tree
#

I know it is possible, in more than one way

#

I am not 100% sure, but I think the current standard way is to make a gameobject prefab, and run it through the conversion workflow.
Once you get the entity out the other side, you'd give it the PrefabComponent, which should disable it. Then you could instantiate copies of that entity.
Relevant sample:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/ECSSamples/Assets/HelloCube/6. SpawnFromEntity

final gyro
#

Awesome! Thank you very much!

stoic mulch
#

So do we not even know what full ECS with everything will look like yet?

#

Or the editor once ready to move away from MonoBehaviour

final gyro
#

Moving away from Monobehaviour would probably take time

#

A lot of time

low tangle
#

reeeee

#

dont put hidden data into the component system

#

only stuff that helps it run more performant like acceleration structures

hollow sorrel
#

what is hidden data

neon shore
#

I was wondering where the ECS channel went :P Now I see it was renamed, funny I was actually thinking about mentioning that it may be best to rename it a few days ago.

#

By the way, building the foundations for a Tycoon game based on DOTS as a little side project, just to see how well all the micro processes will work with it, should lend itself well to that genre.

low tangle
#

hidden data is data inside of oop classes that effects the state of the game @hollow sorrel

#

you should leave that data inside the world and then allow for it to be easily found and modified

#

the clear separation between the systems and that data is a big plus

hollow sorrel
#

ahh i see

#

you were talking about the wavespawnsystem above right

#

in that case wave should be a singleton component?

low tangle
#

yep

#

exactly that

vagrant surge
#

in general you want to use singleton components to control system state

#

for a wave system, you could have a singleton component that holds the "spawnable" prefabs

#

and then entities managing the state of each spawner or similar

stoic mulch
#

I’m looking to do some sort of train simulation so I’m curious as well to see how ECS can work with that as I may abstract the physics away

#

Would ideally like to try to do the maths for each axle

radiant sentinel
#

ok physics backed to me and i can not find example repo. i have implemented dots physics ,my problem is collision or OnTrigger detection, i found raycasts but what is other ways? whos can help me?

stoic mulch
#

Related to those examples, just a warning they’re broken in the 2019.3 beta

final gyro
#

Is it possible to do a car controller with ECS πŸ€”?

#

@low tangle What do you mean a singleton component?

stoic mulch
#

There’s already a car physics example in that bundle

radiant sentinel
#

@final gyro implement physic world and your car physic, then set value of physic velocity component data

low tangle
#

basically, a single entity with a single component on it

#

which just holds more general config data for a system

#

once you get used to this it becomes much easier to debug stuff later on

#

my games been in closed beta testing for about half a year now, and everything that was pure / fully ecs'd has been super easy to debug vrs hybrid or monobehaviour stuff

#

unity's singleton api is kinda meh, so just write the few lines of code yourself

dull copper
#

@stoic mulch physics car example is mainly on mono side and not the greatest example how you would do it

#

But you can of course do all kinds of controllers in ecs

stoic mulch
#

I wonder how the new physics could work against realistically pushing or pulling something along a path or rail, like a train

#

Because with old physx that’s really difficult

low tangle
#

Maybe but I wonder how good havok will be

solar spire
low tangle
#

Yeah, just haven't had time to play with anything yet

#

Couldn't figure out what those dots platform packages where for

#

Maybe moving some of the native code support to packages?

dull copper
#

@solar spire good call, forgot we got these for Havok

#

I'll update the pinned later on today, now on mobile so afraid I'll just screw up the whole post :D

mystic mountain
#

~should you post dots phyiscs, networking in this channel now or keep in respective channels? O.o

solar spire
#

Whatever makes you comfortable

#

they're not the most active channels, so spread it as evenly as you want πŸ˜›

tawdry tree
#

I feel like if it's DOTS heavy (so more about DOTS-specific APIs, interactions with ECS) then here is probably most relevant, while if it's more about the networking/physics part and interactions and whatnot, it might suit those channels better?

stoic mulch
#

Will Havok be free in unity or will it be a separate commercial package like it is normally?

#

Oh nevermind I see now

dull copper
#

It is not going to be "full Havok" in a way you'd get every feat Havok has. More of a select set of basic functionality tied to the common unity physics api

final gyro
#

How would you have a list of prefabs without having to convert them to gameobjects πŸ€”?

#

I have sections of my level saved as prefabs

amber flicker
#

Anyone got a sec to point me in the right direction of how I might take something like this:

{
     t = new Translation() { Value = new float3(test.Value1) };
}```
and use unsafe to set by ref/pointer instead? Setting up some very basic benchmarks to challenge some of my underlying assumptions but unsafe is unexplored realms for me.
trail burrow
#

@amber flicker you can achieve the same thing, with unsafe syntax, when using chunk iteration

#

Also unsafe code isn't faster just because its using raw pointers or because its 'unsafe', what unsafe let's you do is structure data/programs in a way which would not be possible with c# classes or without unsafe, and that can gain you performance if you know what you are doing

twin raven
#

I added attribute [DisableAutoCreation] to my system and I am trying to manually run it from the code, so I can benchmark 2 systems. I am calling this: EntityManager.World.CreateSystem<CollisionPairSystem>(); but it does not end up running. Do I need to manually update it or add it to the group it belongs?

#

Ok figured it out, ComponentSystemGroup is also a ComponentSystem (I am smart :D) which i can get from the world and add my system to its update list πŸ˜„

gusty comet
#

What are these and do I need to put this in my project? These weren't here not too long ago, so not sure if I 'have' to have these in my project or not, I haven't yet gotten to messing with the ECS yet, only jobs and burst for the moment.

safe lintel
#

not sure if those platform packages do anything right now, current dots stuff works fine without em

knotty radish
#

They talked about needing native toolchain in order to build for multiple platform with Burst, maybe this is related

gusty comet
#

Yeah it would be nice to know more details I suppose. I clicked on the documentation stuff and it didn't really say anything other than it was created on so and so date (the doc) its self lol.

gritty grail
#

I am trying to set up a simple object with physics in DOTS, and I have this code, but as soon as I add the PhysicsVelocity, the object stops rendering. Is there something I'm doing wrong?

#
public class EntitySpawn : MonoBehaviour
{
    [SerializeField] private Mesh mesh;
    [SerializeField] private UnityEngine.Material material;
    void Start()
    {
        EntityManager em = World.Active.EntityManager;

        EntityArchetype archetype = em.CreateArchetype(
            typeof(Translation),
            typeof(RenderMesh),
            typeof(LocalToWorld),
            typeof(Rotation),
            typeof(PhysicsCollider),
            typeof(PhysicsVelocity)
        );

        NativeArray<Entity> entities = new NativeArray<Entity>(1, Allocator.Temp);

        em.CreateEntity(archetype, entities);

        for(int i = 0; i < entities.Length; i++)
        {
            Entity entity = entities[i];

            em.SetSharedComponentData(entity, new RenderMesh {
                mesh = mesh,
                material = material,
            });

            em.SetComponentData(entity, new Translation { Value = new float3(0,5,0)});
        }
    }
}```
#

I just want to be able to have basic physics running on my characters.

tawdry tree
#

So if you remove the line typeof(PhysicsVelocity) it works, otherwise it does not?

gritty grail
#

In terms of rendering yes

#

Without

pliant pike
#

are you sure its not flew off somewhere, or is really distant in the scene somewhere

gritty grail
#

I thought that to be a possibility, but for some reason I can't really check the position of the object in the entity debugger

pliant pike
#

how comes it should show up in the debugger

gritty grail
#

One second, gotta make some quick tests

#

So with PhysicsCollider

#

I can't check

#

Without PhysicsCollider

#

With

pliant pike
#

that's weird could be a bug its not parented or a child of another entity is it?

gritty grail
#

Not as far as I know

#

Idk if I just haven't done some sort of prerequisite or not

#

There really isn't much info out there

pliant pike
#

yeah I know

safe lintel
#

you might need to add or update these packages
"com.unity.properties": "0.6.4-preview", "com.unity.test-framework": "1.1.3", "com.unity.test-framework.performance": "1.3.0-preview",
for the debugger to show the components, i literally just did this for something im doing now

gritty grail
#

I do get this error

#

when clicking on the object in the entity debugger

stoic folio
#

Not 100% (need to check my project) but I always get that error and I usually just ignore it and it usually works lol

#

also try adding a floor

#

then testing it

#

I think if you add it to a plane, the default settings for the box collider is messed up, that's why I suggest a cube instead

twin raven
#

When calling simulation group update from monobehaviours fixedupdate (like in Unitys github sample), it is not visible in Entity Debugger πŸ€”

#

Is there a way to get it there?

stoic folio
#

which example was this from?

gritty grail
#

I wanted to try to add physics to objects in pure ECS

#

But I'm just having a little bit of difficulty.

stoic folio
#

you can add physics by pretty much by adding those scripts from the screenshot I sent before

#

just change the motion type to dynamic when you want gravity and stuff on an object

#

if you have the Entities library and the Unity.Physics library installed of course

gritty grail
#

Well how do you add it to an entity that wasn't a gameobject originally?

#

Cause I already know I can add those scripts

stoic folio
#

Hmm haven't done it yet, but I assume you just add whatever components the Physics Body and Shape adds

gritty grail
#

Hmm

#

It still disappears

stoic folio
#

Looked at the code, and it looks like a lot of stuff needs to be created and added

gritty grail
#

And I can't even check its transform

#

Oh I see

stoic folio
#

open the Physics Shape and you can see what they create, most likely you gotta do the same in your own script

#

gonna look at the physics examples, as they have spawners

#

Looks like the Ragdoll demo script is the only one that can create physics stuff without any prefabs

gritty grail
#

Where is that at?

stoic folio
#

My guess is to just not do any of the joint stuff and that's probably all you'll need to spawn an physics object

gritty grail
#

So is all I need to do is make a shape?

#
BlobAssetReference<Unity.Physics.Collider> collider = Unity.Physics.SphereCollider.Create(new SphereGeometry
            {
                Center = float3.zero,
                Radius = headRadius
            }, filter);```
stoic folio
#

I guess if you make a shape, it'll be static

#

there's probably physics body stuff somewhere

gritty grail
#

Well what about the prefab approach?

#

Is that a Hybrid ECS approach?

stoic folio
#

much more easier, lemme get the script from the example

gritty grail
#

Okay

stoic folio
#

I'd recommend getting the whole project and just going through the demos

#

and using that script, you just add the, convert script, physics shape script and physics body script

gritty grail
#

Okay

#

That works for me

#

I'll try it out in a minute, thanks.

stoic folio
#

Here's what the prefab should look like (left) and what the empty game object should look like (right)

#

thought I'd visualize it for anyone else who might be lurking here πŸ™‚

gritty grail
#

Nice, it worked, thanks.

#

I'll just leave my code here

#
using System;
using Unity.Physics;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Collections;
using UnityEngine;
using Unity.Transforms;
using Collider = Unity.Physics.Collider;


public class EntitySpawn : MonoBehaviour
{
    [SerializeField] private GameObject prefab;
    void Start()
    {
        Entity sourceEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(prefab, World.Active);

        EntityManager em = World.Active.EntityManager;

        BlobAssetReference<Collider> sourceCollider = em.GetComponentData<PhysicsCollider>(sourceEntity).Value;


        for(int i = 0; i < 1; i++)
        {
            Entity entity = em.Instantiate(sourceEntity);
            em.SetComponentData(entity, new Translation { Value = new float3(0, 5, 0)});
            em.SetComponentData(entity, new PhysicsCollider { Value = sourceCollider});
        }
    }
}```
#

Now is there a specific way of moving an entity with these new physics?

#

Or can I use translation and rotation per usual?

#

PhysicsVelocity right? .-.

#

Gonna test it

stoic folio
#

You can use translation and rotation

#

but now that I think about it, maybe I should be manipulating PhysicsVelocity instead lol

#

That actually might be a solution for a problem I've been having, thanks for mentioning it

gritty grail
#

It has Angular and Linear value

#

No problem xD

stoic folio
#

Yeah, because in VR, if you just translate it to a point, it'll eventually just clip through, using PhysicsVelocity towards a point might fix that

gritty grail
#

I mean that's also an issue in the regular system

#

Translations are calculated before physics

stoic folio
#

Well technically you can do it after physics, but it just goes through everything πŸ˜ƒ

#

I've tried it, don't recommend doing stuff like that before physics lol

#

Also, I've actually messed around more in DOTS physics than monobehavior physics, just started using Unity this year and stuck with it mostly because DOTS

gritty grail
#

Well I saw an answer like that when I first started in Unity

#

so that's what I'm assuming

stoic folio
#

Wish I knew that earlier, could've saved a day or two of trying to figure it out. Still have to test if it works though

gritty grail
#

Well Velocity is kinda weird

gritty grail
#

I am making my Linear Velocity value = new float3(1,0,0)

#

but it's causing it to go diagonally, even though I'm constraining the rotation to 0,0,0

stoic folio
#

Going diagonal, as in it's rotating diagonally or moving diagonally?

gritty grail
#

moving diagonally

stoic folio
#

Is it constraining the rotation by constantly setting the rotation to 0,0,0? or is there some physics lock system?

#

physics lock system - like freezing an axis

#

via the Physics System

gritty grail
#

Doesn't look like it

stoic folio
#

How are you constraining the rotation?

gritty grail
#
struct MoveJob : IJobForEach<PhysicsVelocity, Rotation>
    {
        public float dt;
        public void Execute(ref PhysicsVelocity velocity, ref Rotation rot)
        {
            rot.Value = Quaternion.Euler(new float3(0,180,0));
            velocity.Linear = new float3(1, velocity.Linear.y, velocity.Linear.z);
        }
    }```
#

I'm testing changing the rotation

#

and it doesn't really seem to do anything

stoic folio
#

maybe do the velocity change first then rotation?

#

idk, reordering stuff can give different results

gritty grail
#

It doesn't really work

#

:?

#

It would be terrible if I couldn't get reliable results from this

stoic folio
#

wait, if it's going diagonal and you're making it go one direction, isn't that gravity making it go diagonal?

gritty grail
#

Uhh, I'm not sure

stoic folio
#

If it's dynamic, set the gravity factor to 0

gritty grail
#

It just makes it float now

stoic folio
#

does it move in one direction though?

gritty grail
#

yeah

#

Velocity seems to be independent from rotation

stoic folio
#

if you want it to stop from rotating, probably have to set the angular velocity to zero

gritty grail
#

Turning the Friction to 0 worked

#
public class TestJob : JobComponentSystem
{
    [BurstCompile]
    struct MoveJob : IJobForEach<PhysicsVelocity, Rotation>
    {
        public float horizontal;
        public float vertical;
        public void Execute(ref PhysicsVelocity velocity, ref Rotation rot)
        {
            velocity.Linear = new float3(3 * horizontal, velocity.Linear.y, 3 * vertical);
            velocity.Angular = new float3(0,0,0);
        }
    }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new MoveJob{
            horizontal = Input.GetAxis("Horizontal"),
            vertical = Input.GetAxis("Vertical"),
        };

        return job.Schedule(this, inputDeps);
    }
}```
#

This really makes me happy lol

stoic folio
#

might borrow some of that code πŸ˜›

gritty grail
#

Np

#

πŸ‘

#

Btw, do you have any experience with raycasting in ECS?

#
        public void Execute(ref PhysicsVelocity velocity, ref Rotation rot)
        {
            if (space)
            {
                velocity.Linear = new float3(velocity.Linear.x, 10, velocity.Linear.z);
            }
            velocity.Linear = new float3(3 * horizontal, velocity.Linear.y, 3 * vertical);
            velocity.Angular = new float3(0,0,0);
            rot.Value = Quaternion.Euler(new float3(0,0,0));
        }```
#

I've added the if statement which works really well besides the fact that you can press space indefinitely.

stoic folio
#

I've looked over the example for it, but haven't tried it yet

#

It's pretty different to the normal way of doing it

#

same with collisions and triggers

gritty grail
#

Okay, I'll have to figure it out soon πŸ‘€

stoic folio
#

If you haven't already, get the ECS sample projects, it has a Query folder

#

and raycasts is in that folder

gritty grail
#

Okay

safe lintel
#

mousepick behaviour has an example of raycasting

upper tiger
#

Hey guys, I made a JobComponentSystem with a little bit of code in it, but when I play it doesnt appear in my entity debugger as a system anywhere. I put Debug.Log() code inside the OnUpdate function but never prints, nor can I breakpoint in the OnUpdate, but I can breakpoint in its OnCreateManger(). Why won't my Job system run?

#

I even created a dummy job struct that just returns and call that in the Onupdate function, still doesnt run

slow epoch
#

Not sure about how it works yet but i think the system detects you are not using that system to get any entity and thinks you don't want to execute it

#

I know it does that but i don't know what are the conditions for that to happen

upper tiger
#

I get that but how does it know that I wont create an entity of a type it uses later

slow epoch
#

Also i suppose you are not modifying the World nor the creation of the systems

upper tiger
#

Even as a ComponentSystem it doesnt work

#

I have 10's of other systems that work just fine, i have no idea why it refuses to run

#
public class SelectionSystem : ComponentSystem
{
    public EntityQuery m_selectedOnlyQuery;
    private Entity previouslySelected;
    private Entity selectedIndicator;
    public EntityQuery m_RockGroup;


    protected override void OnUpdate()
    {
        var spawn = m_RockGroup.ToComponentDataArray<RockTypeSpawner>(Allocator.TempJob);

        if (!EntityManager.Exists(selectedIndicator))
        {
            selectedIndicator = EntityManager.Instantiate(spawn[0].Rock_v2);
        }
      
        var selected = m_selectedOnlyQuery.ToEntityArray(Allocator.TempJob);
        var selectedTrans = m_selectedOnlyQuery.ToComponentDataArray<Translation>(Allocator.TempJob);

        Debug.Log("Selection System");

        if (selected.Length > 0)
        {
            if (selected[0] != previouslySelected)
            {
                var newTrans = selectedTrans[0];
                var newPos = newTrans.Value;
                newPos.z += 2.0f;
                newTrans.Value = newPos;
                if (EntityManager.Exists(selectedIndicator))
                {
                    EntityManager.SetComponentData<Translation>(selectedIndicator, newTrans);
                }                 
                else
                {
                    selectedIndicator = EntityManager.Instantiate(spawn[0].Rock_v2);
                    EntityManager.SetComponentData<Translation>(selectedIndicator, newTrans);
                }

                previouslySelected = selected[0];
            }
        } else
        {
            EntityManager.DestroyEntity(selectedIndicator);
        }

    }


    protected override void OnCreateManager()
    {
        m_selectedOnlyQuery = GetEntityQuery(typeof(Selected));
        m_RockGroup = GetEntityQuery(typeof(RockTypeSpawner));
   
    }


}
candid willow
#

Anyone have suggestions on how I would position 100k meshes and retrieving the transforms from a 20gb JSON file using ECS?

amber flicker
#

(thanks @trail burrow)

trail burrow
#

np πŸ™‚ (what did I do?)

#

πŸ˜„

amber flicker
#

haha yesterday replied about unsafe - I thought someone here mentioned that it can be marginally faster to set values directly (when iterating many) rather than e.g. new Translation(){} - but seeing as a lot of Unity's code does a lot of that I would guess I misunderstood

trail burrow
#

@amber flicker it can be, but it completely depends on what values are involved, exactly how they are being used, etc.

amber flicker
#

hmmm so let's say you iterated 1mil entities and set the translation to a new float3() - are you saying you might expect a difference? Any hints or somewhere you can point me as to how their usage affects the speed?

trail burrow
#

there's no golden rule, it's case by case... calling constructors of course cost performance (unless you're using burst and it's a type burst natively understands, etc.)

#

there really isn't a general recommendation to make here

amber flicker
#

hmmm ok thanks

amber flicker
#

@candid willow it might help if you could be more specific - you can parse the json file and just instantiate 100k meshes and set their translation/rotation.. but I don't feel like I'm doing anything other than rephrasing your question as an answer haha

candid willow
#

@amber flicker haha right. OK so first problem is Unity will crash if I try to load a 20gb JSON file. And then loading in 100k meshes on init seems crude maybe? I was wondering if there were better ways?

#

Or other creative ideas one might have?

#

100k is just the minimum I am testing. There are millions of mesh renderers.

amber flicker
#

I haven't done much with reading large files - I guess it goes without saying you want to stream the file as you go rather than load it all in up-front - I would expect Unity to deal with that fine. It's not generally an issue in ecs to spawn 100k entities with meshes - it might take a few frames - if you don't want any hiccup at all I guess you want to break the workload into e.g. 10k/frame or something. Needless to say you'll likely have performance problems trying to render millions of mesh renderers.

#

(if you planned to render them all at once)

candid willow
#

Yeah I've been exploring level streaming methods

#

I have a websocket set up with database at least for the data streaming

#

Is there any persistence advantage with ECS? Can I load it and leave it

amber flicker
#

hmm instantiation is very cheap (of entities with e.g. a rendermesh component & translation/rotation)

#

are they all unique meshes?

candid willow
#

oh nono

#
#

It this Disney scene actually

#

Trying to assemble in ECS

amber flicker
#

oh yeesh.. I remember looking at that when it came out... good luck!

candid willow
#

Yeah it's a ridiculous in size. Houdini handled it really well but I couldn't get it to render to OctaneRender.

amber flicker
#

that's genuine btw - I'd like to know if you get it working. It is a lot of data though - probably someone else here would be of more help. I don't know of anything obvious you shouldn't be doing - I'd just start by trying to parse the first 1% of the content and get that loading and then go from there.

#

This doesn't seem like something you need to worry too much about how long it takes to import? Just the runtime performance?

candid willow
#

Well, I'd like to investigate progressive load systems. I work in the auto-industry and a car alone could be 100gb minimum

#

And then for runtime performance with realtime era upon us

#

Sucks to sit and wait to load data then try work and iterate

amber flicker
#

I see - so, ideally you want to be importing parts into Unity subscenes and saving them as these DOTS converted scenes - I think they become essentially large blobassets. Then you can stream bits in very efficiently.

candid willow
#

Yeah exactly. Just reassemble on the fly

#

In a few frames you say lol

amber flicker
#

πŸ™‚ - loading blobassets, if they're mostly static and a bunch of shared assets.. it has the potential to be very quick

#

I don't know if anyone here knows the difference between a subscene (or whatever the correct terminology is) and a blobasset but yea perhaps a tool that parses the json and saves chunks as blobassets. Probably depends on how you want to stream them in as to how you break them up.

candid willow
#

Another advantage is decoupling the data from these binary master scene files so they can be reassembled by other renderers.

#

Data oriented amirite haha

amber flicker
#

haha wow, not doing things by halves.. well so I guess the blobasset generation would have a bunch of Unity specific data through right - RenderMesh components and such

candid willow
#

oh you meant blob of a actual scene components. Idk how that would work yet, for sure be some mapping layer that takes the streaming data then converts to a unity consumable format.

amber flicker
#

yea - I'm thinking an editor tool that parses the json, created entities with rendermeshes - serializes to a blobasset/subscene. Then when you stream it in, my understanding is it would be loading a pre-laid out block of memory and everything just works?

tame crater
#

hey im doing begginner tutorials on unity/learn and i just realized..is that smart? dots will most likely take over object oriented workflow being an absolute noob isnt it better to just learn ecs?

#

im doing the karting mod game thing not a lot of coding involved so i guess thats ok

amber flicker
#

@tame crater imo keep going as you are I'd say. It's never bad to learn things and knowledge of DOTS will likely be advantageous for some jobs soon but 1) there are hardly any tutorials for DOTS atm because 2) things are still quite a lot in flux, 3) whilst it might be easier to learn DOD before OOP at this point, OOP isn't going anywhere so you should still be familiar, 4) dots is missing inspector tools atm which make it harder to learn, 5) monobehaviours have many years left. Be aware it exists, look into it when you want to. It's quite a lot to take in with the lack of learning resources though - esp if you're not familiar with the existing way things work.

tame crater
#

alright thank you very much for the explanation ❀ I'll keep going :]

amber flicker
#

Good luck πŸ‘

pliant pike
#

I don't suppose anyone has any idea's for what data structure's I can use for lots of items, like weapons/food items, probably over 50, and each with several stats/variables, so that they are easily editable and accessible

#

I did think of scriptable objects but I dont think they work well with dots also have no clue how to convert

#

My main thinking is just to use a simple text file with a list and load that into a nativearray

coarse turtle
#

Looks like you'll want a BlobArray<T>

crystal zephyr
#

Sorry for a different question. How you would handle the situation if you need a result of an entity query in several systems. Easiest example the player position or position of players. Let's image you have more than one system which needs this information to do its work. Would you have a system to collect all these information and store it somewhere and pass it to the other systems? Or would you do the query in every system? I hope you get the point I am thinking of. How you would solve this?

coarse turtle
#

@pliant pike though, you can also keep your authorable data as a Scriptable Object if you go down that route. The way I'm seeing it is: let's say you have authorable data of 50+ elements, you can edit it in some source file (text file/scriptable), and on runtime you can take the contents of the source file and add it to a blob array. If you want fast searching, I'd imagine you can make your BlobArray treated as a tree

mint iron
#

@crystal zephyr you'd do a query in every system, its just a set of rules for filtering, so its not actually storing anything substantial to worry about having more than one. If you end up on a big project where you're re-using the same thing lots of times, at that point you could consider abstracting them to some sort of helper just to the reduce the duplication / clean things up.

pliant pike
#

Ok cool, thanks guys, I'll check out Blobarrays

stiff skiff
#

Does anyone know if the next Entities release will be 2019.3+ or still work for 2019.2 ?

crystal zephyr
#

@mint iron Retrieving the result as native arrays from the queries isn't an overhead? I thought that causes actually work that's why I ask if it makes sense to persist it somehow during a frame. But if not, it makes things easier.

mint iron
#

@crystal zephyr ahh i see, i missed the part where you said result of. Extracting NativeArrays outside of an IJobChunk does cost you - although not excessively; it does a burst IJobChunk with memcpy to grab all the components in each chunk.

For cross system communication (generally frowned upon) you can have a helper/manager system that exposes public methods for other systems to use. The other systems store a local field, assigned in OnCreate() with World.GetOrCreateSystem<T>();

I don't know your specific requirements but generally you'd want to use the query overload for Schedule() and let it filter inside the job rather than extracting NativeArrays and passing them in.

flat talon
#

@stiff skiff afaik its 2019.3

#

new beta 5 was just released, lets see if we get the new ECS preview soon πŸ™‚

coarse turtle
#

Does anyone know how to grab a command buffer from the universal render pipeline and queue up DrawMesh commands from a component system?

gritty grail
#

What's the new preview ECS?

gusty comet
#

Every time I import Hybrid Renderer I get this error.
"Library\PackageCache\com.unity.rendering.hybrid@0.1.1-preview\Unity.Rendering.Hybrid\LightComponent.cs(86,16): error CS0246: The type or namespace name 'ShadowUpdateMode' could not be found (are you missing a using directive or an assembly reference?)"

#

how is the unity physics performance for things like traces? comparable to physx?

#

(I get that it is very early, just wanted to know the ballpark, and couldn't find any comparison on google)

flat talon
#

@gusty comet yeah that was a mistake on their part, I believe the error goes away if you upgrade to Unity 2019.2 (or was it .3?).

gusty comet
#

Ah okay... I've been scared to upgrade to 2019.3 because it's still in beta, plus I figured it would release here soon considering the roadmap says everythings done, so sorta been waiting on official release.

#

But yeah I'm on 2019.2.6f1 right now

tawdry tree
#

If you're doing DOTS heavy stuff, then you might as well be on the latest beta. Maybe not the week or two after a new quarterly version comes out, but otherwise... Can run beta side-by-side with latest non-beta, too, for your other projects.

gusty comet
#

How stable is the beta right now? I mean is it constantly crashing, major lighting artifacts, etc?

dull copper
#

totally depends what you couple it with

tawdry tree
#

Those sounds more like the symptoms of an alpha or, as 0lento suggested, a bad combo with something else.

gusty comet
#

Alrighty, thanks everyone. I'll attempt it, but i'll make a backup first lol

dull copper
#

@gusty comet should be quite snappy with queries especially

#

Unity itself has a lot of confidence on that part being fast

#

raycast, sweep, overlap check = query

gusty comet
#

Just got 2019.3 installed and project in it... But one of my scripts has an error for this "using UnityEngine.Experimental.Rendering.HDPipeline;" Do I need to edit this to something different or is this not needed anymore?

gritty grail
#

Right now I'm trying to work out all of the things I can do with the new physics engine personally

safe lintel
#

@gusty comet i believe its UnityEngine.Rendering.HighDefinition now

gusty comet
#

Yeah I'm going back to 2.6 this beta bugged out the moment I started doing anything

#

Empty Scene, and this error constantly.

Compute shader (Deferred): Property (_XRViewConstants) at kernel index (30) is not set
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)```
tawdry tree
#

Pipeline stuff, joy

gusty comet
#

loll

gritty grail
#

I'm actually really liking the beta

#

It looks kinda cool

#

Wish there was a way to turn off rotation in the Physics Engine

#

Cause my setup has to snap the physics back in place, but you can still notice it freak out just a tiny bit in some instances

#

such as when you're stepping over the ledge and your center of mass is off the ledge

#

The object just freaks out a little bit

#

I wonder if I can fix this issue by overriding whatever does the physics calculation

dull copper
#

@gritty grail you can freeze the rotation

gritty grail
#

Oh, how do I do that?

dull copper
#

well, if you use DOTS physics packages, there's no like checkbox for it like there is for built-in physics

gritty grail
#

Yeah

dull copper
#

but you can override the inertia tensor if you want to stop the thing from rotating

#

I think setting all to zero on it would freeze all rotations

gritty grail
#

Where is Inertia Tensor located?

dull copper
#

there was a more detailed forum posts on the unity forums about this by Havok physics guys

#

I think the mass override setting is on same place where you have the rigidbody

#

physics body?

#

I'm horrible in remembering the exact names of the classes

gritty grail
#

One sec

#

I'll get you the names

#

Physics Collider

#

Physics Damping

#

Physics Mass

#

Physics Step

#

Physics Velocity

#

And I think that's it

dull copper
#

that's one weird looking list

#

one sec, I'll check it

gritty grail
#

Is Inertia Tensor in a component?

#

Or is it in a System?

dull copper
#

no

#

you override it from physics body component itself

gritty grail
#

Oh

dull copper
gritty grail
#

Oh there it is

#

πŸ‘€

#

Except messing with the Inertia Tensor seems to break my movement script

dull copper
#

you tried putting zeros to it?

gritty grail
#

Yeah

dull copper
#

well, worth a shot

#

I'm sure it's been covered there at least once or twice in the past

gritty grail
#

Okay

#

I'll look

#

I think it's PhysicsMass.InverseInertia

#

Okay, so I have another question

#
entityManager.SetComponentData(entity, new PhysicsMass { InverseInertia = new float3(0)});```
#

This line causes the entire entity to not render

#

I think it's because it replaces the old PhysicsMass.

#

How do I only change the variable inside of an entity without rewriting the whole Component?

#

Because right now to make my code work, I have to do it in my job, but that runs in a loop, and I believe I'm only supposed to set the InverseInertia once.

low tangle
#

getcomponentdata

#

modify that struct returned

#

apply that back afterwards

lament orbit
#

So I see 'Live Link' in the DOTS menu... I can't seem to get this to work at all. Very excited for this feature.. anyone know if it works / how to use the feature, or is this still half baked?

low tangle
#

not fully out

#

the next release of entites will have it

lament orbit
#

mmm looking forward to that release as well

#

hopefully this year

slow epoch
#

So how is ecs going production ready on 2020.1 but we still don't have almost any editor tool avaliable for it

gritty grail
#
            var data = em.GetComponentData<PhysicsMass>(entity);
            data.InverseInertia = new float3(0);
            em.SetComponentData(entity, data);```
#

Like this?

#

Ok cool, that worked great, thanks.

gritty grail
#

Does anyone know how the CollisionFiliter works?

#

I'd like to set it up so that it makes a Raycast only collide with the ground.

#

So far, I've set the ground as belongs to the 0 layer

#

If I'm understanding this correctly, I'm supposed to change the CollidesWith variable

#

Does it work how layer masks normally work in regular Unity?

low tangle
#

|| I dont want to be a dick but read the documentation, its actually pretty good ||

gritty grail
#

Oh I did read

#

I just didn't understand exactly what it said in terms of what I needed

#

Since I'm not exactly the most advanced user.

#

I don't think I would've gotten as far as I have if I didn't read the documentation.

low tangle
#

yes they are just a basic bit mask and work like unity layers

#

& 1 << n the bit you want

gritty grail
#

Okay

gritty grail
#

I'm using this code ```csharp
public struct Raycasting
{

public bool isGrounded(float3 RayFrom, float3 RayTo)
{
   var physicsWorldSystem = World.Active.GetExistingSystem<Unity.Physics.Systems.BuildPhysicsWorld>();
   var collisionWorld = physicsWorldSystem.PhysicsWorld.CollisionWorld;
   RaycastInput input = new RaycastInput()
   {
       Start = RayFrom,
       End = RayTo,
       Filter = new CollisionFilter()
       {
           CollidesWith = (uint)(1 << 0),
           BelongsTo = ~0u,
           GroupIndex = 0
       }
   };

   RaycastHit hit = new RaycastHit();
   bool haveHit = collisionWorld.CastRay(input, out hit);
   return haveHit;

}
}```

#

And I'm running it here.

#
    [BurstCompile]
    struct MoveJob : IJobForEach<PhysicsVelocity, Translation>
    {
        public float horizontal;
        public float vertical;
        public bool space;
        public float dt;
        public Raycasting casting;
        public void Execute(ref PhysicsVelocity velocity, ref Translation trans)
        {
            Debug.Log(casting.isGrounded(trans.Value, trans.Value + new float3(0, -5, 0)));

            if (space)
            {
                velocity.Linear = new float3(velocity.Linear.x, 6, velocity.Linear.z);
            }
            velocity.Linear = new float3(3 * horizontal, velocity.Linear.y, 3 * vertical);
            velocity.Angular = new float3(0,0,0);
        }
    }```
#

But this is giving me an error

#
bool haveHit = collisionWorld.CastRay(input, out hit);```
#

And I'm not sure what to do with it

safe lintel
#

i dont think you should be getting the collision world inside the joib

#

so just grab it when you create the job in OnUpdate

#

well either system really

gritty grail
#

Hmm

gritty grail
#

Well I guess my method of trying to tell if the player is grounded or not didn't work super well

#

The raycast for whatever reason says false if you're on the ground unless you move a bit, then will say true. As you jump it says false and the issue repeats itself

#

That's pretty tough.

#

Is there an example of someone implementing an isGrounded function in the new Physics Engine?

#

Cause I'm thinking about maybe using collider cast if that even works

safe lintel
#

are you by chance hitting yourself when you cast a ray?

gritty grail
#

I was before but I'm not now.

#

The weird thing is that even if I exclude the player object from being detected by the raycast, no matter what the raycast is false if it is touching the player

safe lintel
#

are you sure the filter is correct? ill be honest, i dont understand setting up the filter manually but i just pass in the filter directly from the PhysicsCollider for my own grounded check

gritty grail
#

And you use a raycast?

safe lintel
#

yeah its pretty simple

            private void CheckGrounded(ref ControllerBody body, ref Translation translation, ref PhysicsCollider collider, ref PhysicsVelocity velocity)
            {
                var rayInput = new RaycastInput();
                rayInput.Start = translation.Value;
                rayInput.End = translation.Value + 1.4f * maths.down;
                rayInput.Filter = collider.Value.Value.Filter;
                
                //var allhits = new NativeList<RaycastHit>( Allocator.Temp);
                bool hit = CollisionWorld.CastRay(rayInput, out var rayHit);
                
                if (body.Grounded && hit)
                {
                    body.InitialUnsupportedVelocity = velocity.Linear;
                }
                body.Grounded = hit;


            }

gritty grail
#

And what are you passing to your PhysicsCollider?

safe lintel
#

nothing gets passed to it, that ref could be removed

mystic mountain
#

Lets say I have timers in a component SystemA checks timers and trigger SystemB by adding a tagComponent. Would it better to remove the tag in SystemB or add a "cleanup" SystemC afterwards? : )

amber flicker
#

@mystic mountain if you'll have more than one tag change, would recommend you do it using a bulk method - e.g. myQuery.RemoveComponent<Trigger>(); - this can either sit in a separate system that runs before the end command buffer or using a custom command buffer or in SystemB (but assuming that has a job, you'd have to call .complete on the job)

mystic mountain
#

@amber flicker Bulk method? I don't see that on EntityQuery?

#

And when you say more then one tag change, do you mean multiple ComponentType, or multiple entities with same Component?

amber flicker
#

so, I wasn't exact with syntax but with an entity query you can essentially filter for certain archetype(s) right? So if you did myQuery = GetEntityQuery(typeof(Trigger),typeof(Transform)); or something, you could then do entityManager.RemoveComponent(myQuery, typeof(Trigger)); - the cool thing about this is it changes the matching archetypes - it doesn't actually add or remove components. It makes all archetypes that have Trigger & Transform, instead be just Transform (and whatever else they had). So it's very cheap.

#

I believe it's a pretty common way to implement an event system

mystic mountain
#

Humpf

#

That's dope.

#

But if the final archetype already exists, there still has to be a cost right?

#

And also if the query is contained in multiple archetypes(?). This is something I'm unsure of though.

amber flicker
#

There's a cost, but it's very small. The query can return multiple archetypes, yes. I'm not sure how that's handled - in terms of merging to an existing archetype does anyone here know? I had pictured each chunk having an int into an array for its archetype but I don't actually know for sure. That would mean iterating changed chunks and essentially changing an int. Whereas if it became a unique archetype, I had imagined updating that archetype in the archetypes array. If that's how it worked, it would still be very cheap but they may do something more clever.

mystic mountain
#

Hmm yeah, that's true. The only memory change would be the unfilled chunks of the existing archetype, and changed archetype.

amber flicker
#

Upshot is you could create a million entities and change all their archetypes super super quick. Usually you want to change a subset of a particular archetype which is where everything slows down but things like events / oncreated etc are perfect for this.

upper tiger
#

if i have an Entity variable in my system and I want to essentially "null" it, how can i do that

#

set the entity to 0?

amber flicker
#

Entity.Null

upper tiger
#

awesome thanks

amber flicker
#

fyi, it is just index = 0 and version = 0

upper tiger
#

I thought so

dire frigate
#

Is there a way to add a class to a entity, or a monobehavior runtime?

#

I've tried to do add component but it seems to only accept structs

amber flicker
#

you can associate a monobehaviour with an entity using 'entityManager.AddComponentObject()` which is useful when doing some hybrid things with entities

#

but the way you formulated the question I feel I should ask what are you trying to achieve? Ideally you want to avoid logic being with your data when doing the ECS thing

#

@dire frigate

dire frigate
#

Storing player inputs received from the client in their class just to store info, each tick I'd remove one element from the buffer and apply it to movement

#

in the JobComponentSystem

#

The server itself runs with Mono, although all players are entities

#

I guess I could just store a buffer under one of the structs, but I'd want to add the CharacterController aswell to the entity

#

rather than the PhysicsBody

#

Or is the PhysicsBody deterministic?

amber flicker
#

...processing..

#

ok so I'm a bit unsure why you'd want to add the character controller to the entity and what that has to do with the physicsbody being determnistic? You can use a buffer to store a series of player inputs, yes.

twin raven
#

Why I cannot have [DeallocateOnJobCompletion] on jobs NativeMultiHashMap?

dire frigate
#

Reason why I am questioning the physicsbody is that to get reliable client side predictions you need deterministic data

#

The character controller can be made deterministic

#

Rigidbody isn't deterministic, which is why I am not using it. The ECS equavelent being PhysicsBodyAuthoring, I'm not sure is either

#

So I am reliant on the CharacterController, if the PhysicsBody is deterministic then I'd go with that (that way I can use the JobComponentSystem)

radiant sentinel
#

hello, where can i report bug for ecs?

main oriole
#

Unity bug reporter is the best place

honest dirge
#

@twin raven no idea but they do have a Dispose that returns a JobHandle

upper tiger
#

@twin raven what is the error you are getting and the code context around where its being used?

radiant sentinel
#

@main oriole has "unable to write" error on end of upload

main oriole
#

That's very weird. In that case just go to the beta forums for ecs/dots and say that u had issues during upload with the reporter

mystic mountain
#

I'm just starting to look at subscenes. My background is that I'm using the DOTS multiplayer and want the server and client to be able to exist in different "scenes" (menu, lobby, game etc) to emulate connection parts more properly. So my basic understanding of subscenes is that it caches the output of the Conversion workflow, and can be loaded directly into RAM. My starting question is does the subscene gameobject need to be in a scene itself? Or can we store it on prefabs as well?

gritty grail
#

How do I pass Collision World into my job?

#
    [BurstCompile]
    struct MoveJob : IJobForEach<PhysicsVelocity>
    {
        public float horizontal;
        public float vertical;
        public bool space;
        public float dt;
        public CollisionWorld collisionWorld;
        public void Execute(ref PhysicsVelocity velocity)
        {
            if (space)
            {
                velocity.Linear = new float3(velocity.Linear.x, 6, velocity.Linear.z);
            }
            velocity.Linear = new float3(3 * horizontal, velocity.Linear.y, 3 * vertical);
            velocity.Angular = new float3(0,0,0);
        }
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var physicsWorldSystem = World.Active.GetOrCreateSystem<Unity.Physics.Systems.BuildPhysicsWorld>();
        var collisionWorld = physicsWorldSystem.PhysicsWorld.CollisionWorld;

        var job = new MoveJob{
            horizontal = Input.GetAxis("Horizontal"),
            vertical = Input.GetAxis("Vertical"),
            space = Input.GetKeyDown(KeyCode.Space),
            dt = Time.deltaTime,
            collisionWorld = collisionWorld,
        };

        return job.Schedule(this, inputDeps);
    }```
#

I'm trying to do this

#

And I just continue to get errors like this

mystic mountain
#

Hmm, yeah I think that sort of is bug, but not sure - haven't looked into it lately. What I currently do is I call Complete on the scheduled job that uses physics. If I remember it correctly, they reset some array outside of a job in an OnUpdate.

scarlet inlet
#

Hello, I am digging inside some job code, no documentation around. Do you know what's the purpose of CreateJobReflectionData ?

#

I am also trying to understand how I am supposed to know how to use JobScheduleParameters (specifically the first two parameters)

mystic mountain
#

@gritty grail If it works you can also move your job to after EndFramePhysicsSystem

gritty grail
#

Where do you call complete?

mystic mountain
#

On the job you just created. But it's because I assumed it was a bug when I first saw it as well πŸ˜›

#

The problem I see is that BuildPhysicsWorld calls complete on the handle from last frames physics. But anything using the result arrays aren't checked for. I think the error comes from Broadphase Clone() method when number of bodies change. If I remember correctly X)

scarlet inlet
safe lintel
#

@gritty grail
var handle = job.Schedule(this, inputDeps); handle.Complete(); return handle;

#

its weird i sometimes have to call complete for some jobs using collisionworld and others dont need it 🀷

gritty grail
#

oh okay

#

that's how you do it

#

Well

#

uh

#

it slowed down my physics simulation by a lot

#

can't win can I 😞

safe lintel
#

well you are doing it for every physics entity, is that intentional?

#

but calling complete does cause some hickups for me too I think so i dont think its entirely out of the ordinary

gritty grail
#

Oh I see, you're right

#

Doesn't help though xD

#

Maybe I'll run physics in just a regular component system

#

And have a component called grounded

#

Oh boy I broke something

#

xd

next path
#

Am I an idiot or is the Entities package just MIA?

dull copper
#

you've enabled showing preview packages on the package manager?

next path
#

Yes

dull copper
#

sometimes PM is just not updating the list also

#

so jumping between in project and all packages could fix the list

#

I dunno if there's a refresh button now

next path
#

i'm unsure what you mean

dull copper
#

which engine version are you using now?

#

PM = package manager

next path
#

2019.2.61 is on this machine right now, but I can use whatever

dull copper
#

should show up on 2019.2

#

you can also just manually modify the manifest.json from packages -folder if you know the package name and version you want to use

#

there are some new packages that don't get automatically listed on package manager but entities should be one of the visible ones

next path
#

oh now it shows up under preview... I think I may have been using a beta version the last time I checked under preview, and I was wondering if it had been integrated as baseline or something

#

Thanks

#

I don't know what to make of the fact that theres still no version of the package that isn't still considered a preview... like... are they advising it be used in production or not?

mystic mountain
#

@gritty grail so it won't work for you to put your job after the physics simulation?

gritty grail
#

Yeah, it's causing a lot of random errors

#

But right now my physics simulation is just broke

#

so maybe time to start a new project file? xD

safe lintel
#

it can be salvaged!

gritty grail
#

I didn't even do anything to it and now it's just super slow

mystic mountain
#

Somtimes it's easier to pinpoint the problem that way yes πŸ˜›

gritty grail
#

πŸ‘€

#

Even going back to my old scripts doesn't fix it

mystic mountain
#

Do you profile it?`

safe lintel
#

got stack tracing on? burst disabled?

mystic mountain
#

Profiling the player that is.

gritty grail
#

wait hold on

#

I did turn on stack tracing

#

cause it told me to