#archived-dots
1 messages Β· Page 247 of 1
I posted a similar question a while ago, from what I can gather your best bet at the moment is just forking up the money for some udemy tutorials. I'm not going into specifics since I don't want to shill for any of them, but there's several decent ones and one really good one by an experienced person. DOTS might as well be another game engine, and it's going to take you a long time to learn on your own.
At least this is what I can gather from trying to do a simple DOTS prototype
no way, all info is for free out there, just look it up
I have looked it up for the past weeks. Everything is out there for free, but having a human literally go over every DOTS system with examples and then a final project that has all of that is imo a good investment, trading money for time.
If that's not the case for others that's certainly fine too.
There's a youtuber called TurboMakesGames who covers a lot of stuff and keeps up to date.. It is more piecemeal though not so much an overview of the DOTS landscape. I think though once you can get a handle on the basic concepts, by picking things up and trying things out, you then just kinda run with it and figure out the rest as you go
Thanks, I'll check him out
is it possible to have burst unroll the loop?
also
Unity.Burst.CompilerServices.Loop.ExpectVectorized();
this seems to have been removed?
did you put this in: UNITY_BURST_EXPERIMENTAL_LOOP_INTRINSICS?
what does it mean when you use the in keyword for Entities.ForEach?
I was thinking of making custom input Action Map for each different character in my game, so if I have some type of IComponentData struct to identify each character, could I use the in keyword to iterate over those entities and retrieve the character's name?
in means readonly
ah okay, that's fine. So if I want to query something with two components (InputComponent, and maybe in CharacterIdComponent) then I should be able to achieve this?
I want to get the player's health and expose that in UI, is there a best practice? i.e event based?
personally i just have a system per UI panel
{
Label healthElement = this.healthLabel;
this.Entities
.WithAll<LocalPlayer>()
.ForEach((in Health health) =>
{
healthElement.text = health.Value.ToString();
})
.WithChangeFilter<Health>()
.WithoutBurst().Run();
}```
would be my entire code for this (well there would be other elements owned by this system but you get the idea)
//DATA TYPES
[Serializable]
public struct Pair
{
public TKey key;
public TValue value;
}
//VARIABLES
private BlobArray<Pair> pairs; //pairs
private int cap; //capacity
private NativeList<Pair<TKey, TValue>> pairCache; //ERROR HERE
why does pairCache's definition give me an error CS0122: 'Pair<Key, Value>' is inaccessible due to its protection level error?
Iβm trying to make a deserializable and blobbable hashmap, if thatβs important.
no idea based on the code you're showing here, except the fact that a nativelist should probably never exist next to a blobarray so that's like a giant warning sign right there
but just a note, someone made a blobhashmap https://github.com/bartofzo/BlobHashMaps quite a while ago
though please note, entities 0.17 added a somewhat broken safety check for blobs which breaks this so it needs a fix up
https://www.youtube.com/channel/UCWERX3S8tEGqNeLuQGCcJmw
I also found this gem, really nice stuff
Welcome to GameAcademy.school. Here we cover all things about Game Development, focusing on Unity and C#.
Check out the official Web site:
http://gameacademy.school
Many of the videos on this channels are snippets or supplements for our premium courses on Udemy. These links have discount codes included:
https://gameacademy.school/portfolio/
all videos are free on yt
Do you guys know any good practice to sort trigger/collision events?
Basically figuring out how to run code in 4 (or more) different scenarios efficiently
rn I feel like I'm doing way too much branching, don't reuse any code and it feels bad
i'd advise only having a single trigger/collision job in the project
that just groups, sorts, filters, etc the events and then messages them off to the relevant entities / systems however you prefer
kind of like what stateful events conversion system does?
putting them all in buffer
yeah but it doesn't need to be that complex depending on your use case
buffer is one approach, could use events as another etc
really just depends on your requirements
I think I'll just rewrite stateful conversion later
so I can have groupped stateful events
if you don't want to plan some complex architecture and you don't care about adding state (don't need to roll back etc)
then yeah those state events would be quick to add to your own project
any idea on this btw?
it broke after I created trigger event job
that works with bullets
your prefab
do you have the Prefab component on it?
or are systems executing on it
public static void ReloadPrefabs()
{
DisposePrefabs();
blobAssetStore = new BlobAssetStore();
var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAssetStore);
RifleProjectile = GameObjectConversionUtility.ConvertGameObjectHierarchy(GameObjectProjectilePrefabs.RifleProjectile, settings);
}
public static void DisposePrefabs()
{
blobAssetStore?.Dispose();
}
pretty sure it has
im not seeing where you're adding a prefab component?
all you're doing is creating it into the world
it's literally just a bullet that exits somewhere randomly
if you can see it in entity inspector without a custom filter then it's not a prefab
it's just a regular entity
do a World.DefaultGameObjectInjectionWorld.EntityManager.AddComponent<Prefab>(RifleProjectile);
after you convert it
(I'm pretty sure your issue is you made it so when the projectile collides it gets destroyed and so you're 'prefab' is colliding with something in the world and being destroyed)
what the
World.DefaultGameObjectInjectionWorld.EntityManager.AddComponent<Prefab>(RifleProjectile);
I just added this lol
Does anyone know why "Authoring'? what is the semantics of this word?
Does we authorize anything indeed?
authoring
/ΛΙΛΞΈΙrΙͺΕ/
Learn to pronounce
nounComputing
noun: authoring
the creation of programs and databases for computer applications such as computer-assisted learning or multimedia products.
Authoring is for components that add component during conversion
You're creating your entity
we authorize that this entity is indeed belongs to this archetype kek
i know what it does, i don't know why it called this way
Nice little snippet! I never really use WithChangeFilter and it's quite cool to see it in this context.
WithChangeFilter ?
What does it do
If the data in the component doesn't change, it doesn't get included in the loop/query
So if you have 1000 health components in your game, but only 10 of them actually change values, it'll only iterate the changed ones
I don't really get it
you mean
if component was never a subject of being written?
uugh, bad wording xD
yeah i suppose that's exactly it yeah
huh, cool one
I guess it checks by [ReadOnly] thingy
doesn't actually check if component was changed or not
just checking if it was reffed
so if say the healthComponent.myHealth value is not updated, then that entity/component won't be included in that loop
yeah i'm not sure the mechanism under the hood.. i think actually there's a 'version' value associated with each component, and when that component is written to ( updated ) the version number changes, indicating it's changed in this frame
kinda like a dirty flag basically
how du mean?
I mean to avoid storing managed type on entity
which will contain reference to Label for example
instead have some sort of sync system with indexes maybe
hopefully without dictionary
but I guess managed type is fine too
ah right i just reread Tertles example i see what you mean.. yeah he just references one label but appears to be looping through Health components and only applying to that one label object.. i think his example must be simplified for easiness
but yeah i'd probably use a dict or native array or something, some quite normal and typical c#/managed way of doing that.. i'd probably use the entity itself as a reference as opposed to index
Is entity animation is a thing rn?
tbh, i think it is possible to use references to managed stuff inside components when needed, i do it for a pathfinding component where the pathfinding isn't dots.. it's obviously not ideal to do that but i think it should only really slow down the systems/jobs that specifically use that component, and not affect all other systems that maybe use the same entities but different components
uhh.. keyframe animation etc i'm not really sure.. i use the Animation package to do skinned animation with anim clips, but in terms of just ordinary animation i'm not sure but i assume it's perfectly possible
ngl, I know nothing about animations as of now
even classic animations
should I learn GO animations first or?
mmm i wouldn't want to advise on that heheh
i would say, animating entities i think should be entirely possible with the dots anim package as it is, and i think it should be possible to look into it and figure it out.. there's probs some examples online of people doing it
welp
it seems like animation package is broken
it's dependency uses some obsolete code
I commented it out
and now I have 9 more errors to solve
kek
well, skinned mesh prefabs aren't very friendly with conversion kek
yeah skinned is a liitle more complicated, there's examples of how it can be done inside the unity animation samples project
which versions of stuff are you using
what editor version and did you have Entities packages already installed?
I installed everything by dependency
basically
added Hybrid Renderer
everything else installed itself
seems to work best
editor version?
2021.2.8f1
i think some dots stuff is broken in 2021, i would like to move to it myself but don't think it's safe tbh
i'm using 2020.3.8 which seems to work fine
well, so far only animations and collections (there's fix tho) are broken
ah ok
what animations version are you using?
yeah that's probs just due to the Editor version
eh
I feel like
I should just
remove mesh renderer
and do my own hybrid renderer
kek
maybe download the animation samples and try run them in 2021
if they work, then there's hope, otherwise, not sure
I don't use HDRP but there's examples of skinned animation in the HDRP samples
There's also a store asset called Rival that does it, it's a dots character controller, but it does require Unity 2020.3
oof
Tbh, kinda hoping the dots update that should be coming over the next 2/3 months will get everything back on track and have an Animation packages update π€·ββοΈ
yep
so far I only want to just use GO
for rendering
and everything else for logic
i think that's common unless you're rendering a really high number of objects
yeah I don't have anything in high quantities
I just want to do that in dots
because
that's basically what I'd do in normal OOP
have a system that loops through arrays of objects kek
i really wanted to get past the performance bottlenecks with GO's and Animator and skinned mesh renderer so i pursued using the anim package with hybrid renderer
yeah i think it's reasonable to take the benefits of traditional unity authoring with skinned characters and all the rest of it, and pull in some of the benefits of dots for computational stuff
haha yeah, you quite possibly avoided a pitfall
When using samples from github, always install and use the same editor version
will prevent such trouble π
tbh i mean there's still ways, people use shader based animation systems which can be overlayed on top of dots character controllers etc, there are ways, but if you don't need to be rendering hundreds/thousands of characters it's probs not worth the hassle
I won't downgrade to 2020, since UI toolkit in it is half broken
and I kind of want to do everything using latest tech only
kek
Use Unity Hub to download multiple editor versions
I had about 8 versions couple weeks ago xD
anyway
any idea about hybrid rendering through GO?
do I just keep my GO
and assign it's transform/rotation to entity's one?
i barely use hybrid GO's tbh where i do they're static
maybe someone else can help with that, i think there's an automatic way, a companion tag or something that does it
doubt, I remember someone mentioned
that "Convert entity and keep GO" is obsolete
hmm, maybe create my own authoring component that would spawn new game object in place of entity
Man, that sounds funny
you convert game object to entity to convert it back to GO
π
So, what are my options in doing this thing? I'm guessing putting those objects (that will keep render mesh as GO) into subscene is straight wrong approach
what I want here, is to have normal GO in editor, with standard authoring components, but:
During conversion ignore all children, don't destroy game object, Destroy all authoring components
is Convert And Inject Game Object deprecated?
all right, so far it works with this component and I'm happy about it
hm, I wonder why there's no way to use paralleled jobs with managed types
anyway
How spawning game objects with "Convert to Entity" script works? Will they get converted during runtime?
Like, not in editor, but spawning during runtime
hmm, looks like they will
at least, dragging prefab into hierarchy worked as expected
Is it possible for entity references to be remapped when they are not moved?
For example, say I have entity A and entity B.
A has a field public Entity referenceToB, which references B.
Now B is moved to another world, and that world is serialized. Then B is moved back to the world that A is in. However, the entity reference is now incorrect, pointing at B's previous index and version.
Is there a way around this?
you mean two entities belong to different worlds simultiniously?
or you simply worry about reloading entities from save?
Well, if I want to save the game, I need to move the things I want to save to another world.
I don't want to save everything. But some things that don't need to be saved, reference things that do need to be saved. These entity references are not remapped.
maybe instead of saving reference, save some unique to entity data?
That would mean I need separate runtime and save data
which will retrieve entity in loading pass
Ideally I can just serialize the entire world. Something that would probably be easier is to just move everything to the save file, and remove stuff that shouldn't be in the savefile when loading, but ideally everything is remapped.
Something that would be even easier, but I don't know if this is supported, is instead of moveing entities, simply copy everything. Then I can just throw away the save world after saving instead of moving everything back.
I guess maybe EntityManager.CopyEntitiesFrom would achieve this
Hey guys. I'm using the conversion workflow to convert a simple animated sprite that is in a subscene to entity
But I can't seem to find where to get the correct SpriteRenderer component that it's generated for the entity to flip it.
there isn't a direct SpriteRenderer conversion afaik?
dots hybrid rendering is primarily for 3D space, so not sure if you're using that or rolling something custom
oh and if you're using project tiny, tiny is shelved for the time being
I see, I saw this in the converted list and assumed there was a conversion thing happening in the hybrid rendering.
But yeah, a bunch of it is missing, like the animation for example(and was going to use something custom for it)
No, normal unity
I'll go with something custom then, thanks!
yea that's listing the regular MonoBehaviour component - but np
I thought that only showed the ones that were converted, i see
Just popped up he's doing a game dev chat with the Terraria dev shortly, might be worth a wee listen
https://www.youtube.com/watch?v=iYCp7r6mCWY
Submit Your Question - https://forms.gle/fdf9A3poLtDP5fDb7
The New Years Sale - https://assetstore.unity.com/?aid=1011lkXUB
Game Architecture Course - https://bit.ly/3xN28Q0
InfinityPBR Sale - https://assetstore.unity.com/publishers/4645?aid=1011lkXUB
Jason Storey - https://ko-fi.com/jasonstorey
Andrew & InfinityPBR - https://bit.ly/3a...
as far as I understand currently unity physics doesn't support skinned mesh colliders?
theres no helpers for setting up ragdolls if thats what you mean
hm, do windows builds compiled on a mac support burst compile?
you can see cross compile support here
macos host only seems to support macos, ios, android, magic leap
it says: "**Desktop platforms with cross compilation enabled (the default behaviour) **Burst compilation for desktop platforms (macOS, Linux, Windows) no longer requires external toolchain support when building a Standalone Player (since Burst 1.3.0-preview.1). This should work out of the box, but can be disabled in Burst AOT Settings if needed."
- not sure what this means, is burst already support Cross-plattform on Desktop or not? and where is a setting cross compilation?
True, maybe the table isn't updated
at first i was shocked, when i read: "Burst does not support cross-compilation between Windows, Mac, or Linux." but that's from the docs of an older version.
So can anyone confirm, if it works or not?
just make a build and see if it generates the lib_burst_generated.dll?
if it exist in your AppName_Data\Plugins\x86_64\ folder
then burst has run
Ok, thank you it's there. Then it's still great
I wonder how to check tho if burst is running
throw exception and then check log?
if it's burst, then it should give limited exception error
do you know how to use the profile in editor?
barely
hm, for my project (more for learning/fun) it's so much slower without burst, you will notice, like 2 minutes instead of 1-2 seconds.
yeah, certain algorithms will go from 4fps to 100
it's the time you first see a landscape after starting, mostly the noise generation makes the biggest difference. and when running around it does not re-generate in 1 frame, but takes quite some time
but other than performance, you should be able to see in profiler, if it says something like: "SomethingBlabla (Burst)" then it's fine
oh noise
yeah i have an algorithm that takes 1 second to run with burst
but 3minutes (180 seconds) without burst
this is actually a problem as it makes turning burst off impossible in the project which makes debugging a pain
i have to make it run a basic noise function when burst is off
because of this i made a request with burst devs to add a "Always Compile" option to certain burst functions
i remember reading someone say something about a different approach to debugging when running a built project
but i have no idea what that was
some hack to do with attaching the vs debugger or something
burst supports native debugging
but i'm wondering if that kind of debugging even plays nicely with burst etc
just attach as a native not a managed debugger
i often have both rider + VS open
attach rider for managed debugginng
attach VS for native debugging (burst)
hmm i'm going to have to use my brain here i think
you can do this in the editor as well
yeah i'm having some errors on the built project which are fine in editor
hm, sounds interesting. it has been quite a while, since i wrote the scripts, but it seems that the built-in stuff was enough (leak detection and safety checks on)
this look about right @rotund token ?
thats only for managed debugging
you cant debug burst with a managed debugger
(but it will let you attach a debugger to systems etc)
basically i'm getting an error in a system OnCreate, so ideally if i can just get where exactly the error is
just trying that now
Just AttachToProcess in VS when the game prompts to attach managed debugger?
yeah you should be prompted to attach a debugger when you start your app
damn, just keep getting that access violation
vs seems to be trying to connect natively also
it's just being a silly silly bum bum
nm, will figure this out later
Are there any updated tutorials for getting started with ECS?
or is it basically just the ECS sample project
there's a a youtube channel called https://www.youtube.com/c/TurboMakesGames all about ECS.
and there's also https://www.youtube.com/channel/UCWERX3S8tEGqNeLuQGCcJmw.
Turbo Makes Games is all about helping you make games quickly and effectively.
Game development is tough and it can take a long time to make a great game. But it doesn't have to be that way. Throughout development from pre-production planning to post-launch support there are many ways optimize your processes. Implementing these changes in your ...
Thank you! I watched a few of TurboMakesGames videos, just never checked his channel and didn't realize how much work he has done with ECS. I'm gonna have to binge watch his channel now!
https://www.youtube.com/channel/UCWERX3S8tEGqNeLuQGCcJmw
Here another hidden channel
Welcome to GameAcademy.school. Here we cover all things about Game Development, focusing on Unity and C#.
Check out the official Web site:
http://gameacademy.school
Many of the videos on this channels are snippets or supplements for our premium courses on Udemy. These links have discount codes included:
https://gameacademy.school/portfolio/
my dumb brain decided to upgrade to unity 2022.1.0b5
from what i can tell they removed unity.rendering.hybridv2
downgrading also breaks my project further
what should i do, hybridrenderer has a line requiring hybridv2 namespace?
2022.1 just does not work with dots packages
should i try 2020LTS
was on 2021.2.9f1
now try downgrading it crashes
should i put this in #archived-code-general ?
ok i resolved the problem
13.1 is for 2022
back to the issue that prompted me to upgrade
any thoughts?
you need to create local copy of collections package and change line 599 in NativeList.cs to Allocator.Invalid
how? why? wut? (im genuinely intrigued)
is it fixed in collections 0.17 but since we cant used that version we have to do the following?
so i was the one to report the fix
yes
2021.8 and 2020.3.26 released a fix for deferred jobs
this fix
Kernel: Fixed an issue where low bit set in NativeArray buffer pointer assumes NativeArray is created by NativeList.AsDeferredJobArray, which is not always the case. In some cases NativeArray can be created by NativeArray.GetSubArray, where pointer would have lowest bit set for odd byte aligned offset.
huh
anyway the fix made it so deferred allocation only works on Invalid (i think)
apart from that I can't say much more
change it to invalid?
i wrote instructions here
did you restart unity?
unity won't detect adding new packages to the Packages folder until you restart unity
also unity hub?
that shouldn't matter
just restarted, same
will shut down unity hub and see
im on 9f1. should i downgrade
i haven't tried 9f1
i don't expect it would be any different unless they 'fixed' it again
same, now downgrading to 8f1
hoping it works
did you copy package to local?
yep i triple made sure
it should appear as local in package manager
you can try on 7f1
this is where fix shouldn't even exist
so remove local package for a while to check
convexcollider.create is using something that causes the issue
thats all i can gather
yep, convex collider is the only collider.create that causes the issue on my end (after applying the patch)
xd xd xd
use classic unity
oh
dived straight into ecs hell
damn
I think that's a big jump from something stable to something extremely technical and early access lmao
hard training - easy combat
true
mfw code not workπ
it worked π
it started working
unity momento
thx for the support both u and tertle
oh boi
using root motion with dots physics
I'm in hell
oh boi, looks like it'll require feedback from animator
rip parallelism
just roll your own animation tool in dots
I barely know how animations work
so far I just have linked GO with animator and pass variables to it
animations is just reading a bunch of coordinates and then tweening the points towards those coordinates
yeah, it's not like I'm able to work with it in low level as of now
can i do that and dispose on destroy/after schedule? IEnumerator Start() { public NativeArray<RaycastHit> results = new NativeArray<RaycastHit>(1, Allocator.Persistent);
you can use .DisposeAfterFinish(results)
dud, I just came up with some pog animation concept for ragdoll:
instead of moving transforms, apply force to animation points
so animation is driven by force
and whenever other force outside of animation applies to any collider
animation will go through with it
have a rigid skeleton that is the desired location for each bones, and apply force on each bone toward that direction.
nah, just have ragdoll
with all joints and etc
and simply apply force to body part's colliders
let's say head supposed to be in pont x y z, and currently is x1,y1,z1
then you just apply force of
x-x1, y-y1, z-z1
multiplied by some value
question is
how to get all these points in runtime
assign them
oof
That would stay as concept kek
SADKEK
is it possible to have a proper parenting hierarchy in ecs?
currently there's just parent component
like multiple layers
that applies localtoWorld
one layer?
use that
but it's only for transform
should be adequate
creating ragdoll
takes...
about 500 lines of code
simply ragdoll
with cubes and spheres as colliders
and then you have to also add logic to keeping each of body part
attached to animation avatar
make a hierarchy of bones of supposed position out of the parenting system, then have free moving bones that you apply force to based on the supposed bones position
it's out of my depth
damn
hey I seem to not be understanding how jobs work. I have this code ```cs
m_MeshModJob = new MeshModJob()
{
vertices = m_Vertices,
normals = m_Normals,
sinTime = Mathf.Sin(Time.time),
cosTime = Mathf.Cos(Time.time),
strength = m_Strength / 5f // map .05-1 range to smaller real strength
};
m_JobHandle = m_MeshModJob.Schedule(m_Vertices.Length, 1);
using (marker.Auto())
{
Thread.Sleep(25);
}
m_JobHandle.Complete();
// copy our results to managed arrays so we can assign them
m_MeshModJob.vertices.CopyTo(m_ModifiedVertices);
m_MeshModJob.normals.CopyTo(m_ModifiedNormals);
m_Mesh.vertices = m_ModifiedVertices;
m_Mesh.normals = m_ModifiedNormals;```
this result in the workers being idle during the sleep(simulating other work being done) and only doing work when Complete is called
why is this ?
I've never seen that thread sleep before. You also need to use ScheduleParallel. You are just using single right now. It does it in order even if it can do it parallel
You should call https://docs.unity3d.com/ScriptReference/Unity.Jobs.JobHandle.ScheduleBatchedJobs.html after your schedule call
And you need to put the [BurstCompile] attribute on your job
the job is already a IJobParallelFor. Isnt that Schedule doing the same ?
It means you are setting the job up to be a parallel type of a job which has the function void Execute(int index) but you can still call it in a row if you'd like. Although looking at it now it is scheduling parallely so maybe I am wrong. I always use ScheduleParallel though so you can dictate the inside loop.
Also you should definitely remove the thread sleeping thing. It's just adding 25ms of a pause while the computer does nothing. You can see that in the timeline
m_JobHandle.Complete(); instantly makes sure that job is done
I don't think you need to simulate the work being done. It'll just happen when it happens. I've never call Schedule Batched Jobs and unity is still scheduling stuff for me.
That's because Unity does call it themselves throughout the PlayerLoop
If you want to see your job executed right away like in the example that @mild ledge posted you have to tell the job system to execute your jobs
Hmmm. But isn't that what m_JobHandle.Complete(); is for. That always completes the job right away.
Or are you talking about scheduling the jobs at that moment?
I'm talking about scheduling the jobs at that moment
But if you schedule jobs at that moment they still won't be done for you to look at
No but they start being executed on a worker thread
Ah okay good to know.
Unity's ECS calls ScheduleBatchedJobs after each system update call for example
ah very good to know. I am using DOTS stuff outside of ECS primarily now so I am just checking on IsComplete always
what are you asking @mild ledge. Like what is the issue? Are the threads not spread out out enough
yep ScheduleBatchedJobs had the expected behavior. The actual job work was being done during the sleep
or are you confused why there is such a huge delay?
The issue was the job system starting to do the work only when we call Complete
even when schedule was called before "a other heavy workload"
like Script explained and then I was in the docs, the job system has its own mind as to when to actually do the work, if you dont tell it manually
you mean it wasn't called during update cycle at all?
ah yeah makes sense
Do you have burst enabled by the way? When you see that little .invoke below the job on the thread that means it isn't bursted
Enabling Burst did not change the behavior on its own
yes I mean calling Schedule alone did no work during Update at all
if we called Complete in LateUpdate it did all the work there
can you show whole system?
and if we called Complete in Update it simply did it at the end
yeah complete will stop everything and do the jobs then and there
so calling schedule batch thing that Script said got it working?
in my mind calling Schedule should at some point in time begin the work the job is supposed to do
Complete makes sure the job is done so you can access the data
here is the whole code https://pastebin.com/yBdzizFi its just a example script from a jobs cookbook
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Complete does make sure the job is done
"Second, and the issue most often missed by developers learning the jobs system, is that calling Schedule on a job does not immediately queue it for execution. So, if we schedule a bunch of jobs in Update, then complete them in LateUpdate, they may not actually begin executing until we call Complete in LateUpdate, and the main thread will still be forced to wait for the worker threads to execute the job." This Quote is exactly the problem
They don't make it clear that complete shouldn't really be used unless you must have the data
so in a non ecs project when does unity call ScheduleBatchedJobs ?
handler.IsCompleted is to figure out if the handler is done
I have a non ECS project and each frame I check handler.IsCompleted
I bet Unity's underlying job systems are calling ScheduleBatchedJobs
or rather when it began
my expectations was that work will start when I call Schedule
that expectation was false
all is well now π
it makes total sense to deploy jobs in batches
and then they realized calling scheduling was expensive all the time so they changed it to need a specific call to get it going
I seem to recall thinking the same thing when I started, so I get you
DOTS and ECS are super performant but that comes at the cost of being super confusing with lots of little things to watch for.
I'm not doing ecs
oh even DOTS
it's nowhere near production ready
I am just saying in general
job system seems stable enough to base some things in a game on it
me and my colegue both have parallel experience. Problem is this https://docs.unity3d.com/ScriptReference/Unity.Jobs.IJobExtensions.Schedule.html doesnt say at all that " Hey you call Schedule but the actuall work will begin when we feel like it"
so from our point of view this wasnt parallel at all
at least in our simple just test out the system case
pretend c# threading doesnt exist when learning unity jobs
Yeah good point. Maybe post a suggestion on the forum?
From reading all the docs I should pretend no ther threading exists π
exactly
Its okey. This and the new BRG api has got me very excited
Havent been this excited since the drop of unity 4.6 lmao
just a fair warning, ecs doesnt work on 2022, jobs should be fine tho
I really dont care about ecs
We have been structaring our code in a data driven way before ecs was a thing
neat
Yeah I never did any threading before the jobs system so I have no idea how that stuff works
they are very different π
I don't think there is enough general understanding with game developers (at least the ones I know about in real life) how awesome Burst and the Jobs system is
It's really magical
ECS is just adding onto that, but the core stuff is amazingly fast
ecs is both a curse and a blessing
tho the features really useful
i recommand a hybrid approach tho
can I ask what BlobAssets are ? Are they useful in just jobs or is it something to do with ecs only ?
Blob assets are just blobs of immutable data
How do I instantiate a gameobject in a SystemBase? I need to push an explosion particle effect and people say to make those game objects.
they're only in ECS
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'Instantiate' does not exist in the current context Assembly-CSharp C:\UnityProjectfiles\StarfighterGeneralOnSteam\Assets\Scripts\DOTS3\SystemDestroyNow.cs 149 Active
So using them just with Jobs is a no go ?
UnityEngine.GameObject.Instantiate may work...
in a systembase update you are in main thread, so using the entityManager.Instantiate() is fine but you should probably use an ECB.Instantiate() if you're producing a Michael Bay film like game
Next release will also have blob assets which is made for sharable immutable resource data. In that case, you could convert a ScriptableObject into a BlobAsset and then share it from multiple instances in the same scene.
BlobAssets are made for zero cost deserialization for large amounts of data. AnimationClip, CollisionMesh, CurveData is a good example of what we think belongs into a BlobAsset.
yup.
cool cool moving on then
Mr.K, doh, never thought of entitymanager.instantiate
I thought that was just for entities.
I'm a moran π
And the worst part is... It was working, on editor, but not standalone, and I just needed my withoutburst ^^
A michael bay film like game?? π
When my parallel processing collision job registers death hits, sometimes many things hit it same frame and it registers many deaths. Is there a way to avoid this in the job, or should I give them damage tags to process later?
what's wrong with many hits at the same time, is that not the point in the parallel job?
@remote crater @karmic basin uh you cant use the EntityManager to instantiate gameobjects
weird way of asking how to instantiate an entity then π
Isn't nested Entities.ForEach a thing yet?
It could really help me though. Do you know any alternatives?
use componentdatafromentity
what's your use case?
can also get a nativearray of entities from a query you want to work with and then you can loop those inside of foreach
also nested foreach will def not be implemented cause that would be O(n^2) complexity
which already defeats the point of ecs
Well, I'm trying to update stocks in a market entity depending on what that market's workers produced.
I agree with you Mindstyler. Nested foreaches are lazy solutions. Yet, for a OOPer like me, it can help 'till I learn the ECS.
you could just push out all the changes into a native array or similar and then write all the changes of the native array back to the corresponding entities in another job
Problem is, I need more "dynamic" native arrays. There are many markets, and a bunch of workers for each market. Somehow I need to link those workers and their markets, and calculate what they produced (depending on the raw material availabilities) then update the market's stocks. My aim is completely jobifiying this process on parallel.
Nested foreach and a single if statement can make this "linking" very easy in OOP side.
I guess I need to think harder on this problem.
The best mindset to transition to ECS is to think in SQL databse.
Why not have a Dynamic Buffer hold all the Market Entity the Worker Entity knows?
That is also something I was considering. Creating dedicated entities just for calculation purposes.
But I liked how you put it in SQL terms.
you can also use native stream for parallel write only operations for 'dynamic' output
My approach to this would be, and i think a typical ECS approach something like this:
You treat markets as a bunch of Entities, and loop through those all together, and do market only logic.
You treat workers as a bunch of Entities, and loop through those all together, and do worker only logic.
If you have say a worker who makes swords, you give him say a 'blacksmith' component, and when you loop blacksmith workers, you have some logic which runs for him, say for example he makes a new sword every 10 mins.. The worker could have a generic 'worker' component, which holds a reference to the 'market' entity he works at..
Next if he does produce a sword, you could have a singleton buffer which acts as a middleman between workers and markets - so in the blacksmith loop you append a sword to that buffer, with a note of the market entity it's going to..
Then when you loop over the markets, you check that buffer and if there's an item in it for that market, you then update the markets 'stock' component or whatever with the new sword..
So it's a different thing from classic OOP, you're not looping through markets, and inside that looping through workers, calling worker class methods inside the loop etc.. That approach is easy and good, but it's loaded with calls to reference types and accessing different chunks of memory all over the place.. So the whole ECS thing is to serialize everything of same type, minimize reaching out to different memory locations, and use go-betweens to pass data from one system/loop to another.
I did something similar. Both workers and markets are different entities.
Markets have an ID component, two buffers to hold prices and stock levels.
Workers also have an ID and their output type components, similar to determine if they are blacksmiths or what.
Main challenge was to determine if a worker can really produce at that time. As the production was depended on raw material availability.
I'll try iterating thorough workers and determine their raw outputs first. Then I can iterate again and see if they can actually produce.
Maybe this way it works, as I can group same datatypes together in a more ECS-like manner instead of referencing around as it is OOP.
Yeah that sounds like a good start. I mean you could for example chain the actions so if the worker needs raw materials, he adds a request to a buffer, which the market then picks up on and releases materials to another buffer, which the worker picks up on his next loop, then is able to produce a sword or whatever
So a basic implementation of that - each step will take 1 frame - the worker sends a request for raw materials, then the next frame the market reads the request and sends materials to a buffer, then the next frame the worker gets the materials.. But it is possible to set something like that up to happen within a single frame using ECBs/syncpoints and some careful architecture of systems, i doubt that'd be really needed here though
Just popped into my head to also mention - you might find that unless you have like 10k markets and workers, it's actually faster to run single-threaded for something like that, as with small numbers of iterations the overhead of setting up and managing parallel jobs could outweigh the gains.. it'd still be a million times faster with just bursted Schedule compared to the OOP way
Syncpoints could be useful when dealing with different phases: such as gathering material requests, deciding output and updating stock as final.
I agree with jobs vs single-threaded thing. ECS itself is a major upgrade in terms of performance and just like multi-threading overheads and preparation can outweight the gains. Currently I'm kinda benchmarking ECS vs OOP so market numbers are on 100ks π
besides multithreading, there's also burst and better cache hit ratio
Are there any tools to manage systems?
Like disable certain groups of them and etc?
and not with just enabled property
for different game states
You can use a State component for each of your game states, and RequireForUpdate
Be interesting to see the results of benchmarks!
Can you memberwiseclown an IComponentData?
Clone
Not clown
I take the role of clown
and I want no one copying me
I just want to pass by value and not by reference a copy of IcomponentData
Like say it was public struct EntityData : IComponentData { int a=3, int b=5, int c=6} I want to make a copy of that so when I change a,b,c it doesn't change on both entities it is attached to.
For some reason it is 2022, and cloning a class is still like voodoo
I guess I'll just do it by hand in.. every function... for dozens of variables.
Instantiate is okay, until you're trying to access the methods before they get sent through commandbuffers or instantiation.
you can do
struct S {
public int Value;
}
S a = new S();
S b = a; // b is a copy of a
Does that work for classes too?
Oh snap
I thought icomponentdata was a class for a sec
Shweet, you opened my eyes
I saw the sign and it opened up my eyes
You the ace of blank
and i am happy now living without you
for deep copying a class the "generic" way in C# is stream the class into memory as a copy and then reference that copy
kind of annoying but doable
struct is a value type so when you assign it to another variable it gets copied and does not reference the original
class is a reference type so when you assign it basically you are still pointing to the original
I was having problems with bugged memberwiseclone yesterday on classes, and it turned out memberwiseclone on classes just dont work
I only want one level of memberwiseclone on my classes, and it doesn't do even that.
So what happens is when you have problems with stuff you normally rely on
You begin to doubt reality in other places.
I'm good to go.
Those who debug know what I'm talking about, when stuff starts to get unreliable in one part of the code, it snowballs
I was working on classes today, didn't notice Icomonentdata was struct, just wasn't looking. You guys rule.
this is interesting, could be a way to clone say the values of a component for example?
i've been experimenting with using system groups for this, something like
{
protected override void OnUpdate()
{
if (this.HasSingleton<TestComponent>())
{
base.OnUpdate();
}
}
}```
Mostly doing this as an extra optimization step but the concept can apply to whatever you want
say if you wanted to transfer a joint hierarchy ( all the values of the Joint components ) from one hierarchy to another for example
I've been using AggressiveInlining attribute on static methods called from inside ForEach jobs, can anybody see any potential issues with this?
ooooh, so this is how fixed step works?
basically if SystemGroup on update is not calling base, no system will run?
im not sure I follow?
kind of, all system groups have a FixedRateManager built in
null by default which then does nothing
but you can set it to choose update rates etc
so
to make systems run
I just call base.OnUpdate()?
and to make them not run I don't call base?
thats how it works
Ah it's kindof a long shot i guess.. but say you have some components ( ie gameObject mono components ) on Object A, and you want to clone those components ( and all values ) to Object B, i don't think that's really possible in any non-hacky way unless i've been missing something.. ie you can do ObjectB.AddComponent(ObjectA.GetComponent<ComponentName>()) but it doesn't clone the values over.
do you guys order your systems explicitly or just let them get placed wherever? ive been doing the latter without issue but kinda wondering if im missing out on something important here(though not using netcode or doing any kind of determinism/rollback)
oh, yeah that doesn't clone it. The way I was suggesting I've only ever done it in plain old C#, without any interop to native memory. It pretty much used BinaryFormatter (which honestly shouldn't even be used anymore considering it's a vulnerability and .NET will remove it in the coming year).
I think the hard part with your example is how to clone w/e is in native memory from C#. Pretty sure it's possible but no idea from the top of my head
Yeah closest thing i may or may not have attempted is using reflection to iterate all the fields ( i think there's some way to iterate by field ID or index or something ) but not sure i had much luck there. Was just a thought tbh, when i saw you mention that.
o, didn't think about using reflection before π
Yeah i have a bunch of groups, each group inserted specifically with it's own ECB:
Then inside individual systems i attach to the group and grab a reference to the group ECB kinda like this:
only order if you need to imo. system groups are nice for organizing systems and also ensuring groups of system orders
alright guess ive been on the right track
or well not doing anything boneheaded there at least
Sounds a bit, deviant tbf
on that note just "fixed" my ragdoll body setup after breaking it and leaving it broken for some time. next update cant come soon enough
ah nice to hear
what are you hoping for in the update?
god not to do the ragdoll setup myself. throw away my own code and just use unity's solution for active ragdolls, also like an actual ui for animation because quite frankly its just terrible coding this shit. i had to make a visual diagram of my graph setup because its just cognitively too much for me to remember what is going on. its only 7 nodes + the entity node but ugh
yeah definitely, really hoping for some kind of animation updates above all.. i have a feeling they're going to focus more on the whole authoring workflow and hybrid bridging stuff but damn, i hope there's some fleshing out in other areas
yeah that's why I'm avoiding using any of the animation stuff, I'm just going to make do with some mesh swapping stop motion type animation
seems like animation/skinned-mesh stuff/etc are equally the most complex and potentially end-game for ECS in unity but also the most obvious and clearly lacking
i dont think they have to be though, we have the groundwork in place, ecs/jobs/burst work well, we have the rudiments of physics/animation/networking, we just need more fleshed out versions of them
navigation π©
as in pathfinding?
unity's navmesh system with jobs integration was lacking π
I can really recommend the latest experimental version of the A* Pathfinding Project
Still in the progress of integrating it but the burst powered local avoidance simulator works really well and was pretty simple to add
The same path that took 2 seconds to calculate with Unity's low level API takes 3ms using the A* Project π¬
I do have it, does it actually have a pure integration with ecs or just like regular api gives some sort of way to use it?
@devout prairie misread what you said but lack of official preview versions of navigation and audio vexes me
It doesn't have an ECS integration but some parts use Jobs/Burst
But since all the agent code ships with the package it wasn't difficult to port over
tangential to dots but one thing that kinda bugged me about a* pathfinding project(app? name is so generic!) was that entering playmode adds a small delay, dont suppose you ever noticed that?
I had to enable scene reloading when entering playmode but I don't notice a difference π€·ββοΈ
hmm, what are my options if I need collision/trigger events in 2d?
I wonder if it's even worth to implement physics package for it
Is there a way to get archetype from entity?
basically I have this:
if my entity goes beyond screen I want it destroyed
and spawn other entity of same archetype
From a job, sure
From a system or EM not sure if there are helpers for that
Yo u can retrieve a list of all archetypes in the World from the EM, but then how to compare/match each one with your current entity, i'm not sure π€·ββοΈ
From job it's easy because all entites iterated share the same chunk, which stores it's archetype
huh
Job exposes ArchetypeChunk. Which has an Archetype property
Other way could maybe storing the archetype on a component ? Especially if you instantiate from an Archetype in the first place. But I guess not otherwise your problem would already be solved ^^
Ooooor get the Chunk from Entity Manager
Then you can grab the Archetype
Didnt see it at first, sorry :)
You wont be able to parrallel anymore though. So probably better going with a Job
eh, I'll look for other solutions
maybe keep info about archetype or prefab as component
An approach i take to spawning units is basically i have a buffer which holds my prefabs shrugs
so i just grab the prefab of type i need to spawn
Basically this:
Hi again guys. Back with a probably stupid question. I have this job ```cs
[BurstCompile]
public struct MoveForwardJob : IJobFor
{
public NativeArray<float3> Positions;
[ReadOnly]
public NativeArray<float3> ForwardVecs;
[ReadOnly]
public float DeltaTime;
[ReadOnly]
public float Speed;
public void Execute(int i)
{
Positions[i] += ForwardVecs[i] * DeltaTime * Speed;
}
}
Remark: unknown:0:0: loop not vectorized: instruction return type cannot be vectorized
What am I doing wrong ?
does it work without burst?
that's strange, you don't have the assert and it throws the assert remark?
Anybody implemented pause within the context of dots?
Just wondering if i should have a RequireForUpdate to temporarily toggle systems/group updates, and how to approach pausing unity.physics
I simply used timeScale
and disabled my input controller
it disabled fixed step group which where most of my systems are
if I turn on Safety Checks the remark turns into
Remark: unknown:0:0: loop not vectorized: loop control flow is not understood by vectorizer
for sim type of games you can implement some static boolean and check it in your group
Think you have to put a disable attribute on the native array you are writing to. Can remember the exact name of the attribute. Native DisableParallel or something.
What's the right way to hide an entity that is attached to an armature? ie. I've got an armature created in blender that is imported into unity. I have 2 sets of armour, (red_armour and blue_armour) - Right now, I'm doing a search for "red_armour"'s entity then attaching a "Disabled" tag onto it or destroying it. However the issue with this is that after 30 seconds of so, these entities reappear in the game brokenly - I tracked it down to a copy of the red_armour entity that is attached to the armature that has a "DeformedEntity" component with an invalid value, which is causing the problems.
"DeformedEntity" is internal only (from the unity hybrid package) so I can't just do a search and filter out these entities. Any ideas on how I would approach this?
why not just have 1 set of entities and change their color instead?
if that's the only difference
That's just an example for simplicity, they're are very different meshes practically
Unless they are different archetype, you can still simply switch data
what is even a point of having entity hidden?
Unless you implemented disable mechanic for each of relevant system
you can't really hide entity
i know noting about skinned meshes, but did you try with the DisableRendering component ?
Anybody here knows what happened to gamedevbrothers.com? It had some nice articles on DOTS but now it seems to be gone...
π€·ββοΈ last snapshot was december 2020 https://web.archive.org/web/20201205100136/https://gamedevbrothers.com/
their last twit was months earlier
Yeah just found it on wayback machine too. Weird that it just vanished
Best guess is they didnt renew their domain
because a little more than a year, but really I don't know
yeah thx. just thought that anybody here might know them
any input on how I can optimize this job ```cs
[BurstCompile]
public struct MoveForwardJob : IJobParallelFor
{
[NativeDisableParallelForRestriction]
public NativeArray<float4> Positions;
[ReadOnly]
[NativeDisableParallelForRestriction]
public NativeArray<float4> ForwardVecs;
[ReadOnly]
public float Speed;
public void Execute(int i)
{
Positions[i] += ForwardVecs[i] * Speed;
}
}``` Cranking the 'entity' number to 5,000,000 takes about 12ms per worker
I realize I might be hitting the actual cap of my CPU here π
ArgumentException: All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -4983).
what could cause the exception?
narrowed it down to the line 70-73
NativeArray<float3> voxelPositions = voxelChanges.GetKeyArray(Allocator.TempJob);
foreach (float3 voxelPosition in voxelPositions)
{
byte points = voxelChanges[voxelPosition];
if (correspondingTable.ContainsKey(voxelPosition))
{
Entity existing = correspondingTable[voxelPosition];
points |= EntityManager.GetComponentData<TerrainComponentData>(existing).points;
commandBuffer.AddComponent<Disabled>(existing);
toBeDestroyed.Add(existing);
}
Entity entity = commandBuffer.Instantiate(coversionTable[points]);
commandBuffer.SetComponent(entity, new Translation { Value = voxelPosition });
commandBuffer.RemoveComponent<Disabled>(entity);
correspondingTable[voxelPosition] = entity;
}
Dependency = voxelPositions.Dispose(Dependency);
Dependency = voxelChanges.Dispose(Dependency);
m_commandSystem.AddJobHandleForProducer(Dependency);
I don't understand
you try to write to the commandbuffer while it's doing its playback
at least that's what the error says
all reference to the command buffer is plain code without jobs
I don't get it
π
You cannot directly store entities created through the command buffer outside of ECS components or dynamic buffers
Components and buffers patch the entity indices on playback which doesn't happen when you store them in a hashmap for example
well thank you Script. My answer didnt help because you already managed your dependencies π
bruh
what is this component
and how do I get rid of it
for some reason
it also creates clone of my player game object
that is hidden somewhere
man, lack of control over go conversion really ruins hybrid approach
it's a reference to the gameobject you converted from
this still holds the reguler Object Components Unity didnt convert to ICD
ALso there's a system that applies back the Entity transform to its Gameobject counterpart.
So you could imagine for example having a particleSystem following your entity
And I'm sure I miss a lot of details
Manual will explain better than I could xD -> https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/hybrid_component.html
I followed the guide for accessing to buffer data here: https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_lookup_data.html#looking-up-entity-data-in-a-system
However it throws: InvalidOperationException: OnUpdate_LambdaJob1.JobData.buffersOfAllEntities is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
Any ideas for accesing buffer data in Entities.ForEach.ScheduleParallel()?
Did you forget to send true as a param when calling GetBufferFromEntity maybe ?
anyone using the Havok Physics package ? the latest "Quick Start" guide mentions to get the package in the Package Manager with "All Packages" turned on. except, that dropdown option does not exist any more it seems ( using 2021.2 ), and clicking on the Asset Store Havok Page's Personal-Plan links to .. the Quick Start guide again π wat
does that mean it's not possible to install the free personal version just for testing ? or am i missing something obvious
"Enable Pre-Release Packages" is on btw
Yup. Tried both "true" and "false." No luck so far.
Is there a way to Sample Texture in Job?
You can share your code if you want. Someone here will help :)
2021 just hides these packages, even with the option enabled. you have to manually add it
project tiny
oh .. weird. i hope they update their guides to reflect this. thanks !
Well they only support 2020.3 so currently their guide is valid
It's probably the reason it's not visible
i was wondering why most news / related things seemed to be a few years old. hope they keep going with this, i always had a soft spot for Havok physics
@old barn we are all wondering π
π
Is there a way to pass a BlobArray to a job directly, instead of a BlobAssetReference<BlobArray>?
I have a struct that I convert to a blob asset, and that struct contains blobarrays. Sometimes I have a job I want to reuse, and that job will need e.g. a blobarray. If I have two separate sources of data, I don't want to pass both BlobAssetReference<StructAContainingBlobArray> and BlobAssetReference<StructBContainingBlobArray>, rather I would like to pass the blobarray directly when creating the job instead.
I have a humanoid rig, and you can equip different armour(meshes) - The meshes are connected to the rig so that if the rig deforms, the mesh deforms with it.
My current setup is I create all the different meshes that are connected to the rig in blender, then I import them into unity and I hide all the meshes that aren't the ones I needed.
If you've got another way to do this without hiding meshes, please let me know.
It did not unfortunately as skinnedMeshes are duplicated then attached to the rig. I don't really have a way of differentiate between each entity with a rendermesh except for the DeformedEntity component, but this is internal access only.
why do you not want to hide the mesh?
wait didnt read the last bit also my mind associated both cat pictures as one. isnt that an easy fix of just storing a reference to the entity with a specific rendermesh?
Can you elaborate a bit on what you're thinking of?
Maybe it's something I hadn't considered - currently I'm not able to get a reference to the entity that has the renderMesh I want to hide, as there's no way for me to differentiate between that entity and any other entity with a renderMesh, except for via the DeformedEntity component, but that is internal access only.
The renderMesh entity doesn't exist until the prefab is converted at runtime and then parented under the rig. (Oh yeah, I'm using the convertToEntity feature to do this conversion)
sorry, I see what you mean with the hierarchy getting split into various entities and not really being able to find the one you want. had forgotten about this but its a blocker for some functionality for me too, so will ping you if I find some workaround
Here is my package list: im currently getting the error The type 'U' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'. How do I fix this?
i did nmot copy the whole message, my bad: Library\PackageCache\com.unity.jobs@0.8.0-preview.23\Unity.Jobs\IJobParallelForDefer.cs(77,85): error CS8377: The type 'U' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'. its within unity's jobs library
I added my package list to see if there were any conflicts I was unaware of
so theres nothing going on in the project? zero scripts?
No there is but Iβm not trying to blob a nativelist or anything. Is there a stack trace Iβm missing, because using jobs leak test doesnβt work because it doesnβt test packages
downgrade your collections package to the one specified in Entities dependency or drag the package locally and make the fixes
@whole inlet this should work, its partially tested(some reason my conversion isnt working but I changed the hierarchy of my gameobject)
[UpdateInGroup(typeof(GameObjectAfterConversionGroup))]
public class SkinningConversionSystem : GameObjectConversionSystem{
protected override void OnUpdate() {
Entities.ForEach((SkinnedMeshRenderer meshRenderer, SkinnedMeshCollection meshCollection) => {
foreach (var rendererEntity in GetEntities(meshRenderer)) {
if (DstEntityManager.HasComponent<RenderMesh>(rendererEntity)) {
var renderMesh = DstEntityManager.GetSharedComponentData<RenderMesh>(rendererEntity);
if(renderMesh.mesh.Equals(meshCollection.meshA))
DstEntityManager.AddComponent<SomeMeshSpecificComponent>(rendererEntity);
if(renderMesh.mesh.Equals(meshCollection.meshB))
DstEntityManager.AddComponent<SomeMeshSpecificComponent>(rendererEntity);
}
}
});
}
}
- I don't know how to downgrade a package thats in a release...
- I think I need FixedString32Bytes which isnt in the version I need
- I think it's being called here, but I dont have the stack traces.
.Schedule(Dependency); - Is there a way I can force a type to be non-nullable?
Man I sure am paying the early adopter tax
Go to Packages/manifest.json and change the version manually there
You force a type to be non nullable with where T : unmanaged
"com.unity.collections": "0.15.0-preview.21" Try this version instead of 1.1.0 release.
ok got that maybe i can work around the fixedstring32bytes issuwe
ok, fixed it. But now I am back to square one with my struct not being blobbable even though im using purely blobbable assets
Might want to show your blob struct
public enum Types
{
Block,
Creature,
Fluid
}
public enum BodyParts
{
Arm
}
public struct ParsedRawData
{
public GeneralData General;
public PropertiesData Properties;
public BehaviorsData Behaviors;
public BlobArray<BodyParts> Anatomy;
}
public struct GeneralData
{
public FixedString32 id;
public BlobHashMap<FixedString32, FixedString32> name;
public BlobHashMap<FixedString32, FixedString32> desc;
public FixedString32 texture;
public Types type;
}
public struct PropertiesData
{
public BlobArray<FixedString32> tokens;
public int hardness;
public BlobHashMap<FixedString32, int> species_stats;
public BlobHashMap<FixedString32, int> lifecycle;
public BlobHashMap<FixedString32, int> stats;
public BlobArray<FixedString32> custom_props;
}
public struct BehaviorsData
{
public BlobHashMap<FixedString32, BlobArray<FixedString32>> behaviors;
}
public struct RawBlobStruct
{
public BlobArray<ParsedRawData> Arr;
}
BlobHashMap is from here: https://github.com/bartofzo/BlobHashMaps
it tells me error ConstructBlobWithRefTypeViolation: You may not build a type RawBlobStruct with Construct as RawBlobStruct.Arr[].General.name.data.values[] is a reference or pointer. Only non-reference types are allowed in Blobs.
i would probably remove fixedstrings and replace with blobstrings to start
also what is inside of GeneralData ?
oh its right there
what is Types?
it's an enum on the top
but yeah from first glance - it doesn't really seem like anything is wrong? Definitely try what thelebaron said with BlobString (didn't know BlobString existed before till now too π )
thats what I get for looking at this on my secondary small monitor π
Idk how compatible blobhashmaps is with Blob structs tho
looks like it just copies NativeHashMap logic tho lol
i think id just test some smaller case but to be absolutely safe id just use a blobarray and loop through them instead of the hashmap?
The type 'Unity.Entities.BlobString' cannot be used as type parameter 'TKey' in the generic type or method 'BlobHashMap<TKey, TValue>'. There is no boxing conversion from 'Unity.Entities.BlobString' to 'System.IEquatable<Unity.Entities.BlobString>'. dang.
ideally Yes but I need the hash map for deserialization reasons
well.... I could actually implement my own IEquatable?...
Does any one know what does Delegate.get_Method mean in a profiler?
For a bit of context, I'm trying to run a burst compiled job in main thread by using job.Run().
But I see the job is waiting for a huge amount of time (2+ ms) where the actual job takes less than 0.01 ms.
(The job neither depends on any other jobs nor uses unity's components like transform)
Couldn't find any info related to this online either.
If it matters, I'm using 2020.3 and the above data is captured while profiling in the target hardware (Android).
This job might have some dependencies that you force to run now before it can be executed
Oh wait you mention it
But still as far as I remember, JonHandle.OnComplete() forces all scheduled jobs to finish
Might be the case here
It's strange that I don't see other threads doing anything when this job is waiting. They're all just Idle.
And even if there's a JobHandle.OnComplete() happening somewhere, I'm not sure why my job has to wait as my job isn't being scheduled and also as it don't have any dependencies.
JobHandler.Complete() forces the everything to stop and complete that job right away.
When you schedule a job it doesn't start immediately. It starts sometime after that method call and then you can check with Handler.IsComplete() to see if it is done.
To get jobs going, you need to call ScheduleBatchedJobs which takes all the scheduled batch jobs that haven't started yet and starts them
I think unity calls schedule batched jobs under the hood a lot which is why it happens even if you don't call it
I think it calls them in command buffer systems, like internal sync points
Yup it does but in non ECS it calls it often too
But as mentioned, this job isn't scheduled. I'm just Burst compiling it and running it in main thread. Am I missing something here?
Adding a super simplified version of the script and the job for some context,
public class MyComponent : MonoBehaviour
{
MyJob job;
void Start()
{
job = new MyJob();
// Initialize native container with Persistent allocator
}
void OnCollisionEnter(Collision collision)
{
int result = GetData();
// some more code
}
unsafe int GetData()
{
job.Initialize (/* input parameters */);
job.Run();
return job.Result[0];
}
void OnDestroy()
{
// Dispose the native container
}
}
This is what my job looks like
[BurstCompile]
public unsafe struct MyJob : IJob
{
public float3* input;
public NativeArray<int> Result;
public void Initialize ( /* input params */ )
{
// Setup input parameters
}
public void Execute()
{
// some complex math
}
}
The unsafe tag is just because I have to pass an array, so I'm just passing the pointer instead to be accessed in Execute method
Some other stuff is happening around your job. Have you tried turning on the deep profiler
I also have no idea about pointers being used with burst and jobs.
you'd need to edit the entities package directly I imagine. Otherwise you can try hashing the string content and storing the key as u/int instead.
In your job code, you would pretty much access the value by
uint key = hash(some_string_value);
K value = BlobHashMap[key];
Yeah I was just going to edit BlobString directly. Do you think it would be faster to loop through each byte in a string to compare if they are less than 32 characters or to hash them with XXHash and compare the checksums
Β―_(γ)_/Β―
Profile it and compare between your target hardware
XXHash has really good throughput, but if you do some intrinsics to compare byte values in a string you can also have very high throughput
Actually blobstring is variable length. So for longer strings as a precaution I should use hash
just a heads up, seems like 2020.3.25f1 and up broke the animation package's RigComponent bones field
submitted a bug report, but like that matters π
i'm using 2020.3.8f1 and not had any problems but i'm maybe doing something different to you?
i don't think i'm referencing RigComponent specifically for anything..
25f1 is later than 8f1 right?
it may or may not be necessary for just a one time setup(ie if you parented any accessories under the skeleton, you can remove them from being converted as part of the bone hierarchy is my understanding)
ahh right that would be right enough!
embarassing, was wondering why my camera wasnt doing certain stuff like head bobs etc
firstPersonCamera = cameras[i];
cameraRecoil = cameraRecoils[i];
rotationEulerXyz = rotationEulerXyzes[i];
positionSpring = SpringFromEntity[firstPersonCamera.PositionSpring];
positionSpring2 = SpringFromEntity[firstPersonCamera.PositionSpring2];
rotationSpring = SpringFromEntity[firstPersonCamera.RotationSpring];
recoilSpring = SpringFromEntity[firstPersonCamera.RecoilSpring];
ah rider: reverse statements is just above format selection. i think its been like this for a year without me noticing until now
inside the editor when i hit play, i invariably have to exit and hit play again because certain assignments in classes don't 'take' for some reason.. not referring to ecs classes i have a manager mono which holds a bunch of ui related classes etc.. it often randomly throws null ref exceptions for fields that are assigned in the editor, so i'll exit and hit play again and it works fine.
anybody else experience this?
i don't have this problem in build fwiw
it's something i've just 'put up with'.. tried to circumvent it by doing null checks and re-assigning these fields etc but it's just so random i just put up with it now, exit playmode and hit play again, 9 times out of ten the problem vanishes the second time i enter playmode in sequence.
i'm fairly certain it's related in some way to dots/ecs even though these are separate and assigned within a mono component in the editor
it's something that i've never experienced in unity prior to working on projects that use ecs etc.
havent had that personally. sometimes after doing package modifcations stuff breaks necessitating an editor restart but I dont think Ive experienced what you seem to be experiencing
yeah it's odd, kinda like whack a mole when i fix one another pops up and so on.. just means i have to hit play and exit and hit play again every other time i playtest, which if nothing else adds a significant amount of wasted time after weeks/months.
Maybe it has something to do with Domain reload ? Did you disable it ? It messes up static references
Holy shit i think you're right
I've just tested and got 4/5 clean starts in a row
Disabled domain reload so long ago i'd completely overlooked it
Still technically faster starting with it disabled, even if i have to load twice, but very good to know
Thanks!
π
Is there a way in conversion workflow to get conversion entity of another gameobject?
conversionSystem.GetPrimaryEntity(other_game_object)
this will return an entity in destination world, but i need entity in conversion world which belongs to gameobject
that's the only entity mapped to the gameobject?
GetPrimaryEntity or TryGetPrimaryEntity if its slated for conversion
if its not then you can use DeclareReferencedPrefab on it, but outside of that, not sure if you would get an entity from another gameobject from other means?
we have actually 3 things
- gameobject we want to convert
- entity in destination world - our result entity which we can access through
GetPrimaryEntity() - entity in conversion world - entity used in conversion world to process conversion in ECS style
i need to access parent gameobject's conversion entity
I'm trying to extend BlobString, but I've never extended a class before and I get these errors. What am I doing wrong, exactly?
namespace Extentions
{
public static class BlobStringExtender
{
public bool IEquatable<BlobString>.Equals(this BlobString first, BlobString other)
{
return this.ToString() == other.ToString();
}
}
}
is it ok to write bool IEquatable<T>.Equals()? Seems like wrong syntax
no idea!
i imagine you can probably reverse engineer however unity stores the conversion world entity via JournalData.
think it should be public static bool etc @white island
don't think that would work - doubt the mono compiler would let you declare a static instance with an interface like so π€
down to these two errors
namespace Extentions
{
public class BlobStringExtender : IEquatable<BlobString>
{
public static bool Equals(this BlobString first, BlobString other)
{
return this.ToString() == other.ToString();
}
}
}
yea BlobString doesn't implement IEquatable<BlobString>
only your BlobStringExtender implements it
error is saying that extend method can't be declared in non static class
thats what i thought but then error CS0714: 'BlobStringExtender': static classes cannot implement interfaces\
use the static class from the first snippet you posted
That's true yes but how do I fix that
and this is also true, static class can't implement interfaces in c#
Pull in the package locally and implement IEquatable<BlobString> into BlobString or ditch blob string and use a different type as the key
should I just... drag the blob script into my main project. and it will work since its in the namespace?
okay
by package - i mean the entire com.unity.entities package from your PackageCache.
are you trying to make an extension method or actually implement IEquatable in BlobString?
i am attempting to implement
i fixed all the errors and now im back to square 1, my struct Still. Can't. Be. Blobbable. banging my head into a wall
what are you actually trying to attempt with this, why do you need equatable?
@frosty siren isnt the parent/root generally the actual entity resulting from conversion?
I am using Blobstrings as keys and pairs within these objects: https://github.com/bartofzo/BlobHashMaps because I need the fields of a struct to be deserializable from YAML and my brain is too smooth to make a good implememntation of a blob hash map myself
I dont follow the deserializable from YAML part of this, but tbh no idea how equatable would work given blobs use memory offsets(?) which are definitely above my understanding. Id just say maybe need to rethink if going down this hashmap route is really the best one or see if it could possibly be broken into simpler problems(given how long youve been on it)?
yeah maybe
maybe i should just deserialize into a normal struct and then convert it into one with blobarrays
I can't instantiate NavmeshQuery inside a ForEach. Here's the code
Entities
.WithName("Calculating_path")
.WithAll<BehaviorProgressComponent>()
.WithReadOnly(translation)
.ForEach((Entity condition, int entityInQueryIndex, ref DynamicBuffer<ValidPathWaypointComponent> waypoints, ref BehaviorResultComponent result, in ValidPathQueryComponent query, in ValidPathPositionComponent position) =>
{
var pathfinder = new NavMeshQuery(navMeshWorld, Allocator.Temp, NODE_ALLOCATION_AMOUNT);
})
.WithBurst()
.Schedule();
The error messages are
InvalidOperationException: Calculating_path.JobData.navMeshWorld.world uses unsafe Pointers which is not allowed. Unsafe Pointers can lead to crashes and no safety against race conditions can be provided.
If you really need to use unsafe pointers, you can disable this check using [NativeDisableUnsafePtrRestriction].
But if I try doing this
.WithNativeDisableUnsafePtrRestriction(navMeshWorld)
It doesn't work since NavMeshWorld itself is not a pointer, but the world inside of it is
Is there any way to instantiate NavMeshQuery inside of a ForEach? I know that Job.WithCode is possible, but in this case I need ForEach
i dont think you can create one inside a foreach
i got this working a few years ago
but it requires some unsafe code
you have to remap some memory
@gusty comet When I updated zulfa's navmesh project, I personally pooled them in oncreate using this
UnsafeNavMeshQueryArray[index] = new UnsafeNavMeshQuery { Ptr =UnsafeUtility.Malloc(UnsafeUtility.SizeOf<NavMeshQuery>(), UnsafeUtility.AlignOf<NavMeshQuery>(), Allocator.Persistent) };
var navMeshQuery = new NavMeshQuery(navMeshWorld, Allocator.Persistent, MaxPathSize);
NavMeshQueryDisposeList.Add(navMeshQuery);
UnsafeUtility.CopyStructureToPtr(ref navMeshQuery, UnsafeNavMeshQueryArray[index].Ptr);```
Yeah I did something like that, bringing back memories. (I've since written my own mavmesh system)
Has anyone successfully made physics constrains work? After adding a joint to my player, I am still able to cause the player to move and rotate in the Z-axis.
man blob arrays are so hard to initialize
Can I query for a complete archetype, so there are no other components than the one I am looking for, or do i have to explicit exclude components? So like something I would call Entities.ForEach().WithOnly<Component>()
yes but i have my own 2D transforms and i exlcude Transform mono component from conversion to prevent creating of LTW, TRS comps, etc
sounds pog
But I guess you'd need your own renderer for that
since hybrid will struggle to draw entities without transforms
or am I wrong?
i have my own 2D renderer π
You can filter an entityQuery with a WriteGroup
I assume you looked at the physics samples and that didnt help ?
yeah the physics samples seemed simple enough to setup, but ive not actually ever used constraints so maybe im missing something
@karmic basin I totally forgot those existed. I havenβt touched Unity in two years. Thanks
anyone else get stacks of warnings due to the EntityComponentStore.cs having exceptions in it? Kinda feels janky to have unity complain at me about their own code!
Bleeding edge!
I assume you are just calling Draw methods yourself?
(That's what renderer means?)
yep
February and still no 0.50. Such is life...
Too much for answering everything, especially as our next update would probably be available before we get to the end of it
a month ago lol
just added an UpdateBefore and UpdateAfter to a System (did that before never had any issues) but now i'm getting this exception:
points pretty close to a "throw new CircularSystemDependencyException(visitedSystems);" is this a bug or can i assume this is infact an issue with a circular dependency?
Show the attributes of the system maybe ?
So we can see if smthg wrong with ordering
[UpdateAfter(typeof(TransformSystemGroup))]
[UpdateBefore(typeof(EventCommandBufferSystem))]
public class ProjectileSystem : SystemBase
sorry if i'm not included the entire class. its pretty big.
where EventCommandBufferSystem is a custom command buffer that has the attribute
[UpdateAfter(typeof(FixedStepSimulationSystemGroup))]
Specifically, my questions...
What was your question they didn't answer
True. I didnt really have any questions. Just a general wish list. And they didnt even touch it with a 10 foot pole. So sad.
0.50 is gonna come out and i am going to be so disappointed when nothing changed.
mark my words, 0.50 will be largely indistinguishable from 0.17.
don't remember what your wishlist was but i think unity are for the most part pretty happy with the api for entities and im expecting most work to be in the backend
im more interested in the other packages, netcode, animation, etc
i asked questions that were ignored π₯²
i also assume 0.50 will be largely a disappointment?
not even expecting auxiliary packages like animation to be updated at this rate
Hey sorry was off for dinner
So yeah looks like the bootstrapper has a hard time with your UpdateBefore attribute. But that's Unity code not yours, and after a quick test on my end, it spits no errors π€·ββοΈ
I would delete the UpdateBefore, as going after the Transforms system puts you after the fixedstepsimulation anyway
they've mentioned this increasing focus on hybrid workflow and conversion i think right.. i wonder what exactly that will entail, how much work is going into that etc
I think they're not even on the tooling yet. More about cross-platform determinism with Burst I hope π
But I didn't follow so much
i hope the update isn't all just new methods of conversion etc.. that might mean that although jobs/entities scripting might remain mostly the same, we might need to do some substantial refactoring of projects to adapt to whatever the new conversion stuff is like
Not even enough time to work with what we've got anyway haha
yeah there's so many unknowns at this point
yep, can't wait π
I was kinda thinking what a more hybrid centric workflow looks like
pretty sure they said that won't happen till after 1.0
another stab at the gameobject entity or something where the update is actually called from a code gen'd system behind the scenes? kinda wandering into arowx ramblings territory
I am sure that at some point we will productize such a GGPO / lockstep deterministic net-code architecture ourselves but it is currently not the focus for Entities 1.0. Once we do that, we will add native support for deterministic floating point math directly into the burst compiler.
@candid epoch and indeed after having a look at the system debugger can't see how you could possibly satisfy both at the same time. So yeah, pick one because can't have both in this case.
in entities 2.0, sometime before the heat death of the universe
@rotund token Oh damn, better forget about it and let be surprised by the good news in 2 years
i will say i do enjoy reading all the wild theories
The quote is from Unity team ? GGPO... heavy breathing
its from joachim
Can't wait to see that
Oh nice
I should stalk the forums more often
thanks for sharing
so what is the deterministic fp math stuff all about?
fp operations on different cpus can return different results
we've worked around it for decades π
but for certain multiplayer architectures, such as lockstep, then it's kind of needed
but also things like physics
you're simulation could be completely different on different players
it only takes 0.000001 difference in value to completely change the outcome of a simulation
yeah fair enough understood
i do wonder why it's such a big thing for people but i'm probably missing a bunch of obvious stuff
it allows a lot more simplified code
and allows you to implement all sorts of cool things
it's not just some fetishist ideal about having 1:1 simulations on any scale on any device? π
i mean i'm sure there are good reasons why people are asking for it, would like to understand what those are
if it's all around networking i can understand the blank area in my understanding as i've barely touched networking
there are non-network related uses
think of a replay system
you record all player inputs, upload them to some high score website
other players can download and see your record
except on their machine you just drive into a wall
because the velocity was calculated at a fraction of a % smaller causing you to clip a wall, veer off etc
yeah that makes sense
games like trackmania use a determinstic engine so they can provide this replay functionality
many online shooters etc that have replay cams on death will record every state
and just play it back etc taking huge amounts more data (and often never looking quite right)
you've probably seen a game that did a replay and it was glitchy or whatever
yeah that also makes sense.. much greater load and storage requirements in having to do that
i guess in the context of dots, where you have potentially much larger numbers of entities and potentially much larger worlds with finer granularity spacially etc, it becomes a bigger problem
tertle said it all but I'd add this: + having to build workarounds for all that is a pain, when all I want to do is focus on the gameplay experience π
actually DOTS and physics are deterministic... but on the same CPU ^^
yeah it's interesting.. i mean i dunno if it'd be, on the whole, at the top of my list of stuff but i guess implementing that is something that would preferably be done early as it could push changes into other areas and parts of the api's
Just saw reply
ah really
does uhh, nulling the FixedRateManager break that by any chance π
yeah ecs physics world sim + math lib + Burst are okay on same platform