#archived-dots
1 messages Β· Page 87 of 1
But i'm not sure if you can actually do that with jobs
Or if it follows the data oriented design
i saw something recently that is essentially wrapping an ComponentDataFromEntity/Buffer/Archetype so you can run multiple within a job with less arguments being passed in. https://forum.unity.com/threads/how-to-work-without-interfaces-and-other-questions.742514/#post-4959302
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
i think i would have a single job that goes through every command, switch on command type, and call different static methods.
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
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.
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 π
np!
static global methods with ECS is a really good pattern and highly recomended
of course, pure functions so they dont give issues
TBH pure function statics are great for helper and utility code, in general.
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
i'm wading through burst build issues, i feel your pain.
is there more detail when u click on it
@quaint blade There is no support for cross compilation with burst
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
its a bit of a nightmare right now, perhaps they're trying to upsell us on using cloud build
We've had to turn off burst for all platforms in the projects we provide
Which is a shame, since burst really does help
why is that, build issues or crashes and other things?
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...
yeah i heard mac builds were failing with burst on the forums.
yea https://forum.unity.com/threads/burst-is-failing-during-cloud-build-works-locally.719762/ - "Note that we should hopefully start to work on supporting cross compilation for burst later this year"
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
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
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.
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
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.
@mint iron also getting fed up with the constant "oh this new shiny thing... btw yeah not ready to be actually used yet" ?
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
@mint iron It would be cool to get more info/clarity on exactly how Systems work, like why they start and stop running
@mint iron what about asking for bugs that have been reproduced to be auto added to the issues tracker
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?
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.
@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.
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?
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?
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
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
Is there a particular reason why CopyTransformFromGameObject doesn't update Translation on the corresponding entity?
@stuck saffron does it have a LocalToWorld component
did you add the transform to the entity as well
oh
yea seems it only updates LTW
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
yeah seems weird
hass anyone else come across this error "cannot implicitly convert type Unity.Mathematics.bool3 to bool"
and knows how to deal with it
convert it manually?
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
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
lmao
that works thanks @mint iron
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:
- enum that holds the component type. Based on the enum do an explicit cast to the correct type
- use the dynamic keyword and convert the type to whatever the
.GetType()is
Just wondering of better ways to do it
Is there a multithreaded solution or equavalent to the CharacterController?
Wanna use JobComponentSystem but the CharacterController sort of limits me to use ComponentSystem...
I think you will probably have to make your own
@dire frigate there is a basic one in the physics examples that i used for my own base
Do you guys have some samples with Dynamic buffer ?
fluent API for job scheduling too π
animation engine..?
non-retarded ECS editor, at last
that conversion workflow auto-boilerplate and preview is so much better
so that's what live link is all about π€ been wondering about that for a while
if you can live-edit entities by changing the GO and have it auto recreate, then thats really great
It looked like you could. He translated and duplicated a couple of GO's
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.
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?
@amber flicker What do you mean by full core usage
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
ikr
I want the animation package so bad
finally can finish my ecs ik system
just need to render that data π©
im looking forward to the changes to the transport layer
some new DOTS packages just showed up on the package manager for me, DOTS Platforms [Windows/Android/ios etc] ? and a Device simulator
@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.
So the conversion system hasn't really changed but they fixed the workflow up a bit? That's a nice fix.
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?
store an entity on a component and then use ComponentDataFromEntity to lookup that entity
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.
do a search that looks it up then
you mean like finding an entity by using something else like a raycast?
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.
so entity b is the parent of entity a?
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."
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
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
am i missing something that componentdatafromentity wouldnt be appropriate? ie
`
translationData = GetComponentDataFromEntity<Translation>();
if(translationData.Exists(entityB))
myTranslation = translationData[entityB].Value;
`
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
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
Figured it out! Thanks, guys. The hashmap idea worked great @coarse turtle.
Is it normal for a JobComponentSystem to have this much overhead? (It contains no logic whatsoever.)
you are looping over all entities
also dont cache the entity manger
its already there
Ah, that makes sense! And thanks for the tip.
ππ»
theres a dots editor package.. https://docs.unity3d.com/Packages/com.unity.dots.editor@0.1/manual/index.html
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
How much meshes are unique? All? 90%?
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
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?
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.
@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
yea either that or an intermediate multihashmap or something
possible to have a string, or fixed sized char array in IComponentData?
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
@low tangle Thanks! I assume it's not possible to get the char array to directly ref copy into?
I believe you can. I've never needed it though
There's constructors for string and other native string
Using the DOTS multiplayer DataStreamReader
so would be nice to be able to read it directly into the Component : )
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.
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
dots project to be released later this year from the blog π© hope that doesnt hold back the packages
when working with ECS what are some of the pre made classes to be aware of ( like Unity.Transforms )
ComponentSystem, JobComponentSystem, EntityManager, World? a lot your of data are simply going to be structs more than classes π€
no i mean the pre made data classes
components you will likely use a lot - LocalToWorld,Translation,Rotation,Scale
possibly - Parent,LocalToParent, Disabled
sharedcomponent -RenderMesh
buffer - LinkedEntityGroup
^
Ah that's what you meant
true forgot to check the docs, watching tutorial vids now
is there a way to inspect archetypes ?
Usually through the EntityDebugger
pinned message here has good info too
like if i create an entity only from 1 type without the archetype its possible to click and inspect the value
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
oops that was some bug with my editor (...?) i re compiled and now i can inspect normally via the entity debugger, thanks
np
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
Might be, I have the same behaviour too
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 ).
you should make some suggestions on the forums
https://forum.unity.com/threads/entity-debugger-feedback.522893/
@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 )
is there a way to create a ComponentSystem variable that will be editable in the inspector similar to mono behaviour ?
only if you make a monobehaviour for your system
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;
// ...
}
}
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
@dire frigate show ? like inspect their data ?
Just wanna see them in my scene to begin with π They just disappear
On play, that is
check if they exist in Entity debugger ?
They do, just not "visible" in the scene
Like a standard capsule
smack ConvertToEntity on it
and poof
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
no worries, although cheers π
i just peeked the source code for this class there are 2 different modes
maybe try ConvertAndInjectGameObject ? ( ConversionMode )
Doesnt work either π It's definately moving under the hood
https://gyazo.com/2c3cd616f26fb483b7e4b7e563358494
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;
}
}
do you have the hybrid renderer package added?
That worked, cheers June π
That is such a common occurrence, they should make it super obvious that you need the package to render
yeah some error or some sort would be nice, or have it included on install. Works now atleast
https://gyazo.com/eb06b8d6fc62551aa2b38cb1a267118e
nice, is that for a personal project ?
Just a hobby project
send updates when u can π
just made my few 1st steps with ecs today
( screen recorder is lagggy... )
looks mesmorizing π
anybody interested testing a quick test implementation of a debug gizmo drawer system ?
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
so gizmos are used for not in play mode, right ? how do you work with entities while still in editor ?
Oh no currently it's just a quick test for how I could draw some gizmos from jobs so only at runtime right now.
interesting, i would like to see, do you have a demo scene as well ?
that above my level, im just starting with ecs to get into dots physics for a project
share this on reddit as well π
Let me know if/how it works for you.
@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
From Unite Copenhagen
https://www.youtube.com/watch?v=TdlhTrq1oYk
Uncover the process of converting GameObjects to Entities and how this can be extended and customized. Speakers: Simon Mogensen - Unity Fabrice LΓ©te - Unity ...
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?
Anyone who knows what I'm doing wrong here?
https://pastebin.com/TpLfxLGT
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
Aren't InputDeps doing that?
Not so sure what's that but i usually do itcalling Schedule(JobHandle dependence)
JobHandle *
Doesn't it do this automagically when I schedule job using JobHandle from OnUpdate call?
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
It's dots networking systems, so the first job is calling the internal Update and writing to the nativeArray I imagine.
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
Yeah, I'm a bit confused. The sample code doesn't need to add the dependency separately from what I can see.
Moved the code to a new project, same error. Now trying to cut it down until it stops complaining xD
Finally found it, and it even says in sample lol...
// Group used only to get dependency tracking for the driver
GetEntityQuery(ComponentType.ReadWrite<PingServerConnectionComponentData>());
@fringe sinew I've heard if you use .Run() instead of schedule then it runs on the main thread.
Is that a workaround to using burst for very small functions on the main thread?
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.
Alright, thanks for clarification. That was some strange wording on the slide though
Do you always need to add m_barrier.AddJobHandleForProducer(inputDep);when using commandBuffer, or only when using the concurrent one?
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
adding a job handle to a barrier allows jobs to complete first before the ecb runs
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?
destroy/create is really fast
@final gyro the ECS IS a pool
on itself
basically everything is pooled by default
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 π€?
using CommandBuffers to destroy the entity
EntityCommandBufferSystem if you need the system
PostUpdateCommands.Destroy(Entity) -> ComponentSystem
EntityCommandBufferSystem.Destroy(Entity) -> JobComponentSystem
Oooh another DOTS sample project apparently - https://github.com/Unity-Technologies/DOTS-Shmup3D-sample
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)
yea same, one was with project tiny and web controllers
Do I recommend I use the job system for my use case @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
No I am doing Pure ECS
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() π€
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 π€
AFAIK in the latest package, EntityManager.DestroyEntity() should be deferring it and allows structural changes
on a ForEach
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));
});```
Yea that's a way of doing it
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
yea, and they are only destroyed when the ISystemState is removed
so I was pretty excited when I heard that Unity has added ECS. How awesome has it been?
its a bumpy hell of a ride
hard to tell if that's a good thing or a bad thing yet, heh.
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 π©
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
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 π
What is the recommended way of destroying entities? PostUpdateCommands.Destroy or EntityManager.Destroy
I'd say destroy by EntityQuery overload
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
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
@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?
But I was told ECS already implements the pool system π€?
yeah, I'm instatiating and destroying a lot with my prototype just using single threaded ecs
Any chance you could show your script Calabi?
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.
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
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
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?
I KNOW YOU @wary anchor !
So yeah I guess it wonβt matter if I use Jobs then really @amber flicker Much love man
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
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.
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
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);
}
}
rotation is absolute, you are only feeding it per frame delta of the mouse movement
accumulate it instead
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?
mul(quat, float3)
Well that's just me being dumb as usual, cheers once more
ππ»
Hey looks like these are out
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
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
}
@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
@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.
Yeah I think I need to use something like native hashmaps when looking at there boids example
Definitely some things are a bit tricky
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.
Hi how can i detect collision or trigger enter on dots package?
Physics package
@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
Dive deep into the networked future of Unity using DOTS. Hear how we made the DOTS Sample a networked game, and what we learned on the way. Speaker: Tim Joha...
that was fast π
Anyone know if you can use particle effects with entities yet?
or convert them to entities rather
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
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?
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
But when i will instantiate from it, it will be automatically converted to regular entity?
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.
if so then it is excellent. thanks for the clarify
@dull copper nice meeting you in copenhagen btw π
you as well, sorry for ruining the anonymity thing, just couldn't help it π
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
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 π
feature set seems to be the same as what's on github, but with a slightly more cleaned up workflow
I mean, I did quickly browse the beginning and it seemed very intro like but can't comment on the rest
give or take
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
it's pretty far from mature from the looks of it (netcode part that is, dots itself is coming a long nicely tho)
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
i mean DOTS is starting to look really nice, at least when the stuff they showed at unite is out
it's nice that they finally start uploading these asap and not having to wait that typical 3 weeks for the most anticipated ones
yeah
and yeah, I'm all for reducing boilerplate
editor workflows also need those improvements badly
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
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
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
@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
@coarse turtle is there any way to translate in world space if an entity is child of another entity?
yeah, inverse the matrix from local /object space -> world space
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
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
@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..
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
Is there any way to convert unity components that doesn't have an auto convert yet like Sprite Renderer?
not out of the box, most ppl have implemented their own versions, which usually takes a texture and render it to a mesh
What do I need to do to a camera to make a ECS-converted object visible in it?
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
@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
@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.
any word on when DOTS 1.0 is going to release?
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.
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
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
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;
}
Your goal is to run something every X time, right?
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
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
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
No repeated events. This is an endless runner kinda game
I assume you want to potentially have multiple spawners with different times etc?
A single spawner, same time
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
Every 2 seconds or so
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)
SpawnStuff is supposed to create entities
I donβt think you can do EntityManager.CreateEntities inside a System no π€?
Yes you can
Oh!
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
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
Obligatory link: https://github.com/Unity-Technologies/EntityComponentSystemSamples
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?
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
Awesome! Thank you very much!
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
reeeee
dont put hidden data into the component system
only stuff that helps it run more performant like acceleration structures
what is hidden data
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.
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
ahh i see
you were talking about the wavespawnsystem above right
in that case wave should be a singleton component?
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
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
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?
Related to those examples, just a warning theyβre broken in the 2019.3 beta
Is it possible to do a car controller with ECS π€?
@low tangle What do you mean a singleton component?
Thereβs already a car physics example in that bundle
@final gyro implement physic world and your car physic, then set value of physic velocity component data
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
@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
Also yay for #archived-dots channel rename:)
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
Maybe but I wonder how good havok will be
You can try it right now (perhaps @dull copper should add the docs to the list https://docs.unity3d.com/Packages/com.havok.physics@latest)
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?
@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
~should you post dots phyiscs, networking in this channel now or keep in respective channels? O.o
Whatever makes you comfortable
they're not the most active channels, so spread it as evenly as you want π
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?
Will Havok be free in unity or will it be a separate commercial package like it is normally?
Oh nevermind I see now
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
How would you have a list of prefabs without having to convert them to gameobjects π€?
I have sections of my level saved as prefabs
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.
@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
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 π
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.
not sure if those platform packages do anything right now, current dots stuff works fine without em
They talked about needing native toolchain in order to build for multiple platform with Burst, maybe this is related
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.
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.
So if you remove the line typeof(PhysicsVelocity) it works, otherwise it does not?
are you sure its not flew off somewhere, or is really distant in the scene somewhere
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
how comes it should show up in the debugger
One second, gotta make some quick tests
So with PhysicsCollider
I can't check
Without PhysicsCollider
With
that's weird could be a bug its not parented or a child of another entity is it?
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
yeah I know
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
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
Add these scripts to a stretched out cube
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
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?
which example was this from?
I wanted to try to add physics to objects in pure ECS
But I'm just having a little bit of difficulty.
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
Well how do you add it to an entity that wasn't a gameobject originally?
Cause I already know I can add those scripts
Hmm haven't done it yet, but I assume you just add whatever components the Physics Body and Shape adds
Looked at the code, and it looks like a lot of stuff needs to be created and added
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
Where is that at?
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
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);```
I guess if you make a shape, it'll be static
there's probably physics body stuff somewhere
much more easier, lemme get the script from the example
Okay
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
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 π
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
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
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
I mean that's also an issue in the regular system
Translations are calculated before physics
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
Well I saw an answer like that when I first started in Unity
so that's what I'm assuming
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
Well Velocity is kinda weird
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
Going diagonal, as in it's rotating diagonally or moving diagonally?
moving diagonally
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
Doesn't look like it
How are you constraining the rotation?
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
maybe do the velocity change first then rotation?
idk, reordering stuff can give different results
It doesn't really work
:?
It would be terrible if I couldn't get reliable results from this
wait, if it's going diagonal and you're making it go one direction, isn't that gravity making it go diagonal?
Uhh, I'm not sure
If it's dynamic, set the gravity factor to 0
It just makes it float now
does it move in one direction though?
if you want it to stop from rotating, probably have to set the angular velocity to zero
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
might borrow some of that code π
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.
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
Okay, I'll have to figure it out soon π
If you haven't already, get the ECS sample projects, it has a Query folder
and raycasts is in that folder
Okay
mousepick behaviour has an example of raycasting
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
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
I get that but how does it know that I wont create an entity of a type it uses later
Also i suppose you are not modifying the World nor the creation of the systems
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));
}
}
Anyone have suggestions on how I would position 100k meshes and retrieving the transforms from a 20gb JSON file using ECS?
(thanks @trail burrow)
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
@amber flicker it can be, but it completely depends on what values are involved, exactly how they are being used, etc.
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?
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
hmmm ok thanks
@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
@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.
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)
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
hmm instantiation is very cheap (of entities with e.g. a rendermesh component & translation/rotation)
are they all unique meshes?
oh nono
At Walt Disney Animation Studios, technologists and artists work together to advance the art and science of animation. Inspired by our rich legacy, we look ahead to discover new tools and techniques that will shape the future of animated storytelling.
It this Disney scene actually
Trying to assemble in ECS
oh yeesh.. I remember looking at that when it came out... good luck!
Yeah it's a ridiculous in size. Houdini handled it really well but I couldn't get it to render to OctaneRender.
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?
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
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.
π - 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.
Another advantage is decoupling the data from these binary master scene files so they can be reassembled by other renderers.
Data oriented amirite haha
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
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.
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?
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
@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.
alright thank you very much for the explanation β€ I'll keep going :]
Good luck π
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
Looks like you'll want a BlobArray<T>
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?
@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
@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.
Ok cool, thanks guys, I'll check out Blobarrays
Does anyone know if the next Entities release will be 2019.3+ or still work for 2019.2 ?
@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.
@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.
@stiff skiff afaik its 2019.3
new beta 5 was just released, lets see if we get the new ECS preview soon π
Does anyone know how to grab a command buffer from the universal render pipeline and queue up DrawMesh commands from a component system?
What's the new preview ECS?
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)
@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?).
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
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.
How stable is the beta right now? I mean is it constantly crashing, major lighting artifacts, etc?
totally depends what you couple it with
Those sounds more like the symptoms of an alpha or, as 0lento suggested, a bad combo with something else.
Alrighty, thanks everyone. I'll attempt it, but i'll make a backup first lol
@gusty comet should be quite snappy with queries especially
Unity itself has a lot of confidence on that part being fast
if you read https://docs.unity3d.com/Packages/com.unity.physics@0.2/manual/design.html they state: For any physics features that do not cache state, e.g. raw collision queries, we expect Unity Physics performance to be on par with, or outperform, similar functionality from commercially available physics engines.
raycast, sweep, overlap check = query
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?
Right now I'm trying to work out all of the things I can do with the new physics engine personally
@gusty comet i believe its UnityEngine.Rendering.HighDefinition now
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)```
Pipeline stuff, joy
loll
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
@gritty grail you can freeze the rotation
Oh, how do I do that?
well, if you use DOTS physics packages, there's no like checkbox for it like there is for built-in physics
Yeah
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
Where is Inertia Tensor located?
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
One sec
I'll get you the names
Physics Collider
Physics Damping
Physics Mass
Physics Step
Physics Velocity
And I think that's it
Oh
@gritty grail
Oh there it is
π
Except messing with the Inertia Tensor seems to break my movement script
you tried putting zeros to it?
Yeah
well, worth a shot
you may find more solutions by searching https://forum.unity.com/threads/unity-physics-discussion.646486/
I'm sure it's been covered there at least once or twice in the past
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.
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?
So how is ecs going production ready on 2020.1 but we still don't have almost any editor tool avaliable for it
var data = em.GetComponentData<PhysicsMass>(entity);
data.InverseInertia = new float3(0);
em.SetComponentData(entity, data);```
Like this?
Ok cool, that worked great, thanks.
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?
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.
yes they are just a basic bit mask and work like unity layers
& 1 << n the bit you want
Okay
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
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
Hmm
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
are you by chance hitting yourself when you cast a ray?
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
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
And you use a raycast?
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;
}
And what are you passing to your PhysicsCollider?
nothing gets passed to it, that ref could be removed
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? : )
@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)
@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?
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
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.
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.
Hmm yeah, that's true. The only memory change would be the unfilled chunks of the existing archetype, and changed archetype.
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.
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?
Entity.Null
awesome thanks
fyi, it is just index = 0 and version = 0
I thought so
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
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
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?
...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.
Why I cannot have [DeallocateOnJobCompletion] on jobs NativeMultiHashMap?
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)
hello, where can i report bug for ecs?
Unity bug reporter is the best place
@twin raven no idea but they do have a Dispose that returns a JobHandle
@twin raven what is the error you are getting and the code context around where its being used?
@main oriole has "unable to write" error on end of upload
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
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?
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
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.
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)
@gritty grail If it works you can also move your job to after EndFramePhysicsSystem
Where do you call complete?
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 Answer is here: https://docs.unity3d.com/Packages/com.unity.jobs@0.1/manual/custom_job_types.html
@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 π€·
oh okay
that's how you do it
Well
uh
it slowed down my physics simulation by a lot
can't win can I π
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
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
Am I an idiot or is the Entities package just MIA?
you've enabled showing preview packages on the package manager?
Yes
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
i'm unsure what you mean
2019.2.61 is on this machine right now, but I can use whatever
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
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?
@gritty grail so it won't work for you to put your job after the physics simulation?
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
it can be salvaged!
I didn't even do anything to it and now it's just super slow
Somtimes it's easier to pinpoint the problem that way yes π
Do you profile it?`
got stack tracing on? burst disabled?
Profiling the player that is.