#archived-dots
1 messages ยท Page 216 of 1
There has to be something else messing with your tag
find references only return 2: when creating the entity on another system onstartrunning and here...
should the ecb be created inside the foreach?
i already tried getting entity by ref, without success
You are saying that this is printing the entity twice?
{
struct Component : IComponentData { }
private EndSimulationEntityCommandBufferSystem m_barrier;
protected override void OnCreate( )
{
m_barrier = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>( );
EntityManager.CreateEntity( typeof( Component ) );
}
protected override void OnUpdate( )
{
var commandBuffer = m_barrier.CreateCommandBuffer( );
Entities.WithAll<Component>( ).ForEach( ( Entity e ) =>
{
commandBuffer.RemoveComponent<Component>( e );
Debug.Log( $"Entity({e.Index}:{e.Version})" );
} ).Run( );
}
}
Do you have multiple worlds running?
...maybe...? xD
The EntityDebugger should show if you do
tbh, i dont know how to use it...but i dont see anything...photo?
in fact, if i pause the game, the second time is when I hit the next photogram, so +1 for the ecb being delayed theory...
When clicking on the button that states "ClientWorld" you get a dropdown that should list you the worlds.
The commandBuffer won't be delayed it updates in the same interval as the system
Script โ Today at 9:44 PM
Uhhh are you mixing the FixedStepSimulationSystemGroup with one of the other groups?
make sure this isn't the case, check what groups your system is in with entitydebugger
only default world plus a bunch of loadingsworld empty
If it would be delayed 50% of my code dependent on command buffers would be broken
Which are around 20-30 systems
...options?
They are working fine since 5+ months
doctor?
๐คทโโ๏ธ
@night venture You could try coding in a Debug Break before your Foreach and again after
confirm exactly how many entities you have, make sure theres no duplicates
1 entity 1 system...i think i cant remove anything more xD
and look at all the entity inspectors, the systems window shows how many 'matches' it has so good idea to confirm that
unless its a new empty project I dont think you can assume theres nothing else
oh and clear the library folder too
I've had some compiled older version of a system hang around somehow
fresh project...see u in a while xD
from everything you said it sounds like your system is running twice in the same frame
yea thats what i thought too
its not, cause it doesnt happen until i click next if paused
it is entering twice cause the ecb hasnt run yet, but it doesnt run a third time
so my ecb is delayed by 1 frame ๐
where is your system in the UpdateOrder and what ECB system is it using?
If you see the same behaviour in a fresh project with the code I posted above you need to start worrying
Do you use a custom bootstrap?
Are you recreating worlds?
@north bay yes, no, no.
nothing set, commandBufferSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
what does that mean you click next when paused
use breakpoints, debug.log frame numbers
when you hit pause+play, it show the scene and run the first frame
then you click next and the next frame is run
and there is when it magically "enters"
Subscenes? or ConvertToEntity?
with the same trigger component?
Did you take @north bay's code, make a NEW system and NEW Component type to test?
nothing, nothing, nothing...
yes, used @north bay code and happened...almost ended creating the fresh project
and in the systems window it only appears once?
Werent you trying todo some weird custom OnCreate loop awhile ago?
not that i remember...
must have been someone else ๐
im messing with dynamicbuffers today
So you didn't break the matrix after all huh
well, no clue whats happening, You need to investigate all your existing systems and try figure out whats going on
try disabling EVERYTHING else
it would have a great feeling if this was also broken, cause i would have decided going to sleep xD
no...im sticking to this new project xD
Try adding Debug.Log( this.GetHashCode( ) );
To the OnUpdate of the system I posted and see if it matches
To fully rule out my multiple world theory
Oh I guess lol
Before the whole system went crazy I was messing with dynamic buffers, and I was trying to achieve a specific task:
systemA creates the entity A with a dynamic buffer of 10 elements (waypoints)
systemB must check those items and add some others in the middle (intermediate waypoints)
- tried creating a new dynamicbuffer to replace the older or to clean+iterate, but it didnt work, as memory wasn't allocated according to internals.
- tried using buffer.insert, but as the system uses i-1/i+1 (index), it didnt work as was accesing non-yet created waypoints.
- tried using a native list, but seems the entities are not created before the list is copied to the buffer...(using ecb inside foreach...)
can you think a simpler/better approach to solve the task ?
could you please elaborate? do you mean when using foreach+buffer is a copy (as Translation) and i have to write local changes to entity?
does anyone know offhand if this kind of defensive JobHandle combining is necessary?
Do I have to combine with the original dependency each time considering the jobhandle I pass in already in theory includes that original dependency?
I feel like I've just always done it. Maybe I determined there was a reason for it at one point, but I certainly dont remember
as far as i can remember, when i tried to split things apart, it didnt work.
eg:
var foo = new somethingJob{...};
foo.schedule(..., foo); //ERROR
so i ended using dependency as a one line declaration-usage (as seems its declared by parent)
thats not what I meant, I'm afraid. My question is about whether or not it was necessary for that second job to depend on Dependency, since it also depended on something else that depended on Dependency
sorry. no clue.
As far as I'm aware, yes you need to. It has to include the dependencies for the TypeHandles which are fetched when you get the Dependency property
lol. good.
i think if Job A has dependancy as a input then job B dosnt need to combine A handle + dependancy
Well, at least I feel affirmed that it wasn't an obvious answer
BUT you should combine the outputs back into Dependancy at the end
that, at least, I definitely am aware of
Easy way to figure out tbh. Don't do it and see if the jobdebugger yells at you when you schedule another system that uses those component types
I use a lot if unsafe pointers, so my job debugger often just washes its hands of me
@ocean tundra could you please elaborate? do you mean when using foreach+buffer is a copy (as Translation) and i have to write local changes to entity?
im probably not explaining the issue properly, and althoug there may exist workarounds, this ecb thing is giving me headaches today
systemA add source and destination+ component ready4pathfinding
systemb creates the pathfinding buffer and should replace existing buffer(source/destination)
Your problem was that you did add invalid entities to the dynamic buffer right?
EntityCommandBuffer has a method that is called SetBuffer. That method returns a empty DynamicBuffer<T> which you can add your elements to. At playback that dynamic buffer will overwrite the content of the previous DynamicBuffer<T> on the entity. That playback should handle deferred (the ones created by the entity command buffer) entities correctly.
but, it seems entities (created by ecb) dont exist when added to buffer
so setbuffer replaces the buffer with the resulting one when entities.foreach has ended?
It replaces the buffer once the command buffer is played back
are shared components automatically distributed or is there more to something than just using AddSharedComponentData to an entity?
Hi, I'm using an array of 26 bools within a job to store some data, just for within the job. Will need to reset all of the bools to false multiple times within the same job. Is there a way to set a nativecontainer to "false"/0 for all elements within it quickly, rather than iterating over all of its elements and setting them to false individually (like wiping the memory its using to 0 across the board)? Or is there a better way to do this, like using the first 26 bits of 4 bytes and setting them to 0/1 etc
hey all, been awhile since I've last messed around in DOTS, is there a specific Unity version it's best to work in at the moment?
Trying to get a project last used in 2020.1 beta build working where I used the SubScene and "ConvertToEntity" workflow
but I can't remember if I ever figured out how to get the whole SubScene and "ConvertToEntity" workflow working outside of the Editor, so I figured I'd just try and upgrade it to whatever stuff is happening now instead
I think I forgot ECS requires using a different way to build to get SubScenes to work
requires these Build Configuration assets, right?
it's why I feel like I should update, I feel like it's possible this whole workflow has changed by now ๐
yep, there's my SubScenes folder of binary subscene data...man it's hard to remember this stuff when you put it down for a year 
Can I use hybrid rendered with regular URP
Basically Iโm trying to find out what hybrid doesnโt and does not support in URP
Ty
Ok so letโs say I enter a area where I really need to use reflection prob
Can I just not use hybrid for those particular objects
I'm sad because I made a huge video game, super high quality in my books using DOTS/ECS. It works perfectly in the editor, but when I try and make a stand alone, it errors out and won't run. I cannot downgrade my unity because every single version errors out. My project without library/temp is 17 gig, so every time I port it, it takes 2 hours. I tried so many versions over 5 days, I would say I put 40 hours of trial and error there, but I'm ramming my head against a brick wall. I feel like I have a really huge hit on my hands, but I can't even release it to go live. Just when you thought you crossed the finish line the goal line moves and a brick wall appears between you and it. I've done my part. I've coded an awesome game. Will Unity do their part and make a 2021 alpha version that allows DOTS? I can't even get my unity to load alpha 11,12,13, because errors many other people are having. I choose Alpha to do DOTS/ECS the new technology because I thought I had to.
If I can't downgrade, how long do I expect to be waiting? I have like 5 devs working on the project now that I called in when I got it working[wo standalone]. But they may run out of steam when I'm not pushing forward anymore.
I like coding. I do not like being stuck on a technical brick wall with no one to help me. Can we use DOTS/ECS with alpha soon? After all, alpha infers your latest technologies, AKA DOTS/ECS.
Upgraded to .14: Library\PackageCache\com.unity.platforms@0.10.0-preview.10\Editor\Unity.InternalAPIEditorBridge.012\EditorGUIBridge.cs(15,45): error CS0426: The type name 'HyperLinkClickedEventArgs' does not exist in the type 'EditorGUILayout'
That is the same error I got on .13,.12,.11
Maybe .14 could compile to standalone, but that is the one error I get I can't pass. My choices are "Wait for a version that works", or "Someone help me past that error."
Long shot but have you tried blowing away you packageCache ?
It's mentioned here, they concluded it's because Entities isn't supported in 2021:
https://forum.unity.com/threads/upgrading-to-2021-2-0a11-breaks-entities-0-17-0-preview-41-package.1085771/
The situation sounds.... confusing
"the future of Unity" is no longer compatible with future versions of Unity
quite worrying
Yeah, I don't get this whole area. Nor why they're being so cryptic about it. Saying barely anything almost seems worse than nothing too.
It very much gives the impression that a serious mistake was made somewhere
in either case being transparent about the actual situation should be considered.
DOTS will slowly die at this rate if they just keep drip feeding us
Yes
and that worries me since we've spent hours studying the bloody thing
"Won't work in 2021 until the end of the year at the earliest" is like, really bad
hey for procรฉdural gรฉnรฉration Noise DOTS or thread from scratch or other ?
Procedural generation of noise sounds like a shader graph thing
Shared components are actually stored at chunk level. This means that adding the sharedcomponent just moves the entity into that chunk. If you change the value of the shared component, then you also move the entity into another chunk with that shared value (or create a new chunk if there is no chunk with that shared value)
@remote crater say again how you make your builds ? (Just to make sure you use the new workflow and not the usual way)
Lets hope they won't do something stupid like releasing a DOTS only version of Unity (Bit like Tiny)
result = new NativeArray<int>(1, Allocator.Persistent);
// nvm for me
//this work
int *ptr = malloc(1, 4);
ptr[0] = 0x000000FF; || *ptr
//WTF ...
Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions)
Any explain ?
What's the question
Why constructor failed
And what is the exception it threw
If your fps is too high unity's own components will show this error. Try removing this code and running it. Does the error still happen?
Hmm
but when i need to alloc it ..
you're allocating but not disposing
The job class just isn't held by any other variables so when the job gets deallocated the native Ray member gets deallocated in the.net side which triggers the error because you haven't disposed of it on the unmanaged side
Just call result dispose at the end of your job
Sorry at the end of your job
Dotnet is freeing the job class and.net is freeing the c sharp side of the native array class. This is what detects that you haven't disposed the native side of the array. This safety check only exists in the unity editor. Users of a build would never see the error
Ok when i put this its work but i have question
Surr
Yup
....
?
i don''t want to block my main thread...
If you want to wait until the job is done then your thread is going to wait until the job is done
If you don't want to block your main thread then don't call . complete
@tulip robin are you using regular jobs or using it in entities?
If you have something that depends on the data in that job then that dependent thing needs to wait for the previous job to complete
It's not magic
com.unity.entities
??? O.O
simoyd, in basic Thread i don't need to call .join, i don't want to block my main thread so my game just because i m generating chunk ...
What is causing the seg fault if not some other code that needs to wait for your job? You say if your job runs then there's no segfault right? What am I missing?
Ok, step one my english is bad sorry for this.
step two: i need to generate chunk without lock my main thread.
SO complete block him == for me, just freeze and wait when it's finish...
it's same way then do sync
@deft stump why ?
OH
So after you're done generating a chunk you would do some other process right? To consume the data generated by the function you wrote. That process would call Complete. You wouldn't call complete right when you schedule it
You can make a second job dependent on a first job
So that both your generate chunk and your following process is in a background thread
yeah i already think BUT
If you call complete on the main thread it will block your main thread
you can't because job don't accept mesh etc
obviously ahah ๐
i m trying something and i will back
does that even run
You don't have any references to the result array which is the reason why the leak detection shows you that error. After the job completes there are no references to the allocated data anymore and there is no way for you to free the memory which is what that message makes you aware of.
why not just call thatArray.Dispose and pass in the job handle?
Actually, no. Why not dispose the array when you're done with the result?
it's obviously greedy but ok it's work
thks mate โค๏ธ
but no documentation said that ๐ข
That you have to free memory that you allocate?
anybody here a fair hand with raw pointers? I've got a pointer to an array that is size 2n, and I want to pass half of it into 2 different systems, so one side gets elements 0 to n, the other gets element n to 2n
I seem to recall thats a trivial thing you can do with just, like, arithmetic on pointers
but I dont remember how
like I feel like you can just select the nth element, effectively, and say "here, this is the start of your n length array"
Yeah ๐
Is this a NativeArray ?
yep!
You might be able to use a NativeSlice then?
yeah, I mean I could use nativearray operations
yeah this is more one of those "does anyone know the particular implementation im thinking of" questions
Pointer arithmatic is literally just using the + and - operator on a typed pointer
so byte* test = stackalloc byte[10]; test += 5;
oh, yeah, so I might just add n * size(float) or what have you
gotcha, that's awesome.
float* would already have the size included when you add or substract
right, yeah that makes sense. Thanks, zero!
I would recomment using the NativeArray and Slice however to abstract away the unsafe stuff
lol, im in too deep for that
I agree with that recommendation though, for anyone else seeing this ๐
once I get everything working, I'll probably refactor to use more abstractions.
Are you dealing with interop perhaps?
Mr. K. I know you tried to help before, but I could not follow your instructions. They didn't make sense to me. To you it is obvious, but to me it is not or I'd have it working. I tried for about 8 hours alone trying to install this "WINDOWS PLATFORM" build thing, but was unable.
Are you having any specific issues with installing the Windows Platform package?
Alright don't worry I'll try again to help. It's all explained here https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/install_setup.html#standalone-builds
This means you need to:
0. Completely IGNORE the usual Build MENU (this doesn't know what entities are) that is File > Build Settings
- Install
com.unity.platformspackage through the package manager, & then let's saycom.unity.platforms.windowsto make a windows build. - Create a build asset from Assets > Create > Build menu
- Click the asset from your project tab to show its inspector, like you would for any other asset. From there you will find the new Build button
The screenshots I posted here and there
#archived-dots message
#archived-dots message
show you what the asset and the inspector windows look like.
If that's installing the packages through the package manager that you have trouble with, maybe we can help with that too (sometimes it can be stubborn)
Hi
I'm trying to make a selection box system for my RTS game. What I'm doing is drawing a selection box on the screen, projecting the four points onto the world and creating a pyramid convex collider (the four points and camera position) and then add all colliding units to the selection script. But it seems to behaves weirdly if units have non zero rotations.
//initialPosition - one corner of selection box, finalPosition - Diagonally opposite corner
NativeArray<float3> vertices = new NativeArray<float3>(5, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
vertices[0] = new float3(Camera.main.transform.position);
vertices[1] = Camera.main.ScreenToWorldPoint(new Vector3(math.min(initialPosition.x, finalPosition.x),
math.max(initialPosition.y, finalPosition.y), 25));
vertices[2] = Camera.main.ScreenToWorldPoint(new Vector3(math.max(initialPosition.x, finalPosition.x),
math.max(initialPosition.y, finalPosition.y), 25));
vertices[3] = Camera.main.ScreenToWorldPoint(new Vector3(math.max(initialPosition.x, finalPosition.x),
math.min(initialPosition.y, finalPosition.y), 25));
vertices[4] = Camera.main.ScreenToWorldPoint(new Vector3(math.min(initialPosition.x, finalPosition.x),
math.min(initialPosition.y, finalPosition.y), 25));
BlobAssetReference<Collider> collider = Unity.Physics.ConvexCollider.Create(vertices, ConvexHullGenerationParameters.Default,
new CollisionFilter()
{
GroupIndex = 0,
BelongsTo = 0x00000001,
CollidesWith = 0x00000001
},
new Unity.Physics.Material()
{
CollisionResponse = CollisionResponsePolicy.RaiseTriggerEvents
});
vertices.Dispose();
ColliderCastInput input = new ColliderCastInput()
{
Collider = (Collider*) collider.GetUnsafePtr(),
Start = float3.zero,
End = float3.zero
};
physicsWorld.PhysicsWorld.CastCollider(input, ref hits);
If units have non zero rotations, their colliders seem to be in shifted positions when I select with castCollider but I do know that they aren't since I can select them just fine with simple raycasts.
Noob question: if i use for example EntityArchetype inside bursted lambda, which defined in system, then how can i avoid caching it's value every time before lambda scheduling?
You probably want to pass quaternion.Identity as the ColliderCastInput orientation
Thank you SO much MR.K! I'm gonna give that a try for a few hours. If it does not work, I am going to make a version of my game for my Starforger level designers and they have technical knowledge that they may be able to downgrade to 2020LTS. I'm no longer stuck at a brick wall because of you guys.
Help required to continue: I have Platforms package 0.10.0-preview.10 installed, but do not see where to install com.unity.platforms.windows. It is not in the Package Manager, and when as I said, I spent 8 hours trying to mess with manifest.json to try get it in, but failed.
in the package manager theres a + icon, click it and type in com.unity.platforms.windows to add it
When I tried to build, I got "Empty Build COnfiguration."
Thank you thelebaron I will check that.
looks like it is installing that package
This is great, thanks
Now there is a Classic Windows configuration on the asset->create->build menu
@sage mulch - there is also BitField32 and BitField64 if you have a fixed number of bits. No need to deal with safety/allocation management:
https://docs.unity3d.com/Packages/com.unity.collections@0.9/api/Unity.Collections.BitField32.html
https://docs.unity3d.com/Packages/com.unity.collections@0.9/api/Unity.Collections.BitField64.html
It appears to be compiling. I'll let you know if it does
ooo tyty
It appeared to have compiled and ran. The DOTS part threw up a bunch of errors. Still this is very very good. I can finally patch my game with new stuff for non DOTS mode. I think there is a high chance of the reason DOTS not working is because I funkified my code/scene to try and remove it. So this is very very very good. Thank you much Mr.K and thelebaron and everyone else who helped. Remember my promise: If I make it big, and you track me down somehow later, I will send you a nice ph@t Manilla envelope. hahahah, but for serious cuz I am generous.
Yes, this is awesome! I have a few things to patch over the past few weeks for a minor update. Today I'll work on adding power level bars on ships. ๐ And do an update tomorrow. This is good and encouraging news for my developers. You guys rock. I'll let you know if I can get DOTS working at all.
It looks like yeah, DOTS ain't working. But it's a small victory to do a NON DOTS update, thank you.
DOTS work in client, but not standalone.
is there any way Entities.Foreach being able to invoke a class method with burst?
Only if it's static
but static cant use GetComponent ๐ฆ
No problem, do GetComponent on onUpdate and pass it as param to the static method
or use that GetComponentFromEntity thing
when I build out my DOTS game that uses entities and SubScene's, do I need to keep all 3 of these binary files for SubScenes to load properly?
well I know they won't load with Bundles
I just wonder what the difference is between Bundles and Entities
it takes me 16+ minutes to build my project, so thought I'd ask if anyone knew before trying it myself
maybe
i forgot the version of DOTS I am using probably does copy the sprite sheet I am using unnecessarily
all of my entities are just planes that use a single (somewhat giant) spritesheet to draw a texture
and I have 2.12 million of those entities
about 100,000 per subscene
Ooo very nice
yea dont think subscenes is very good at optmizing away unity objects
but maybe soon
๐
are you on a very old version?
yeah, probably. it's a project I haven't touched in a year, I just wanted to make another build of it for my portfolio
i think i'm in like entities version 0.11.something
and I know that's up to 0.17 now
may try to update when I get more time
so dont go to far on the unity versions if you update
yea
but im thinking "something" is comming
for now a version or 2 locked on 2020
but they cant stay there, as merging back into the 2021+ will be a MASSIVE pain
and the longer they leave the bigger pain it will be
im not getting my hopes up, time between releases has been growing steadily while new features inversely proportionally dropped with the time between releases. considering they want more stability id only guess this could take even longer?
yea definitly, im expecting 6ish months for the next 2-3 versions
a announcement of some sort in 3ish months, but whatever their plan is we wont see it till early next year (10ish months)
im disappointed because theyre now pursuing stability over features tbh, I want audio and pathfinding
me too
still so many core things
optmize tags, the enable/disable components feature
yeah, animation is super rough, editor experience kinda sucks, im not too upset about the code workflow but obviously tons of people really dont find it appealing at all, and seemingly no changes on the horizon there
graphics is a weird hodge podge
i saw a tweet by the hybrid team lead saying they managed 1.42ms with 100k dynamic entity stress test scene
super beefy hardware tho ๐
yea
still that would be nice to have
but also i love procedural stuff, so better performance for individual rendering would be nice too
and no word on if job scheduling overhead will improve or if the job system will scale with more cores(as it gets worse in physics)
wait
it dosnt scale with more cores?
i just ordered a ryzen 9 5950x ๐
i need to use all them cores
it sorta does and also sorta doesnt? i remember seeing 0lento mention with a similar ryzen, that perf suffered with all job workers enabled and maybe something similar on the forums
oh damn
well you will be able to test it out for yourself soon๐
i guess the main thread scheduling begins to suffer?
but hopfully burstable systems will help with that
that too was disappointing lol
yea it sucks atm
a few tests didnt seem to yield any gains but then again its not yet complete so who knows
yea im hoping next version will add full support for jobs
and then maybe the one after add Entities.Foreach codegen
i also would realllly love to be able to update a entire world in a different thread
after reading so many posts here regarding ForEach stuff, imo its a real shame unity decided to kill off IJobForEach, I think that taught me so much about proper job usage while being easier to digest than chunk iteration at the time. Simply starting out learning ForEach lambda has a lot of useful job stuff obfuscated, like kiwi asking how to use HasComponent from a static burst method, very easy in the regular job usage with cdfe but someone new theres like a big jump and current docs dont illustrate it well.
would be awesome to get my whole Server/Simulation world into background
they replaces IJobForEach with something else tho didnt they?
thats not chunk based
I dont think the IJobEntityBatch is it because thats still kind of similar to chunk usage
Id like to be able to schedule jobs from jobs, give me a super unsafe way to try it out ๐
haha nooo so much chaos
but if we could somehow use a old long lived thread
or some sort of new engine loop hooks to plug in a world to a different thread
i work super hard at keeping my Server world away from all the unity stuff
it is basily just the simulation, then pipes stuff into network/accross to local clients
its in combination with the netcode package?
i guess i could run a headless unity
na custom netcode
made mainly for stragety/rts/management type games
managed to network the unity Boids sample the other day, 8k unoptized boids flying round ๐
nice, after making an fps id love to make a simulation game of some sort
well message me when you do, if you want networking
im building more samples and stuff then i want to find some 'beta' users
but also one of my friends has started talking game ideas, and i kinda want to try build a prototype using the networking library
probably be forever at the rate of things ๐ฉ
haha yea same here ๐
have you done much with custom worlds
a big part of the idea depends on sub worlds
Think spaceship RTS with Capital ships having a internal simulation world
so i need a nice way to link worlds together (parent server world has captial ship entities which contain a sub internal world)
I have to figure out how to do manual world creation depending on whether or not you're a client/host (I already have multiple worlds working with ICustomBootstrap) ๐ฆ
I don't really want to start figuring it out lol
yea i do that
its aweful ๐
when you create a new world you can give it a name
so inside the ICustomBootstrap i do if (worldName.StartsWith("Server)) or client
i hate it
we should be able to pass a object in with the world creation, so we can pass any setting we like
ive done zero custom world stuff, I dont want to touch manual system ordering or anything like that, too much cognitive load ๐ฅฒ
yea i get that
you can trigger the defult system ordering somehow. something like World.Sort or SystemGroup.Sort
but yea custom worlds are painful
im really on the fence, i 'might' be able to hack at phyics and things so that it can all exist within the same world
but additional worlds seem so much cleaner
what i want todo is create a world, store it in a component (and NOT add it into unitys auto world update) then when the server updates, dynamicly update the sub worlds (with optmizations like only update 1 sub world per frame, ect)
but i also need to find a nice way to sync data between them, maybe passing around a ECB?
meh, all random ideas ATM, i need to get hybrid entities working in my netcode first
Did you disable automatic initialization for your worlds?
Ah - yeah I'm looking to turn that off
Then from that I trigger additional worlds
There's a define you can add
Something like, disable world initialization or something
yeah something like that
In regards to BitField32, does anyone know why I'm getting a strange value when I try to print the BitField32 next to its .Value? For instance, this screenshot prints the bitfield followed by its Value when converted to decimal, but when I plug those bits into any binary->decimal calculator online I get completely different numbers:
Converted to decimal, those bits should become 3963910912 in decimal
oh huh
they're reversed
should have checked that first
is that normal for this kind of bit struct?
Guess I was treating it too much like an array
As in, not using these provided structs?
yup
got it, i'll have to look into that
that way i can get my sizes a bit smaller
ill see if i can find the link
here
JacksonDunstan.com covers game programming
26 is annoying
you cant really save there
smallest we can pack into is a byte
yep that was my thoughts too lol
thanks for the link tho
i'm sure it will come in handy later
which is 8 bits (8 values) so 26/8 = 3.25 and you need to round up so 4
same size as a that 32 bit field
๐
out of interest what are you bit packing?
neighbors for a voxel
trying to determine a certain kind of shape for a voxel based on its neighbors
just need a flag for whether a neighbor is solid or not, and in my case there are 26 "neighbors"
ok cool
you sould def look at that link then
you could probably bit pack something else into the spare 6 bits
you can fit 64 numbers in that
maybe enough for voxel type?
ooh i like that a lot
thank you
first comment is by another Liam ๐ must be a sign
tho 64 block types is kinda low
but if you added 1 more byte you get a TON of numbers
tru
like 16k
๐
that feels like 2 many
lots of cool things you can do with bit packing
how many voxels can you fit in a entity/chunk?
when i was 'planning' voxels out i could almost get 16*16*16 in
same so far altho i haven't really messed with it
tbh i'm not worried about size at this point, more trying to get my mesh generating correctly hahaha
i've been jumping around with differing methods, marching cubes, wave function collapse, brute force lol
none of them completely fit but im back with just writing out each case manually
๐
you should worry a bit about size
if 1 entity ends up being bigger then a chunk you will have errors
which is 16kb
that's a good point
I got a math static class for jobs, which exclusively uses Unity's math library. I don't need to add the burstcompile attrib on that class right? it'll be burst compiled already as long as the job using those methods is tagged with burstcompile
Ye
Are tuples supported in burst jobs nowadays?
It doesn't see to be throwing an error for me on compilation
I don't see why not. They're just unnamed structs right? Was there a time they weren't supported?
Yeah, burst does not support structs with auto layout
ah
Or it didnt use to
Not sure if there is now some magic going on in the background or something
Support for them got added in 1.5 if I remember correctly
anyone know if you can use setcomponent with a nativearray of componentdata? in a similar way to instantiating with a nativearray?
NativeArray is like a regular array. Just read and write like the elements are just normal structs.
Same if it's GetComponentDataFromEntity<>(), it's just a regular array except now the indices are entities.
๐
im talking about a batch operation rather than reading and writing every element in a loop
I dont believe there's an equivalent batch operation with entities with an native array.
I really wish there was. Makes my entity creation a lot simplier but instead a we need to use a bunch of foreach.
yeah the comparison of entity creation in the best practises highlights instantiation optimization, but then after that for setting or adding components I guess theres just nothing?
You can probably make an extension function but it'll just be a foreach loop rather than something bursted.
was hoping I was overlooking something
Yea, it's nothing at all. Incredibly annoying to type out var entity = entityManager.CreateEntity(typeof()); and then entityManager.SetComponent(entity, new()) every single fucking time.
If I could burst populate then burst set entity components, what would be amazing. But no.
i would like a batched version of the ECB
Welllll, I could technically using an unmanaged system. But that's even more pain.
many of those methods have batch versions on entity manager
that looks like what your after
ahh
That's add component. Will error out if you already have that component on the entity
There's no equivalent SetCompnent(EntityQuery)
like 2 native arrays? one of entitys and one of data
hmm annoying theres no set component version
thats kinda dumb
you could probably do the asmref trick and add your own to entity manager
something like that, like you use entitymanager to instantiate a nativearray of entities, then also add component on that subsequent resulting batch entities but not the entire query?
as the code must exist within that AddComponent version somewhere
Instantiate those entities with an empty unique (to that nativeArray of entities) Tag, then do a Entities.With<Tag>().ForEach() and set the components?
Maybe the Tag should have a single int called Index which corresponds to the native array index.
yea i kinda have that pattern too,
My prefabs get a tag added to them in conversion,
Runtime i have a WithAll<TAG> ..... then ECB.RemoveTag
so i can do my 'init' logic
Then use that tag index to sample the native array, get the component data from the NA, then write to the actual entity. Then outside the ForEach or using a ECB, remove the tag. That's what I do with some of my logic.
Not the best, I prefer to set the component data at instantiation. Get the data array first then create the entity.
thanks, will have to experiment but seems like there should be a more obvious and direct way
yup
the whole ECB/EntityManager api needs some love
its 'good'
but could be so much better
I wouldnt say "good". It works but has so much boilerplate.
Probably because it isnt built into the core of C#, rather working around with the limitation of the language.
If it could be as easy as object creation and setting, that would be amazing.
maybe some super fancy code gen could get us there
but since we have to use structs i dont think it will ever be like object creation
Also which sounds better:
Arc Networking
OR
Arc Multiplayer
Networking
Sounds more professional
agreed
Sweet ty
ok, so how do we kill off companion/hybrid components?
im adding support for hybrid to my networking BUT i only want them to be for the client world, server world should remove/disable all hybrid components from its entities/prefabs
last i looked at this CompanionLink was private/internal
and it still is ๐ฆ
i forget if remove component works on the hybrid component
ah finally resolved my gc issues with compute buffer, so at long last my use of drawmeshinstancedindirect doesnt trigger gc constantly allocating buffers!
https://gfycat.com/concernedbleakbudgie getting closer to being able to ditch gameobject particle/vfx systems and spawn/destroy these things only in entities
very nice
@coarse turtle Yea i think i just need to remove the component, not sure if it works but will test shortly
hopfully it removes the GO too
so remove component does NOT actually remove the GO/delete the component
and because CompanionLink is internal destorying the GO myself causes things to break
ewwww ๐
{
_serverSpritesQuery = GetEntityQuery(typeof(SpriteRenderer));
_type = Type.GetType("Unity.Entities.CompanionLink, Unity.Entities.Hybrid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
_componentType = (ComponentType) _type;
}
protected override void OnUpdate()
{
Entities.ForEach((Entity e, SpriteRenderer sr) =>
{
GameObject.Destroy(sr.gameObject);
})
.WithoutBurst()
.Run();
EntityManager.RemoveComponent(_serverSpritesQuery, _componentType);
EntityManager.RemoveComponent<SpriteRenderer>(_serverSpritesQuery);
}```
What happens to DOTS audio
It's dead Jim.
@light mason Its not dead, just no updates/news/progress
Lol
hello
there are 2 sets of entities under different parents, can they be in same chunks?
theyre same type
Yea they will be in the same chunk
ah nice
what r these numbers? https://i.imgur.com/bwG7mOW.png
i thought theyre amount of chunks but prob not cause
one chunk has just scene in it and it displays big number
also is Schedule actually faster than scheduleparralel?
reaching more fps with schedule but i cant tell
can you get entity by its index?
from entity manager
or by its name
some fast way?
i know i can iterate by each entity in monobehaviour => get some component => gread value
but its probably slow
by the way i am trying to do this so i can get entity in some optimized manner from mb instead of looping through thousands of entities and checking if name matches
Lol
Could you search for it by the presence of a component, ForEach ? entity index is not going to be reliable.
what if you stored entities in list List<entity> at start of the game?
will that list be reliable
eg will it not be corrupted later
if entities move to diff chunks or whatever
i was trying to do in in MonoB
didnt xzjv just say id is not reliable
What do you mean with reliable? As long as the entity exists the Entity struct will point to the same instance
i dont know what he particularly means
i just mean that its a runtime variable, its going to change when working with SubScenes/Conversions, it could be deleted elsewhere, moved around as you build things out. Its fine for super temporary lists that you're needing to cache to pass into subsequent steps but id limit it to that. The entire thing is built around querying by component existence (and optimized for it), if whatever entity you need has a specific component then you don't have to care if the entity exists.
I don't suppose anyone knows the best way to check whether a singleton entity exists in a monobehaviour?
Build an EntityQuery in your MB then .CalculateCount() or smthg like that ?
yeah exactly what I'm doing, just wasn't sure if there was another better way, thanks
I used to think that rendermesh changes chunk only if you change mesh, cause its SharedMeshComponent, but now i noticed theres other values too in that component
public Mesh mesh;
public Material material;
public int subMesh;
[LayerField]
public int layer;
public ShadowCastingMode castShadows;
public bool receiveShadows;
public bool needMotionVectorPass;
public bool Equals(RenderMesh other);
public override int GetHashCode();
is the chunk changing mechanism triggered by change of any of the above? or is it just about mesh
thats quite limiting haha
i thought ill use same meshes with different materials but guess not
@gusty comet Pretty sure, but the thinking is that the RenderMesh changes rarely, so it's not really an issue
You could create some batching system if it's becoming too big of an issue
yeah but the more meshes/materials the more chunks
sadly yeah. 2 alternatives that should be more performant atm (leveragaing the GPU) would be Graphics API .DrawInstancedMesh or smthg like that or compute buffers
Guys, Entities 0.17 changelog no more fixed in forum title. Can it be preparation for updates? ๐
drawinstancedmesh are painful to setup and my meshes will be moving anyway
so i made them dots/ecs instead of Mono xD
there are no updates for next year, or at least not fully compatible ones
As i can understand what is written by MartinGram, 0.17 version and next releases are compatible with only 2020 LTS. Why no updates for whole year?
yeah thats what i mean
no updates if u use newer unity
its kinda funny, you have to choose between up to date unity and up to date dots ๐
Today, the situation makes "Unity" name more ironic than ever
For now whole my project is written with Entitites and i can't be with modern cool guys on 2021, so i only can wait for shiny 0.18
damn do you have any screens? of project
ive made only world as entities
rest is monobehaviour
As console says by error message i can't use SetComponent<T>() and can't use writable ComponentDataFromEntity if there is the same type in ForEach lambda expression.
Is there a way to write to component in this situation?
cant imagine converting everything to entities ๐
i'm not about Pure ECS ๐ It is close to impossible for now. I use a lot of monos. SpriteRenderer is everywhere. But all is written with Entities syntax, using entities queries i mean
oh ok im writing some mono-entity interaction framework right now, for the world. mainly stuff like discarding models if player is too far, or changing planet LoD. planet and models are entities, but player is mono
what is rendermesh.submesh int value for?
does SetComponentData overwrite whole data with new default struct values? + the change you specified. or does it only add the change to already existing data
@gusty comet It overwrites it
But if you just get the component, change the value in the component you get, and then set it back it will be just that value
oh ok thx
any elegant way to store children of entity? i use protected override void OnStartRunning()
but theyre not converted yet so acessing child buffer results null
Beginner at ECS here, im tryiung to setup cinemachine with ECS right now but its not working
im using the conversion workflow
player will be converted into an entity
i thought there would be some sort of bridge for senarios like this
Cameras dont need to be converted to DOTS. In fact, I think its recommended not to. Do all your movement code in regular Mono. Saves a lot of headache.
i actually found a tutorial ๐
but im still gonna move the player via ECS systems
just the camera stuff in Mono
Why NativeMultiHashMap has SetValue() and NativeHashMap don't ๐ฉ
Because SetValue is only in the context of iterating over the elements of a specific key
It's for replacing the current value in the iteration
I guess you want a method to replace the current value?
yes
You can
I have ended up with Remove + Add
thank you. i didn't see indexer in haspmap
This mirrors the api of System.Collections.Dictionary
documentation is not the best - as it just says "retrieves a value by key" but you can see it has both get and set defined
documentation is not the best
DOTS in a nutshell
It's still experimental so it's expected that documentation is not top-level
local
should ECB only be used from within job or can be called from monobehaviour too
thanks
When i want to use some struct defined in system inside scheduled lambda i need to cache it in OnUpdate like this
public class MySys : SystemBase
{
private SomeStruct _someData;
protected override void OnUpdate()
{
var someData = _someData;
Entities
.ForeEach((...) =>
{
...
if(someData.value ...)
...
...
})
.Schedule();
}
}
Is there cleaner solution?
yeah that looks pretty ugly
even more when i have 3 archetypes, some ComonentTypes and other struct data
Unfortunately you have to, but in the first place, storing data in the system it something you should try to avoid.
I think persistent data of what entities archetype system need to create is a data that can only be stored inside System, isn't it?
What problem do you see with storing ComponentTypes/Archetypes etc inside systems?
are you asking Bmandk?
both of you tbh ๐
same for "SomeStruct" if it's persistent data internal to the system
I see no problem to store data in system if talking about concepts. But it leads to heavy boilerplate code
ive discarded my well optimized monobehaviour based world system for the sake of dots, i wonder if it will result in better performance in the end
Well, that sounds just like a prefab tbh
If you ever want to access that data somewhere else, it's going to be a lot easier to have it stored in an entity.
By also storing the data in the entity, you also fulfill the age-old saying of separating data and behaviour
Sure, you have to write one or two extra lines of code to retrieve the data in that isolated system, but if you ever want to access that data in the future, then you're already set to do it much easier
if you want to do this you should have a singleton entity with that data as a component
Yep
The Overwatch devs did exactly what I'm advocating for here
https://www.youtube.com/watch?v=W3aieHjyNvw
In this 2017 GDC session, Blizzard's Timothy Ford explains how Overwatch uses the Entity Component System (ECS) architecture to create a rich variety of layered gameplay.
Register for GDC: https://ubm.io/2yWXW38
Join the GDC mailing list: http://www.gdconf.com/subscribe
Follow GDC on Twitter: https://twitter.com/Official_GDC
GDC talks cover...
They used to store it in their systems
But for good reasons, they went to singletons
I'd still argue for doing the simplest thing that works, and modify when needed (i.e. store your internal system config stuff in the system). Especially for things like caching queries/archetypes/componentTypes (if it was possible to store them in the ECS), because this is strictly an optimisation (you can just recreate the archetype every OnUpdate) and querying the entity system gives you nothing.
If you expect that piece of data to be needed in other systems, by all means store it in a singleton
but don't add complexity for the sake of dogmatic "don't store data in systems"
i think this debate is taking longer than adding 20 singletons
XD
get yo snippets on
I mean, I can link tons of forums, blogs etc that advocate for separating data and logic. The only argument so far against it is because it's more convenient to write that code.
there's definitely an argument for being agile. dont do things you dont need
but separating data and systems is so important
and it's super quick
One quick question: do you consider things like Queries/ComponentTypes/Archetypes to be data?
no. that's logic to figure out what data to perform operations on
not unlike for (int i
yeah "i" is a variable but it's just like... not really data
Queries, probably not. Archetypes you have to specify a bit, because if you want to create an entity based on an archetype, you could do it just from a prefab.
you may persist it as a variable, but that's not unlike a lambda
And even if you don't need any specific data other than the types, I think you could also store the ComponentTypes
interesting
But I also think it's quite rare that you're creating an archetype without any data anyways
Archetype is just an entity description
So is a prefab, just with data
like even programatically generating an entity, you can still initialize it with a prefab then update it
you dont have to make it in code from scratch
soo is it normal that entities are rendered
with cpu and not gpu
omg
anyone knows
what do you mean as "rendered with cpu"
cpu usage increases when you look at entities and gpu stays the same
were your monobehaviours static vs entities dynamic? and what rendering system are you using?
Not sure what this means but if it helps as a reference point, rendering 100k cubes (cpu-wise) on 3900x with URP and a directional light: ~2ms for uploading data, ~2ms animating & ~2ms evaluating TRS & changing render bounds + ~3ms for camera render. (Rough numbers, in editor but with safeties off etc)
thats with 100 entities
jumps to cpu 30ms+ and stays there sometimes
okay it was done by shadows
(decreasing the shadow distance from 30 meter to 10 meters solved the issue) but is that normal that shadows are calculated with cpu?
They are not, there is no software renderer in Unity. Something is putting more cpu pressure for some reason (data upload or culling if I had to guess? but may be anything). Make sure you are on Hybrid v2 and paste your frame profile
hybrid v2 not compatible with my shaders
Wait so you are on Hybrid v1 + built-in render pipeline?
Because that option was never really supported afair
and just worked by accident
Either way, there is no DOTS rendering system that doesn't rely on the scriptable rendering pipelines for performance
i planned to convert them somewhere along the way
but last time i attempted it wouldnt work
Has anyone ever encountered
Burst error BC1028: Creating a managed array `byte[]` is not supported?
I am declaring a static readonly Guid inside a class that extends SystemBase, assigning it to a variable in OnUpdate, and then using that variable in a Job.WithCode. The declaration of the Guid shouldn't be bursted yet Unity is complaining about it
change the array to a native array?
I think System.Guid is implemented with a byte[] inside
so using it at all inside Burst may be impossible
see the sources for System.Guid in the Mono repository and check the DOTS compiler window to see if it doesn't try to put a new byte[] anywhere inside the bursted section
entities has a Hash128 which I think should be burst friendly? may want to try that over guid
Hash128 sounds good! Thanks guys
@worldly pulsar According to https://github.com/mono/mono/blob/main/mcs/class/corlib/System/Guid.cs the code for creating a new Guid is ```namespace System
{
partial struct Guid
{
// used in ModuleBuilder so mcs doesn't need to invoke
// CryptoConfig for simple assemblies.
internal static unsafe byte[] FastNewGuidArray ()
{
byte[] guid = new byte [16];
fixed (byte *ptr = guid) {
Interop.GetRandomBytes(ptr, 16);
}
// Mask in Variant 1-0 in Bit[7..6]
guid [8] = (byte) ((guid [8] & 0x3f) | 0x80);
// Mask in Version 4 (random based Guid) in Bits[15..13]
guid [7] = (byte) ((guid [7] & 0x0f) | 0x40);
return guid;
}
}
}```
So you're right, Guid cannot be used anywhere in bursted code
@safe lintel I made my own Guid struct and put a Hash128 inside, which basically replaced all instances of the old Guid class in my project. Thank you so much!
Sometimes after script compilation the following exception is thrown, which causes the scene to lose all references to scripts upon clicking Play.
Manually triggering a recompilation corrects the script references, though it's very annoying and time consuming
Is this the most effective way to remove a component from all entities that have it? (group is a EQ for just that component)
Does the EQ need ReadWrite componenttype or just ReadOnly or just a Desc with All = ... (what exactly?)?
_group = GetEntityQuery( ComponentType.ReadWrite<TagBubblePhysicsRefresh>()
);
- yes 2. doesn't matter afaik
Thank you, @worldly pulsar
I see couple of problems.
When i use EntityArchetype to create entities i do it when i need no data, i mean when i can and want initialize entity from scratch.
Yes, i can use prefabs, this will eliminate the need for the system to have such data as EntityArchetype. But using Prefabs leads to increasing Archetype count, because PrefabTag creates unique entity description. I don't really know how much Archetypes is good to have, this is the question for me. But if i don't need data, why not do it for myself?
I have read your reply below about storing ComponentType as data and then construct entity from it. But can you set ComponentType from inspector? I think inspector can't do this for you. So you will need a code somewhere to initialise some singleton entity with some ComponentType data.
how much Archetypes is good to have
Last I checked having archetypes is essentially free (same for queries). Creating archetypes is somewhat costly (in the "don't do that every frame" sense) but other than that, having an additional archetype from a prefab is not something I'd worry about.
It's a good point about prefabs creating more chunks. As we discussed, you can use ComponentTypes, but you still need the data somewhere. If you really wanted to optimize that, you can store it in some blob asset, to make the entity count less. Your blob asset could also have the component types in there.
As for setting in inspector, I guess not by default. But it's not too hard to create an editor script that gathers all the component types you want through some reflection and creates an enum or something for it, and then displays those in your inspector.
His point is that having a prefab is actually a new entity, with a prefab tag. That means just having the prefab creates a new chunk with just that entity.
One your prefab creates one Archetype and one entity which stored in one chunk which is 16kb. It is not something critical but still.
I have such script, but i have wrote it a year ago and i was facing problems with AOT
So if you have 100 of these they will take 1.5 MB. If they are actually useful to you (which I'd argue in this case they are not) it really isn't something you'll notice unless you are on a really old mobile
But maybe with ComponentType it will work
If it's an editor script, then AOT won't matter. You should basically just wrap it in #if UNITY_EDITOR anyways
Year ago i was trying to find solution to be able to have something like ComponentPreset which stores component with data, not just types. And using this you'll be able to add components to entity at runtime. I was need such solution to construct arbitrary entity at runtime. I ended up with codegen.
Also i think that i can trick with conversion workflow to inject components at runtime.
One step at a time. I'm trying to downgrade me 2021 to 2020 LTS: here is my error message on converting: https://crystalfighter.com/code/8.png
Yeah, some codegen or conversion workflow wouldn't have much trouble with this kind of stuff
Can it be that those packages versions are incompatible with 2020?
I think 10.xx is the latest supported version for 2020
If you continue and go into the packagemanager you might be able to downgrade directly
Otherwise you will have to find out which versions are compatible with 2020
Most of the info should be on the SRP or URP manual
@remote crater you can create empty project on 2020 and see latest versions of your packages
10.4.0 is the latest compatible versions
I'd recommend just going to the manifest and changing it there
If i use DynamicBuffer in lambda and use GetBuffer inside lambda with the same type console tells me that i can't use writable access to buffers with same type.
My case: I use IngredientElement : IBufferElementData to represent what ingredients player has at the moment, and also i use same IngredientElement to represent required ingredient for recipe.
Is there something like DisableNative...WhateverToBeHappy ? Or what do you do in such cases?
What I'd do is use IngredientInInventory and IngredientRequired structs as buffer elements, but if you guarantee the buffer on player is never the same as the buffer on requirements then I think it's [NativeDisableParallelForRestriction]Entities.WithDisabledParallelForRestriction()
(I assume the IngredientElement has some kind of ingredient ID so duplicating these is not a problem)
The lambda has some disable descriptors, I forgot which one is the correct one
But it might be ParallelFor as @worldly pulsar said
uh, wait, the ForEach syntax has Entities.WithDisabled..., not an attribute
Yeah that's what I meant ๐
Thanks for answers, will try ๐
oh i had no clue what that meant. Thanks guys.
var patched_filter = collider.Value.Value.Filter;
patched_filter.GroupIndex = bubble.id;
var cv = collider.Value;
var cvv = cv.Value;
cvv.Filter = patched_filter;
Debug.Assert(collider.Value.Value.Filter.Equals(patched_filter), "This assertion fails. Why?");
I'm struggling with setting a collision filter on an existing collider. This used to work (possibly by coincidence through case 0), so now I added the assertion and it always trips.
BlobAssetReferences are apparently structs.
But... its value is a ref.
And I am changing the object at that ref.
Man those chains of structs... and abstracting away everything behind a BARef is just so difficult to debug.
Already guys! New errors! This is good because our princess is in another castle of errors: https://crystalfighter.com/code/9.png
I actually feel confident I can finally make a standalone.
patched_filter.GroupIndex = bubble.id;
var cv = collider.Value;
ref var cvv = ref cv.Value;
cvv.Filter = patched_filter;
Debug.Assert(collider.Value.Value.Filter.Equals(patched_filter), "This assertion fails. Why?");```
I think it should work this way, because `cvv` in your version is a copy and the `Filter` setter takes the `this*` and does magic with it... but the copied Collider has this* pointing at the stack
Well it makes the assertion not trip, so that's encouraging.
But the functionality behind it doesnt work, so there is still something off.
(i.e. the collisions aren't detected)
I'm actually not sure var cvv = cv.Value is even valid, because they assume C++ style data layout, where there Collider is just a header and they expect there to be more data in memory after it
collider is a PhysicsCollider componentdata
Looking at some ways people on the forums use to set collision filters, this seems to be a surprisingly convoluted topic.
collider.Value.Value.Filter = patched_filter;My old code was this.
Ok that passes the assertion, too.
Weird.
Well, not weird.
this should be equivalent to my version (with ref)
I think maybe BuildPhysicsWorld doesnt pick these up then. There IS a bug in Unity ECS that I found and that got confirmed, but my new code is much simpler so that shouldn't trigger.
But in IsCollisionEnabled in Unity.Physics, the collision filters aren't properly updated.
Is updating those blob assets at runtime even supported? (I barely ever use Unity.Physics)
Hey, I'm having trouble using Unity.Mathematics.random. I'm initializing a global random to be used by static variables like this
public static readonly MyGuid = /* code that uses the global random */
It has to be Unity.Mathematics,random, otherwise it won't be burstable. However, I keep getting the same generated value in all the classes that call the code that uses the global random. Anyone knows how to make each call to nextInt alter the global random's state?
I seeded it with a constant integer of 1
The random generator code is ```public static class RandomGenerator
{
private static readonly uint SEED = 1;
public static Random GenerateThreadSafeRandom()
{
return new Random(SEED);
}
public static Random GenerateMainThreadRandom()
{
var ticks = (uint)System.DateTime.Now.Ticks;
var nonZeroTicks = ticks == 0 ? 1 : ticks;
return new Random(nonZeroTicks);
}
}
And the Guid code is ```
public struct Guid : IEquatable<Guid>
{
private Unity.Entities.Hash128 hash;
private static readonly Unity.Mathematics.Random RANDOM = RandomGenerator.GenerateThreadSafeRandom();
public bool Equals(Guid other)
{
return hash.Equals(other.hash);
}
public override int GetHashCode()
{
return hash.GetHashCode();
}
public static Guid NewGuid()
{
return new Guid
{
hash = new Unity.Entities.Hash128(RANDOM.NextUInt4())
};
}
}
An example call to NewGuid() would be
public class SomeSystem : SystemBase
{
public static readonly Guid SOME_GUID = Guid.NewGuid();
}
You don't have a global rng, you have a static method that returns a copy of the same rng each time it's called
i.e. every time you call GenerateThreadSafeRandom() the resulting rng will produce the same sequence of numbers
That's weird because the Guid class stores a single result of GenerateThreadSafeRandom()
and i think the RANDOM in your guid doesn't work because it's readonly
so the compiler generates a copy before calling methods on it
interesting, thanks for the info, I'll test things out
shucks, removing the readonly causes burst compiler to complain
This all stems from my trying to use SOME_GUID in jobs
Sorry that my use case is so convoluted ๐
Last errors to resolve maybe. How do I resolve these? I want my MMO to go live: https://www.crystalfighter.com/code/10.png
I tried caching the private static readonly Guid in a local variable in OnUpdate outside of the ForEach, then using the local variable inside of the ForEach. Burst still thinks that I'm trying to directly load from a non-readonly static field
@worldly pulsar The code did work, the problem was the following:
- I had custom code depending on this, a change to DOTS Physics that interprets the GroupIndex field differently (like a layer)
- the way Physics determines compound collider collisions is by checking the union of the colliders first; that caused the value to be written to 0 (which is the most inclusive GroupIndex in the default behaviour) again and then further checks just not done.
- I do not know why a simple capsule is a compound collider but ok ๐
Learned something here...
Solution was to set GroupIndex of compound colliders to -1 (or any other value that can't occur naturally), and then for that case to check if the Belongsto/collideswith bits overlap, and return true if so.
So I was able to port my DOTS/ECS project down to 2020, yet still on standalone, it has different execution behavior than in UNITY Editor as seen here: https://youtu.be/ChOdL0pOCWc Any idea why?
If you like what you saw, please sub for more. It helps me. It may help you, but I make no promises!
You can also come to like the only positive zone of the Internet I know: www.twitch.tv/goodnewsjim The Bro Zone Layer.
Temporary offer for anyone of any skill level: Can someone contact me to promote my game? www.starfightergeneral.com I'll gi...
Hey guys, when using entities, the only way to detect collision is with physics bodies? or is it still possible to use collider components?
Hey guys, is it possible to have a native array with a array inside? im trying to create parallel jobs and i wanted each job to give me a float array
Do you know how big the result array will be for each job?
or it's dynamic?
If it's dynamic - you could try using NativeMultiHashMap so each job can write into its own key.
If you know ahead of time how many results each will give, just use a NativeArray and have each job write into a segment of the array
thanks again for the help, i know ahead of time how many results each job will give, the thing is and correct me if im wrong but when using parallel jobs i need to use NativeArray to store each result of each thread
so like 3 threads working at the same time so the native array would have a size of 3
but im still super new to jobs so this might be wrong
You can use a single NativeArray of resultCount * number of iterations
your job doesn't need to correspond to the number of threads
Yeah that might work
If you use IJobParallelFor you get an execution index
so let's say you need to do a job on 20 elements
and each job has 5 floats as a result
so index * array size
Thanks i wouldnยดt get there myself
and then for each job you write results to to executionIndex * resultSize, so index * 5 through index * 5 + 4
so the first job would write to 0-4, the second to 5-9 and so on
- How are you building?
- Have you checked the logs for the build?
Yeah im gonna give it a try thanks.
You'll need to use [NativeDisableParallelForRestriction] in your jobs or the safety system will be upset with you writing to indexes that are not the same as the execution index, assuming you're using IJobParallelFor
Just a heads up
Ported to 2020 LTS still won't make ECS/DOTS standalone, just crashes when running it, any help? https://studio.youtube.com/video/PP1jRQLgruc/edit
Share your videos with friends, family, and the world.
sorry to ask but where exactly do i place this? I tried above the struct but it didnยดt work
aside from that i think everything will workout ok
Your scenelist in the build config is empty. Make sure that all your scenes AND subscenes are there, and in the normal build settings. They must also be there for some reason.
On the NativeArray field in your Job struct
For example here's one of mine
Thanks again
Bmandk, so wait, "use open scenes" doesn't actually register em for dots, but works for MONO?
Bmandk, I don't think that is the case. My scene loaded and played fine.
Its just when I enter DOTS/ECS mode, it crashes.
So I tried your mode and manually added a scene.
Still same behavior, crashes on DOTS/ECS play mode.
Is DOTS/ECS not supported in 2020LTS either?
I know "use open scenes" does not do nested subscenes. not sure if there are other issues. I had to all all my scenes and subscenes for it to work. not sure what the deal is exactly
2020LTS is the main version that dots is supported in
@remote crater
o
what does the log say? what's causing the crash?
Let me see, I never looked at a log file before.
Where is the log located. Seems like there is none.
it should be in appdata. i forget if it's local or roaming, but then it'll be your company name or game title in there or something
kkk
I... can't find mine... I dunno rofl
it's somewhere!
haha
google should be able to help
I found it, but can't understand it
Apparently it is saying certain things are null which aren't in the actual editor version.
Is it possible order of operations gets changed?
Cuz I convert to entity to a singleton for reference using hybrid mono/dots which people say you should do.
NullReferenceException: Object reference not set to an instance of an object
at Unity.Collections.LowLevel.Unsafe.UnsafeUtility.InternalCopyStructureToPtr[T] (T& input, System.Void* ptr) [0x00001] in C:\buildslave\unity\build\Runtime\Export\Unsafe\UnsafeUtilityPatched.cs:42
at Unity.Collections.LowLevel.Unsafe.UnsafeUtility.CopyStructureToPtr[T] (T& input, System.Void* ptr) [0x00001] in C:\buildslave\unity\build\Runtime\Export\Unsafe\UnsafeUtilityPatched.cs:36
at Unity.Entities.EntityDataAccess.SetComponentData[T] (Unity.Entities.Entity entity, T componentData) [0x0003a] in D:\unity\unity projects\starfighterclient - Copy (2) - Copy\Library\PackageCache\com.unity.entities@0.17.0-preview.41\Unity.Entities\EntityDataAccess.cs:1017
at Unity.Entities.EntityManager.SetComponentData[T] (Unity.Entities.Entity entity, T componentData) [0x00008] in D:\unity\unity projects\starfighterclient - Copy (2) - Copy\Library\PackageCache\com.unity.entities@0.17.0-preview.41\Unity.Entities\EntityManagerAccessComponentData.cs:50
at Controls.FixedUpdate () [0x0028a] in D:\unity\unity projects\starfighterclient - Copy (2) - Copy\Assets\Scripts\Player Scripts\Controls.cs:1600 ```
Nulls everywhere man
D:\unity\unity projects\starfighterclient - Copy (2) - Copy\Library\PackageCache\com.unity.entities@0.17.0-preview.41\Unity.Entities\EntityDataAccess.cs:1017
oh sorry whoops read it wrong
D:\unity\unity projects\starfighterclient - Copy (2) - Copy\Assets\Scripts\Player Scripts\Controls.cs:1600
I find that because the release build runs faster the initial order of system is sometimes different in a build than in unity
That line is: https://hatebin.com/jpwbupmwvy
might need to add some before and after attributes
OOOOH so that IS THE PROBLEM! AS I expected, Unity has no set order of operations
That's terrible design, but I can hack it to make it work maybe
That's really good stuff to know bro.
DOTS/ECS is awesome otherwise, their stock is gonna rocket when this is done.
So that log file, is there a way for my debug.log statements to show up in them. This could help me find the order of operations in my editor vs standalone.
oh yeah I see em now
I thought I had more
TY. Ok, gonna get dinner, and theorize how to do this.
Should be as easy as just putting Debug.Log before every entity call
which I only have about 20
Thanks coder bro.
Remember if I make it big, ask me for a Manilla Enevelope ๐
assuming that doesn't make a system take so long that the order changes again after you remove the debug statement XD
but good luck
Well in order to avoid race conditions, I could have a pacer variable
Don't run this unless > x
you can just use UpdateBefore and UpdateAfter attributes on the systems to enforce order
I've dealt with should be racer condition hell with that decades ago.
TY, I book marked that.
Hey guys is minmax ai a common use case for dots?
Or any kind of state space search
It's a bottleneck for my game and I'm wondering if I should invest in writing a dots solution/find one online
General consensus on the DOTS forums is that the only AI DOTS supports is a form of Utility AI. No clue how min-max AI relates to it though.
Hmm yeah this kind of high level decision making was the only result I could find too
I've only scratched the surface of dots so I'm probably not gonna try it if there are no examples of it being done but lemme know if anyone has any ideas
Anyone use DSPGraph
@bright sentinel , @worldly pulsar it seems like those descriptors are only for captured native containers
Hmm, maybe you can then use BufferFromEntity<T> then, and then disable the restrictions on that?
i'm not quite understand how
Something like
OnUpdate()
{
SomeBuffer yourBuffers = GetBufferFromEntity<SomeBuffer>(Allocator.TempJob);
Entities.WithNativeDisableParallelFor(yourBuffers).ForEach((Entity entity, SomeData someData) => {
var buffer1 = yourBuffers[entity];
var buffer2 = yourBuffers[someData.someEntityReference];
}).Schedule();
}
Does that make sense?
oh, ok, i've got it
@frosty siren You might also be able to use the "new" syntax, with GetBuffer to replace most of it.
OnUpdate()
{
Entities.ForEach((Entity entity, SomeData someData) => {
var buffer1 = GetBuffer<SomeBuffer>(entity);
var buffer2 = GetBuffer<SomeBuffer>(someData.someEntityReference);
}).Schedule();
}
Although I'm unsure if the disable thing gets added automatically with that or not
I already use new syntax everywhere, but it leads to this problem
no its not working
there is no problem in your example code, because error only happens when you have DynamicBuffer in foreach query like
OnUpdate()
{
SomeBuffer yourBuffers = GetBufferFromEntity<SomeBuffer>(Allocator.TempJob);
Entities.ForEach((Entity entity, DynamicBuffer<SomeBuffer> someBuffer) => {
var buffer1 = yourBuffers[entity];
var buffer2 = yourBuffers[someData.someEntityReference];
}).Schedule();
}
@frosty siren Yeah, but that's why you don't have the dynamicbuffer as part of the ForEach, but use the BufferFromEntity type instead
Oh, I also mistyped I guess.
WithNativeDisableContainerSafetyRestriction works
SomeBuffer yourBuffers = GetBufferFromEntity<SomeBuffer>(Allocator.TempJob); should be BufferFromEntity<SomeBuffer> yourBuffers = GetBufferFromEntity<SomeBuffer>(Allocator.TempJob);
But good that it works ๐
LOL. I could use BFE for entity in ForEach instead of pass DynamicBuffer to query. Little overhead and so less problems
Simple things sometimes pass my head
hey guys, let's say some of my project is classic unity and I want to only implement ECS in one system. however, that system is linked to the other systems in the game. How do I do the conversion without worrying too much of it breaking other things? I'm currently trying the Convert And Inject Game Object on my entity, but changes to the entity don't reflect back on the gameobject (such as destroying the entity, does not destroy the related game object)
where can I read of the best way to do this, or do I need to convert the entire game to ECS for this?
No, you can ship your game to dots partially. Convert And Inject Game Object will just add all components from gameobject to entity as ComponentObject, and you will be able to access GO's components from ECS systems. But by default this kind of conversion do no sync for gameobject<->entity. If you want to sync positions, you can use CopyTransformToGameObject/CopyTransformFromGameobject/etc. But there is no built in way to sync destroying for injected gameobject, you must create something by yourself.
Convert and Destroy will just destroy gameobject after conversion, but all GO's components that used in GameObjectConversionSystem.AddHybridComponent(Component) will appear on new gameobject which will be completely linked to entity (means sync position, destroying, creating). For example by default, if you use HybridRenderer, SpriteRenderer component will be added as Hybrid in case of use Convert and Destroy. AFAIK it called Companion, when gameobject recreated and linked to entity during conversion. Using companions very simple, but it has downsides.
thanks for the answer tony, so basically if I want to sync the destruction of entities towards their GO, I need to create my own conversion system as described here?
https://docs.unity3d.com/Packages/com.unity.entities@0.16/manual/conversion.html
can you please refer to section you're talking about?
I was thinking to make something like
class SyncDestruction : GameObjectConversionSystem
...
OnUpdate()
{
// do something here
}
To sync destroying?
I wouldn't know if it will work, these things seem too abstract for me
Conversion systems only works when conversion happens. If your game perfectly uses dots, then conversion wont be needed at runtime. So to destroy gameobject, you have to
- Cache entity destroy event (maybe SystemStateComponent can help)
- Access to related gameobject
- Destroy gameobject manually (or reuse it ๐ )
I will look into those, thanks a bunch!
You might be looking for hybrid components https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/hybrid_component.html
I will look into that as well, thank you ๐
yes
from entitymanger you have a system getter
wrong, my bad. You access systems from World, not EM
World.DefaultGameObjectInjectionWorld.GetExistingSystem<GalaxySystem>().set
whats next though
World.DefaultGameObjectInjectionWorld.GetExistingSystem<GalaxySystem>().myPublicVariableInSystemScope ?
you're welcome, and another thing, check if it exists, just in case your MB Update() runs before your system
thats not needed for this particular case
i am submitting player transform to system, on player login
so the system can calculate distance from planets to player
Isn't it enough to have a system that queries player + its position components, and just instantiate the player prefab on login, and let the query in the system pick up the player position. Without having to set anything ?
that is to say, without setting position explicitely
do you know about this?
UnloadTime: 2.157500 ms
NullReferenceException: Object reference not set to an instance of an object
at Unity.Scenes.ResourceCatalogData.GetGUIDFromPath (System.String path) [0x00096] in <6d6849833010407eaf68aacfba8931a1>:0
at Unity.Scenes.SceneSystem.GetSceneGUID (System.String scenePath) [0x0000b] in <6d6849833010407eaf68aacfba8931a1>:0
at Unity.Scenes.GameObjectSceneUtility.AddGameObjectSceneReferences () [0x00034] in <6d6849833010407eaf68aacfba8931a1>:0
at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x0000c] in <666db234fd54498496918391b0314900>:0
in build only
yeah, check if system getter returned something before trying to set one of it's var ?
wait, this is something related to scenes
double check you included all scenes in build ?
do you compile differently for dots?
yup, from the build asset, not the classic build menu
it's in com.unity.platforms package
๐
you know i dont use subscenes
uwu
wondering if it will bite me back
but in my game its important that you see things happening 1000 meters away
1km is okay you wont have floating point origin problems
these kind of problems start to appear after 5k-10k-40k
depending what kind of code you use
egg AddForce based gravity worked poorly even at 5k
yup
but i replced it with
raycast
and it worked fine until 40k
if i remember correctly
by raycast i mean snapping the player to planet to raycast.point instead of pushing him via addforce
would love to have super big world though, i did hear dots will be able to help with floating point precision
but they probably dont care about this atm
even with dots i would still have Position components with doubles instead of UNity transform with floats, and have some 3d grid for spatial partitionning and shift everything in view above a threshold. But I still need to test if that messes up physics or not one day
- have some kind of Interest management for additional far/big objects to render in the client view
Erf, the list of things to prototype is infinite ๐ญ
I mean make your own