#archived-dots
1 messages ยท Page 275 of 1
There's no manual for Entities 0.51: https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/index.html
but i guess if stuck worth a try
it takes them a while to get all the documentation pushed
there is likely very few if any changes though
wait what
But it's already available in the package manager?
is it released?
I can use DOTS with Unity 2021 now?
so, what version is stable now?
upgrading project atm, we'll find out
i will say they have broken a bunch of my tooling
[Obsolete("UnsafeHashMap is renamed to UnsafeParallelHashMap. (UnityUpgradable) -> UnsafeParallelHashMap<TKey, TValue>", false)]
[Obsolete("NativeHashMap is renamed to NativeParallelHashMap. (UnityUpgradable) -> NativeParallelHashMap<TKey, TValue>", false)]
=S
interesting ๐ just a rename? need to make some diff
I don't get it, what version do I need? xD
0.51 was made on May 4?
0.50/0.51 is still based on an internal state of from memory like september last year
there wasn't much that needed to change 0.51 to make it work in 21 as far as i can tell, it's mostly editor side of things
Ok
Strange, 2021.3.3 works to install but 2021.3.4 does not
i dont know how to get into 3.2.0 hub
bottom left is a switch channel button or something i think
found it ty
it's just a rename. I'm honestly not amused about calling something Parallel that has shitty performance and uses Interlocked
uses Interlocked
What do you mean?
Enzi 2 months ago - interlock everything
Enzi today - interlock is the devil
๐คฃ
i get the concern though
but to be fair, for most applications it's pretty fast
haha, I never said interlock everything ๐ only if it's faster in practice than other solutions.
NativeCollections and their ParallelWriter are really slow because they rely on Interlocked to keep thread safety. It's for most containers, only NativeStream is truly parallel
You mean mutexes?
just test a NativeList.Add in parallel and then in single thread. single thread runs many times faster. - Isn't atomic operations the general term? Mutex is like the old version of interlocked i think
This is the first time I hear interlock instead of mutex or just lock
sirs. Is new target version of unity known yet?
NativeQueue only interlocks on allocating a new block per thread
it has a block per thread and only if it runs out of space it needs to allocate a new one
// a non-null head which means we need to do more checks...
if (Interlocked.CompareExchange(ref buckets[bucket], idx, -1) != -1)``` check the source, it's used a lot. - Yeah NativeQueue is also block based.
From what I've seen, NativeQueue is not a circular list but a list of blocks, is that correct?
everyone forgets about the poor nativequeue, the original boy
Does that help with performance when adding/removing elements because you don't have to allocate as much memory when growing the capacity?
Also, how do you implement parallel writing to a data structure without mutexes?
well there's a very simple example - an array of lists
1 list per thread
but yes for anything more complicated than just that you do need something
How do you know in advance how many lists you'll want?
Ok
ok upgrade hasn't gone so well so far
Hey guys, is it known what GameObjectConversionUtility.ConversionFlags.ForceStaticOptimization exactly does?
1 error a frame about replacing code gen in the hybrid renderer package
time for a nuke
i believe this is the same as using StaticOptimizeEntity
which removes translation/rotation
adds Static component
so it should only be left with LocalToWorld which won't update
Oooooh, I see!
How about SceneViewLiveConversion and GameViewLiveConversion?
those are for subscenes
to determine what view you see
you shouldn't touch that i don't think, as it's just part of the subscene conversion stuff
(well you shouldn't touch GameObjectConversionUtility either imo ๐ )
oooh, really? why, and what would be the alternative?
I need to convert a prefab gameobject to spawn it randomly during gameplay
the gameobject has a ConvertToEntity component, but I haven't figured out yet how to do it from code
what could I use?
I'm using EntityManager.Instantiate(Entity, int, Allocator) to spawn it right now
Anybody >.>
I need a couple thousand and quickly, so GameObject.Instantinate isn't a good idea
the simplest way: create some component with entity field and [GenerateAuthoringComponent]
I would make sure it's not blocked by windows defender or other anti-virus configurations
then just assign GameObject prefab to serialized field
i have
and future entity will be Entity prefab
it kind of sounds like (based off your previous issue) that the exe is just being nuked
when it's downloaded
you create all your prefabs in a subscene
and then just instantiate what you need at runtime
2021.3.4 + 0.51 in project is a go! (just needed a library deletion...)
wait nevermind still having issues on codegen
๐ฆ
(just needed a library deletion...)
What do you mean?
Oh
I'm not sure I understand tbh
I have a prefab, which I locate with Resources.load
then I convert it to entity with GameObjectConversionUtility.ConvertGameObjectHierarchy
then I instantinate it with EntityManager.Instantiate(Entity, int, Allocator)
also, I must use 2020.3
The Netcode for Entities manual has taught me to do it another way
yes this is not a good entities flow
The Netcode for Entities manual has taught me to do something like this:
[GenerateAuthoringComponent]
public struct PlayerSpawner : IComponentData
{
public Entity Prefab;
}
Then you create an empty GameObject in a subscene, give it this authoring component, and set the prefab GameObject you want
The prefab GameObject is seemingly converted to a prefab entity
ah
wait
so you attach the GameObject prefab to Entity field?
In your code you do GetSingleton<PlayerSpawner>().Prefab and you have your prefab entity
I think in the generated authoring component, the field's type is GameObject instead
I don't see how else it would work
uuuuuuu, I see
that's a cool solution indeed, much better than what I have
alright, I'll try this now then
But you'll also need to add RequireSingletonForUpdate<PlayerSpawner>() in your system's OnCreate() so your system doesn't run before the PlayerSpawner singleton is loaded from the subscene
And if you add that call to RequireSingletonForUpdate<T>() in your OnCreate(), then I think you need to explicitly list all your other requirements too, they won't be automatically generated from your entity queries anymore
Entities 0.51 docs are out: https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/index.html
bugger - 0.51 + 2021.3.4 runs fine for my save library
just my game that has code gen issues
?
oh
I didn't realise
it is latest 2021
xD
all right, time to break my project too
AT LAST
do anyone have any problems with upgrading?
it will take me awhile as I need to do whole 0.17->0.50 upgrade guide
i'm seeing some weird issues with netcode
get an error on codegen preventing doing anything on a library that has no netcode in it
but another library references it that does use netcode
and it wont compile/codegen until the first library gets a reference to netcode even though it doesn't use it =S
but only with netcode?
I don't see the option for adding partial keyword
funny thing
can't see it because it don't compile
why it don't compile? because of missing partial word
๐คฃ
yeah it needs to compile once
I have error with conversion of buffer element with entity field
Hey, is there a way to get an Entity field in the inspector of a MonoBehaviour?
I know you can get it on a struct with [GenerateAuthoringComponent], but I was wondering about a monobehaviour
you can't as how exacly you want to set it up?
I mean, Entity on the component is just a prefab/GameObject as it would be converted
and how should Entity field work in MB?
you can always have GameObject field and convert it by hand
I want to have a singleton monobehaviour, from which a system gets the Entity prefab to instantinate
I was told converting by hand is bad?
oh, yeah, I suppose
damn, I didn't think of that
that solves my problem, although it's a bit silly xd
and use RequireSingletonForUpdate<>();
that's my plan, yea
although... I kinda need the prefab in OnCreate
so ikd
idk
I don't know, but since OnCreate is before OnUpdate, then I guess I don't really need to RequireSingletonForUpdate...
since I need the singleton before it anyway
doesn't matter I guess
have anyone errors in runtime with converted IBufferElement with Entity field?
[GenerateAuthoringComponent]
public struct SpawnerEntityReference : IBufferElementData
{
public Entity entity;
}
Getting access to entities during OnCreate phase is not reliable
I suggest use RequireSingleton
and getting one time thingies related to that singleton in OnStartRunning
Out of curiosity, does pausing and unpausing the game in Unity invoke OnStartRunning and OnStopRunning?
subscenes usually load only after a bit of time after world started running
pausing in what way?
from what I noticed
nnah
from what I noticed
they are only invoked if queries changes
as in, if system requires singleton
it will do oNstartrunning only after it appeared in world
technically start running is invoked if the previous frame system didn't run and the next it did
and onstoprunning after it dissappeared
(or on first frame)
99% of the time this is from queries as you say
but it can be from Enabled toggling etc
oh i don't think it should be used to toggle
as long as it's before OnUpdate, I'm good xd
I really like your idea about using entities as state defines, btw
Kind of curious whether with increased shared comp capacity
I could use one shared component and use it's filter for state requirement on systems
what's so great about it? seems over engineered on paper. ๐ค
allows you to use all power of OnStartRunning
i dunno, it just moves a if to someplace else?
switching states of game becomes very simple
and doesn't rely on other modules
Allthough it does raise a question, whether it's perfomance justified
don't get me wrong, it sounds convenient. if it's not too many systems even perf wouldn't be a problem. still I think an easier, equally convenient solution can be made with sharedstatic or smth
well, in case of a lot of similiar cases
is newtonsoft json now totally gone from 0.51?
when systems would require same component
I could just create group with that requirment
kek
great, I see a lot more caching in low level entities methods
what do I need to do, to be able to use this code without writing WithoutBurst() at the end?
I can't really tell what isn't allowed, aside from the fact that any line of this code produces the error
all structs
unfortunately problem still appears
what error says
show new code
You can't use properties in lambda
Prep your variables before for each loop
oh my
๐
ouch, so Random.NextFloat is also a no-go?
Dots has it's own random
use Mathematics
yea yea, I know. That's what I'm using
you need to make random variable before foreach
I think I just lied to you ๐ you don't have to do it before in case of Mathematics.Random
either way, I think using random breaks it. Imma check
I put my random on entities
I'm using random system with number of random variables
So each entity has it's own random
it was posted on the forum while ago
the safety system got a bit more dumb. can't use a NativeList in a scheduled IJobParallelForTransform
I don't need that, since I only use it to generate random positions basically
and rotations speeds xd
I commented out the calls to random and it still screams :/
my project runs fine now in 2021.3.4f1 and entities 0.51
oooh, I probably can't reference global objects, can I
do you have Buffers with Entity field?
as in variables in the class
No static in lambda either
still doesn't work wth
OUCH
I figured this out
I can't use functions
from the class
Only static methods work
no, I phased out pretty much all buffers. do you have problems with them?
oo, yea I guess so?
Make it static
do you mean [GenerateAuthoringComponent]?
yeah, rewrite to IConvertGameObjectToEntity
it's last thing I didn't try as I have quite a lot of buffers
oh boy ^^
with what did you replace DB?
hashmaps
doesn't mean it will fit in your case. hashmaps is also not quite true. mostly they are linear key/value arrays that are indexed
does anyone have any idea why GetSingleton is claiming that there are 0 instances of a singleton, when it clearly is in the loaded scene? It doesn't exist even after waiting a while...
nevermind, had to make it an entity
im quite new to dots, so this is probably not a clever question, but can i convert unity terrain into dots physics collider thing, and if so, can i have it so non dots stuff still collides with it, or should i instead have 2 terrains, one for the dots and one for non-dots?
also is there a list anywhere of all the packages needed for dots to work?
terrain isnt really officially supported yet
one cludgy workflow might be to export terrain as a mesh and use that for your collider
for needed to work, generally if you install a package it will auto install its dependencies, ie physics will pull in everything it needs, same with hybrid renderer so with those two thats more or less covering all basic dots stuff(entities, collections, burst, math), then theres also netcode
maybe platforms as well to build stuff
ok thank you so much, ill try out the converting of the terrain to a collider to dots, and see how it goes, thanks!
the samples repo should have some useful cases to look at as a beginner, theres physics samples inside it
yup i saw them, they are super useful, thanks lol
what order do i have to install them? as it seems that installing them in any random order is not a good idea so far
shouldnt matter
odd, im getting an error every time i try to install any of them, about the dependencies
perhaps it is urp, does dots support that?
it does, you may have to restart the editor
i have tried restarting it, multiple times, doesnt seem to help, like it doesnt even install the packages, it just says it couldnt
has to be 2020 lts or 2021 lts
yup im running one of the many 2021 lts versions,
here is the error message, incase it helps
odd, ive not gotten that error before
welp that is annoying then, any ideas what could be causing it?
i dont think it is space, cause i have almost a tb of space left, it wont be admin, cause i launch unity / unity hub as admin
dont really know what that error means besides the obvious, but going through these kinds of hiccups are kinda a rite of passage with the dots onboarding experience ๐
welp lol, ill go do research, and try it on my laptop to see if it is device specific, but thanks for all the help!
good luck! maybe someone else will chime in later here
yup, after a bit of messing around, i found the one package that has no dependencies that break, the dot editor, but it breaking in other ways it appears, how fascinating
oh dots editor shouldve been rolled into entities package now so remove it
oh ok i have, but ye, still weird as i cant find anything anywhere about the other errors, and it seems no order of installation helps lol
are you upgrading an existing project or is this a brand new project and installing dots?
adding dots to an existing project
after much research, it seems this issue has never been seen before, atleast it hides in the shadows it has been seen before, no known solutions can be found with googling, trial and error isnt helping much either, very odd, i suppose it is a preview package, makes sense that it is unstable, but im determined, eventually there must be a way to fix it!
I warned you. Subscenes load async and world might start running before any subscene is koaded
for now ill have to go without dots, which is annoying, but oh well, if anyone does ever know of a solution i will gladly take it though
oh god ,living without 2D physics is pain
I literally consider using Hybrid 2D physics xD
atleast you have something working lol, but i wish you luck anyways for whatever your doing!
it becomes so much easier when you finally get that ECS thinking click
ye, i cant wait till i am able to start learning, but so far ive had no luck in installing it
does not work
one of the many lts versions of 2021
oh only that version will work?
yeah
welp i feel like a fool now
and that on 2020
sorry lol, i thought any 2021 lts version would work
oh i cant install that editor version
apparrenty it requires over 550 gb of space
i know
unity does this to me every install
it checks for space in my f drive, but installed in my d drive
i do not have an f drive though
yup
as such i now have to go find a drive to plug in and be my f drive, and it needs to have enough space, so that i can install unity onto my d drive
installing unity is a pain
why not just reinstall Hub to drive you want?
hub is installed on the drive i want
it is installed on my d drive
but hub likes the f drive, just like visual studio, and visual studio code, and omni sharp, and so many other programs
despite me not having one
no clue why my computer does this, cant seem to fix it either, as such i just have to go find something to be an f drive whenever this occurs
welp guess ive either gotta go find something to be my f drive, or just deal with not having dots
sometimes i just wish there was an option to install without checking for space
because there is no space, cause the drive does not exist
well, I heard someone was using it either without a problem
pretty sure since you are using it
you know better
xD
Also all the DOTS packages say 2020.3.0f1 in their package.json
it needs to be 3.30f1+
Any idea whether Companion Game object Update Transform system has any write group filters?
I might want to disable it at some point
your as capable as anyone else in here to look at the source yourself ๐
CompanionGameObjectUpdateTransformSystem
but no it doesn't
because it doesn't write to an actual component
and write groups require a component to write to
it doesn't have Transform
in it's query
i think you are probably the first person to ever think
you know, even though they're meant to be the same thing, i don't want my gameobject companion to be the same as the entity that represents it
welp, yeah xD
Literally everything is done through hybrid atm
animations, rendering and even physics
since no 2D
so at some point I just want to disable companion link update on entity
so it drops dead through classic physics
has anyone got unity + il2cpp building without errors in 0.51 + 2021.3.4f1?
i can build mono fine no issue, soon as i try build il2cpp and run the game
flooded with
ExecutionEngineException: Attempting to call method 'Unity.Entities.FastEquality+CompareImpl`1[[Unity.Physics.PhysicsWorldIndex, Unity.Physics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::CompareFunc' for which no ahead of time (AOT) code was generated. at Unity.Entities.FastEquality.Equals (System.Void* lhsPtr, System.Void* rhsPtr, Unity.Entities.FastEquality+TypeInfo typeInfo) [0x00000] in
yep, I found how it does it. Sadge
hmm, so write group will only work if I try to write to that component of group?
How that would work with managed component?
I want to try and mod this system's query
m_ExistingQuery = GetEntityQuery(
new EntityQueryDesc
{
All = new[]
{
ComponentType.ReadOnly<CompanionLink>(),
ComponentType.ReadOnly<CompanionGameObjectUpdateTransformSystemState>(),
ComponentType.ReadOnly<LocalToWorld>(),
}
}
);
Here's the query that system uses to write to. All read only ๐
hmm, if I simply put different query with readwrite on CompanionLink
and Write group filter
is that going to work?
I wonder why there is no official post about 0.51 yet
no idea
never tried on a managed component
in theory yes
(if you add write group to the query as well)
yeah, will try that through reflection
btw, is there any attribute that I can use to some static method to be executed during WOrld init phases?
like after OnCreate of systems
no that sounds gross
i guess if you use the default bootstrap
you could just do the next stage of RuntimeInitializeOnLoadMethod
@rotund token had you maybe the problem with autogenerated IBufferElements with Entity field?
what?
ExecutionEngineException: Attempting to call method 'Unity.Entities.FastEquality+CompareImpl`1[[Unity.Physics.PhysicsWorldIndex, Unity.Physics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::CompareFunc' for which no ahead of time (AOT) code was generated. at Unity.Entities.FastEquality.Equals (System.Void* lhsPtr, System.Void* rhsPtr, Unity.Entities.FastEquality+TypeInfo typeInfo) [0x00000] in <00000000000000000000000000000000>:0 at Unity.Entities.FastEquality.Equals[T] (T& lhs, T& rhs, Unity.Entities.FastEquality+TypeInfo typeInfo) [0x00000] in <00000000000000000000000000000000>:0 at Unity.Entities.TypeManager.Equals[T] (T& left, T& right) [0x00000] in <00000000000000000000000000000000>:0 at Unity.Entities.ManagedComponentStore.FindSharedComponentIndex[T] (System.Int32 typeIndex, T newData) [0x00000] in <00000000000000000000000000000000>:0 yep, I think I have the same problem as @rotund token
it happens in an empty project
with just dots packages
and an empty scene
tested other properties packages with no luck
already forwarded it over to unity
at least it builds with mono...
also having a lot of code gen issues that need an editor restart to fix - not an ideal work flow
waiting for half a year and getting errors. meh ๐
[GenerateAuthoringComponent]
public struct SpawnerEntityReference : IBufferElementData
{
public Entity entity;
}
@rotund token this
i hope they at least sent you a shirt by now for all the things you found tertle
not sure I have any of these
but wouldn't surprise me
there's a lot of odd errors btw
error SGICE004: Seeing this error indicates a bug in the dots compiler.
or
info SGICE006: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\DotNetSdkRoslyn\Temp\GeneratedCode\X
line 11 is creating buffer for entity in generated script
so null ref in something that basic seems very odd
though that's not breaking, just annoying
so yeah not really recommending anyone upgrade atm
it's too late
I'm too hyped to back down ๐
seemd strange but managed comonent nedded to have all public fields
due to new code generators
that'll die
when you have to restart the editor every time you make a code change
no it won't xD
nice I figured it out
they make an array of entities is autogenerated code
which is never initialized
and then they are trying to use it
public class TileUnitAuthoring : UnityEngine.MonoBehaviour, Unity.Entities.IConvertGameObjectToEntity
{
public Unity.Entities.Entity[] Values;
public void Convert(Unity.Entities.Entity __entity, Unity.Entities.EntityManager __dstManager, GameObjectConversionSystem _)
{
Unity.Entities.DynamicBuffer<_YourHighness.Map.TileUnit> dynamicBuffer = __dstManager.AddBuffer<_YourHighness.Map.TileUnit>(__entity);
dynamicBuffer.ResizeUninitialized(Values.Length);
for (int i = 0; i < dynamicBuffer.Length; i++)
{
dynamicBuffer[i] = new _YourHighness.Map.TileUnit{unit = Values[i]};
}
}
}
seems it will work in case when type will be serialized as inspector will initialize it
I can confirm that was the case
haha
I have another strange error
UnityEngine.Debug:LogError (object)```
protected override void OnUpdate()
{
var ecb = entityCommandBufferSystem.CreateCommandBuffer();
var attacks = attackQuery.ToComponentDataArray<Attack>(Allocator.TempJob);
var healths = GetComponentDataFromEntity<Health>(true);
var map = new NativeParallelHashMap<Entity, int>(attacks.Length, Allocator.TempJob);
var jobHandle = new SortAttacks
{
attacks = attacks,
map = map.AsParallelWriter()
}.Schedule(attacks.Length, 5, Dependency);
jobHandle = new ApplyAttacks
{
map = map,
healths = healths,
ecb = ecb,
}.Schedule(jobHandle);
ecb.DestroyEntitiesForEntityQuery(attackQuery);
jobHandle = map.Dispose(jobHandle);
Dependency = jobHandle;
entityCommandBufferSystem.AddJobHandleForProducer(Dependency);
}
Hey, does anyone have any idea why just adding ref Scale scale into my Entities.Foreach break basically everything?
and the job itself has [ReadOnly] public ComponentDataFromEntity<Health> healths;
It's like no object is selected, suddenly
was Dependency overriding pattern changed in 0.50?
check entities (via DOTS hierarchy window) if they have Scale on them
they probably don't
hmm, they do not indeed
how would I add it?
I kinda thought it would add automatically like translation and rotation
I think there is no easy way
only when scale isn't 1,1,1 it will be automatically added
oh no
it breaks burst
It seems so, you can also make authoring script to add it while conversion
With a struct Scale and a float named Value? Would that work??
and just add it to the gameobject prefab?
make sure you use Unity.Transforms one and not one from i.e. UiElements
it should be burstable
there are 2 versions of scale
Scale and NonUniformScale
oh yeah, I forgot about that
I moved out from using Unity.Transforms
I use only LocalToWorld
Since I have 2D
unfortunatley, NonUniformScale breaks things as well
you still need to add it to entity
I guess I could try making the object have something like 1.0001 scale... I'm gonna reset it anyway
lmao that works
yes, it got more strict. also had a few issues when going from 0.17 to 0.50
are there any resources on this?
not really, the safety system just complains where it didn't before
so technically it was a mistake that wasn't catched
do you know how to fix this?
only some tips, check the line where it is thrown
sometimes the error in itself is pure garbage
and only take the first time such an error is thrown seriously, others are cascading errors from the first one
it's at ecb.DestroyEntitiesForEntityQuery(attackQuery);
what also helps is putting some jobHandle.Complete() in places you are suspicious about. if it fixes it, you know where the problem is
I'm trying to access a buffer after a job where I've populated it but I'm getting this error Attempted to access BufferFromEntity<PotentialMoveBuff> which has been invalidated by a structural change.
I have jobhandle.complete and Dependency().Complete straight after the job
buffers are invalidated by structural changes
after any structural change you need to get buffer again
I even create a new GetBufferFromEntity after the job, I'm not sure what is happening ๐
yeah I am getting the buffer again or so I think
I do this before the job var potentbuff = GetBufferFromEntity<PotentialMoveBuff>(); var realbuff = potentbuff[PotentMoveBuffEnt];
and then this after var newent = GetSingletonEntity<PotentialMoveBuff>(); var oldnewbuff = GetBufferFromEntity<PotentialMoveBuff>(); var newbuff = oldnewbuff[newent];
so is jobs production ready or should I bother learning how to multithread by myself?
hey, is there a way to change surface type of the material on an entity?
from a job
preferably without EntityManager
I really really need to get transparent objects to work somehow
wow. I needed to enable zwrite in inspector in debug mode, and changing it to normal mode breaks it again
I can't click on the material
thatis so silly wth
Do the source generators in 0.51 force you to use only public instance types?
Any idea about unity physics debug display?
I created entity with that component but I don't see any visualisation
1 week of 40 hours of work and more 20+ of fret, I have addressables take over the resources folder's duty. I have a few other possible problems, but it looks promising. Thanks guys for the help. Standalones should be hard let alone this hard, but with solid, friendly help like yourselves at least they're doable.
try to build one a week next time, companies setup whole CI/CD pipelines to prevent such situations
but build once a week should be plenty
So I beat a couple issues, but I am left with: AssertionException: Ensure TypeManager.Initialize has been called before using the TypeManager.... I think Editor runs slower and my code works there because of a fortunate race condition. What is the proper way to Initialize TypeManager MORE INFO HERE: https://pastebin.com/hBvgGXBf
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.
Right, I'll do that. I never knew this could be an issue since I never encountered it in 40+ years of coding, but now I do, and I can mitigate. Thank you for wise methodology advice.
That feeling when the google search return only result is your question from 4 days ago:
Oh tertle said to try disabling entities journaling
I disabled it in the menu, I still get the errors.
are collisions still only done through ICollisionEventJob interface?
I need to make managed collision events loop
There is one that checks triggers too
What you do is check the collisions in that job
then you check each entity based on some components
and then filter the collison based on what hit what
Everything is done through ICollisonEventsJob and ITriggerEventsJob I believe if those are the names
yeah, I know
I just wondered
whether it's still the only way
cause I never liked it
I really find inability to manually choose which collision events to query really troubling
yeah havent been any major changes to physics
You do not want to be querying collision events
kinda sad, physics improvements were moving at a really good pace prior to that year long wait
query is for information always there that you want to process
a collision is a one time deal
is it possible to wrap a native collection into a read only version like this:
private NativeArray<float2> _v;
//public ReadOnlyNativeArray<float2> Vertices => _v;
...
Once you receive the two entities that collide, you process their components
Are you able to detect when two entities collide with your Job?
An event is different than a query
well, that's what I was complaining about: I get 2 entities, but not context
and I have to figure out from what context are they
When you have two entities, you have components attached
You can get the data to process them from their components.
Sec, let me help you
What does your Onupdate look like?
protected override void UpdateWithBuffer(EntityCommandBuffer buffer)
{
Dependency = new GroundCollisionJob { buffer = buffer, playerEntity = _player }.Schedule(
_stepWorldSystem.Simulation,
Dependency);
}
This is mine: https://pastebin.com/BqZFLvMC
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.
See that's the problem
You don't pass components in
You can't read components into your execute
unless you pass em, click my pastebin
Then I'll show you my execute
I don't really get it
appologies for mass comments in my code, I use em like ship wrecks
is there some kind of secret codegen behind?
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.
Notice I pass Entity Data and Translation
EntityData is a custom component I give useful information to my entities
yep, that's what I was talking about
Translation is the position n stuff
you go through each entity and figure out which one is which
Then In your execute, you can process em
Click the second pastebin, most recent
That shows how once you pass a component in, you can read it in the execute
Now that you have custom components you made in, you can process how entities handle the collision if its a bullet, rocket, person, wall, exploding barrel, etc
hmmm, can I adjust entity to stop creating collision events?
it's singleton
I only need to disable raising events
cause I still need collision to be processed
Oh that's a sub chceck box
under material->Collisionresponse in the component
You should be able to find that in the Physics Shape component
how?
First get the Physics Shape Component
Physics Shape is where the ability to turn on and off the events is
But I only have Physics Collider
Every Entity that collides has both
Physics Shape is authoring component
@rustic rain you can do it like this https://forum.unity.com/threads/toggling-collision-events-via-script.851761/ under (b)
its a property of the collider blob
hmm
the code is in the spoiler tag
I guess you can wrap it like so:
readonly NativeArray<float2> classNativeArray;
SomeConstructor() {
classNativeArray = new NativeArray<float2>(...); // Init w/ persistent allocation
}
ah true
I found manual sphere/capsule/whatever casts much easier. also they perform a lot better. maybe you can use them instead of fixed triggers
i find physic shapes only good to use for basic collisions. i. e. character controllers. for everything else, the colliders being immutable makes things difficult
how do you check whether smth collides with smth?
in my case I have floor
wwaaaait a second
I don't think it'll work
damn it
I need a way to determine whether my entity hits the floor
and when it does, usually you can't catch that with simple cast
or overlap
hm, for a floor the default ICollisonEventsJob works best
some capsule cast with velocity would work
you need an iterative solver i guess
should catch everything even between frames when the cast length is the velocity distance for the frame
What physics features are you thinking about
does unity plan to expose native arrays etc to the inspector in future?
kind've annoying not being able to add test data in them
what do you mean to the inspector?
i can't think of a scenario, except a custom debug windows, where this would ever make sense
i want to fill a native array (persistent one) with vertex float2 data
so i can then run it to test collision stuff
right now i have to use a list then populate a native array from the list which is just verbose and annoying
but you cant have an allocated native array just sitting on a settings file?
why not when you can have a list serialised
if its persistent whats so different about it
@gleaming surge they teased some things like lower fidelity physics for particle sim, also better api's for collision, some better joint authoring, im not really convinced by the split physics shape/body either. oh and I know terrain colliders are also something others need. anyway the speed of visible development just kinda dried up
Entities 0.51 is giving compile error with JobsUtility, such as "Library/PackageCache/com.unity.entities@0.51.0-preview.32/Unity.Entities/DefaultWorld.cs(26,25): error CS0117: 'JobsUtility' does not contain a definition for 'ClearSystemIds'"
Any suggestions?
Currently upgrading my Unity editor version
and remember that 2021.3LTS is current latest version of unity
Yeah upgrading to 2021.3.4 from 2021.3.0 worked
Who can enlighten me about how to initialize blob asset when it is a BlobArray itself?
Yo tertle, adding the precompiler command: DISABLE_ENTITIES_JOURNALING Got me past that Standalone Error. I'm now stuck on some weird thing where the addressables aren't packing themselves properly: https://forum.unity.com/threads/please-please-please-help-me-get-a-standalone-scriptable-build-pipeline-isnt-documented.1294917/
We closing in on a nice revenue stream and a dream realized man.
Does Unity have any unbuilt inbuilt ways to test the performance of DOTS systems?
Oops, should have been inbuilt
you mean built in?
eeeeh, still not sure what it would mean in that context, but system debugger literally has profiler built in
is that smth you're looking for?
I meant more of a benchmarking tool
Similar to Benchmark.Net or something
e.g. set up (in this case build the world state) -> benchmark / test -> tear down workflow
I guess the unity test runner can probably do it, but I was wondering if there was something specifically for dots
Anyone had any perfomance problems with Physics?
For some reason for me with just 2 physics shapes one of which is static
I get 5 ms in step physics world system
and overall it jumps to 10ms
Do you have integrity checks off?
Have you tried performance tests package? Not dots specific but just a general purpose performance profiler
tertle, did you solve the physics bug in builds?
@rustic rain are you profiling the timeline or hierarchy?
I did turn them off, but that didn't change much
I am not profiling anything, I am just watching my fps go from 150 to 30
and physics systems go to 50ms
sometimes
should use the profiler because sometimes systems can be waiting on other jobs(spawned from other systems) to complete and you get an inaccurate view of ms timings
What bugs?
That doesn't mean it's physics
That just means physics causes a sync point and it's waiting on that
well, I don't have any systems that are related to physics atm
Sounds good, thanks
Do your systems use translation or rotation?
literally just 2 entities with physics components and fully vanilla
Because then they are related
You just need to look at profiler
I'm not sure what to look at it
seems like it's the first systems all together to run
Looks like you have full stack trace on to me
hmm, where are those 3 dots?
the AOT error that is thrown in builds
I had this when I was still using the physics system
It was orders of magnitude faster in a build
I hope it will, this is supposedly mobile project xD
Oh that's a general shared component data issue
Just using the workaround on forums for now
got jogs debugger on?
so, that's also a reason? xD
yes, jobs debugger adds a lot of main thread slowdown
you really shouldn't profile with any safety on
there's no point
my step physics with 1000 falling cubes is 0.70ms in editor
with jobs debugger on 1.75ms
yeah I have a job which is like 2000ms and goes down to 60 odd I think without safety checks
I think to an extent theres overhead with physics kinda like the hybrid renderer, though I suppose it depends what your hardware is to determine what that is exactly
I just wish they roll out 2d physics as soon as possible
I wish for many things with dots ๐ฅฒ
there is one?
oh, I didn't try that. never thought this would work tbh ๐
stupid question but I don't suppose anyone knows why I get this error Attempted to access BufferTypeHandle<PotentialMoveBuff> which has been invalidated by a structural change. when trying to access the length value of a buffer
I'm not structurally changing it anywhere near this code I 'm just getting the length ๐
all buffers are invalidated by any structural change
just in case the buffer might have moved chunks
its just a safety measure
it would be costly for unity to validate which buffers have/haven't moved
so it's just faster/safer to invalidate everything
so how do I even read teh buffer then
you read it
you just don't use entity manager until you're done reading it
it's in the manual ๐
well that's a new addition I'm sure, they keep updating this stuff dammit
your solutions are really either
a) copy the buffer to a native array
b) use a command buffer and playback after the loop
if you mean new you mean entities 0.6 in feb 2020 ๐
yeah I maybe slightly behind in reading it 
actually I normally do check that page quite often when I use dynamicbuffers just don't think I scrolled down than far ๐
yeah the small print don't matter all I need is the setup
well thanks for clearing that up
So ECS has no animation system. I am told that to have entities that animate I have to convert them from GameObjects. Is this so? Can I get entities that I can animate by converting gameobjects?
that seems like odd advice
if ecs had an animation system you would convert entities from gameobjects (which is what you should be doing anyway)
generally you animate using a hybrid approach of having gameobjects with the animator
which is referenced by an entity
otherwise you need to go into shader animation territory
I always think of this when thinking of shader animations
Why would you have to use game objects if ECS had everything you needed? I don't think game objects are useful in the least and I would much rather not use any at all.
game objects are part of conversion
which is integral to ecs
Well, yes, its necessary in its current state, but that can't be the case forever.
it is meant to be the way of standard workflow
so unless Unity fully gets rid of game object, I don't see how it can become obsolete for ECS
That can't be the case. Why would you just throw away all of your GameObject based features just because you have an ECS alternative?
Also, why would I have a workflow that uses GameObjects to create entities if I didn't have to? Seems like doing it twice
because thats the intended workflow of entities
author your entities via gameobjects in subscenes
i.e.
gameobjects - authoring state
entities - runtime state
1.0 significantly expands on this further
not sure what you mean by that
you mean a unity physics collider?
you can get the type from it
I am trying to modify current physics into 2D
rn what I want is to go through all converted GOs
and modify their colliders to be at Z == 0
offset
depending on converted LTW
Can't figure out how to modify collider
since I get generic type of
Collider
which wouldn't allow such modifications
what about casting?
var boxCollider = (BoxCollider*)e.ColliderPtr;
hmm
all right, seems to work
mmm
seems like changing Center is not allowed normally
well colliders are blob assets
ah, it's private field
blob assets are meant to be immutable
i certainly would not use reflection
it's meant to be set via boxgeometry
but i wouldn't do it this way at all
i'd just write my own physics conversion for physics2d components
I don't want to modify it every time
I change Z
on every game object
I'm trying to simplify my authoring process
wondering, can you instantiate prefabs with dots like regular prefabs, and if so do they require more processing power to instantiate then non dots prefabs, or less?
EntityManager.Instantiate
oh ok nice, thank you so much!
due to me being completely new to everything dots, do you have to create an entity manager manually, or is it auto created when it detects that the scene has dots in it? (sorry if this is a stupid question, the docs for the dots api are quite vague or im being quite dumb)
aha, i have no clue what either of those things are
let me check the docs brb
just go to manual kek
lol
oh thanks lol
so from reading this it appears i do have to create a system base, and it doesnt make itself, and that system bases cant be made in monobehaviours, am i understanding this right?
just keep reading xD
It's totally different world from game objects
at a point it'll get to examples
and all you read will finally start to make sense
yup lol, im excited to learn this, im gonna feel dumb once i understand this
ok ive kept reading, and it seems that each different archetype (list of all entities that are exactly the same component wise) each have their own entity manager, i think, this is so fascinating lol!
and each system is part of a world, which is like the entity version of the scene, except you can have multiple worlds in one scene, and multiple scenes in one world
not really
there is 1 entity manager per world
oh ok cool!
also is it normal and good for dots to really hate one random script that doesnt even use dots?
huh unity discord is not enjoying you pasting that code, unlucky
im a fast reader issue but i can't read all that code in 0.1s
same lol
What am I doing wrong?
trying to make a constraint joint
so entity can only move in X,Y and rotate around Z
results in NaN
is this normal, the file doesnt even use dots?
try to restart editor
ok i will thanks
new issue with 0.51 unfortunately
you can just delete the directory as well
to avoid editor restart
delete what directory? the assembly c sharp thing?
yeah just everything in temp directory
ok, and it wont break anything?
its a temp directory
ok good
just reimport something aftewards
for some reason
its creating files instead of directories in there sometimes
ok got it
ok im a bit confused, im trying to interact with an entity, which means i cannot use a mono behavior, but if i dont use a monobehavior then i cannot atatch the script to a game object, therefore i cannot make it run?
with ECS, updates happen from inside systems
create a class that inherits from SystemBase
and make your logic in there
no game objects
ok, so i dont need to attach my script to a game object then if i do that, i can just let it rot in some folder somewhere?
oh also more importantly, how do i do that?
same way you create monobehaviour
I suggest to keep looking through manual
it has examples
this makes sense, but the manual ended after one page, with no examples, i tried searching around for the rest of the pages of the manual, but it appears that they have scattered in the wind, or atleast they are evading my grasp
ahem
you just keep going through each page kek
oh those things, i didnt realise they were pages...
but judging by this im gonna make a wild assumption from what ive read so far, and say ComponentSystem?
something like ```csharp
public class whatever_name : ComponentSystem
{
stuff here
}
SystemBase
oh ok!
fascinating, my no error code has suddenly gained quite a few errors, but they look fun to debug, thank you so much!
this is gonna be yet another stupid question, how do you run the for each of the entities thing, as it seems most info about it is nolonger working, i would assume outdated judging by how most info is from 2020, and the documents in the manual thing are equally unhelpful, being quite vague in description. Infact the best information about it i can find would be in the error message which tells me to either use schedule, scheduleparallel, or run, but if i dare do any of these it gets even angrier, how odd
manual is up-to-date
yes, but the manual is super vague
sorry i phrased things weirdly
ive already been there, nothing there helps me, the more i follow the guide, the less things work
it seems that you need to have schedule, parrallelschedue, or run, none of which i am allowed to use for unknown reasons
im guessing im missing something extremely obvious?
To execute a job lambda function, you either schedule the job using Schedule() and ScheduleParallel(), or execute it immediately (on the main thread) with Run()
this is from manual ๐
curse it ill screenshot it
sure one bit is cut off, but that bit never raises any errors
also ignore my snake_case i know it isnt proper c sharp style, but i find it hard to read CamelCase, dont know why i do, but i do
I can see an error already, kek. Hold on, a bit busy
it's ok, take as much time to do whatever, im in no hurry
well, you need to add WithStructuralChanges()
But that exact thing is told to you by error you get if you run
Errors in ECS are really helpful
so, pay attention to them
there are so many safety checks inside
it will shout on you on literally every possible error
oh ok, lesson learnt, and when do i do teh with structural changes thing, and are there any things i need to pass into it?
if you do structural changes, you need this attrubte
and also need to Run
as structural changes can only happen on main thread
im really feeling like an idiot at the moment, what on earth are structural changes, and which attribute, on which one of the things?
in this case you are allowed to do managed code inside your lambda
WithStructuralChanges() is attrubute I talk about (could be wrong terminology)
structural changes are described in manual ๐
oh, i clearly have not gotten to that point in the manual yet, im only up to page 3 so far, but thank you!
ok that makes sense, i still dont know which one needs it, but atleast it is a good starting point for research!
ok from reading it, it seams somthing somewhere of somekind needs it, i still cant work out exactly what, but im getting closer
also the more i read, the less and less this seems like an attribute, the more it seems like it is a method of some kind
how you attach a method, to a thing i have no clue (i dont actually know the technical name for the thingys that contain and are and exist and stuff, im sorry im very stupid lol)
but this is a fun mystery!
also according that that, there are no structural changes in my code, which raises the question, why do i need the structural change thing anyway, it definitely seems required, but as to why, the manual seems to disagree with the reality
creating entity
adding/removing components
also changing shared component
are structural
destroying entity also
oh, ye that would make sense, sorry i am an idiot, im up to page 5 now, and still no sign of anything to do with structural changes, so i hope i find the page soon
i did manage to find another page that described the for each entity thing, but that made no mention of structural stuff anywhere sadly, i hope i find wherever this knowledge is kept, it seems to be well hidden
you instantiate entity
it's creating
yes, that is what i agreed with?
aha i found something about structural changes! It is super vague, and i dont know how to use it, and it has no examples, but atleast it is confirming the existance of it!
they get this small paragraph, and are not mentioned anywhere else judging by my research, so imma trial and error this thing all over my code until i figure out what it does, and how to use it
One of the things i admittedly struggle with when moving away from Transforms and gameobjects etc some of the helper methods we take for granted for example transform.RotateAround() etc, things that involve quaternions and matrices that i have no idea the math behind
by default all ForEach lambdas are bursted and threaded
and you can't do structural changes with that
so you need to disable burst and enable main thread
Obviously we can pick up some little tricks like converting a position or rotation from global to local space etc etc, but when there are more complex transformations required the maths is a bit of a black box
oh ok that makes sense, how do i make it so that it can do all that?
or you can simply do it inside OnUpdate without ForEach loop
ForEach is only required if you need to access entities
in World
nothing stops you from doing your own bookkeeping
inside System
ok, how do i do any of that?
For example if you google 'unity rotate a point around another point' or try and find the code behind transform.RotateAround you just get a ton of references to transform.RotateAround..
cause as far as i was aware from reading the manual then the for each loop was the only way of finding entities...
Would be nice for Unity to start providing some learning materials around how to do this, in order to transport some of this logic into bursted jobs
that would make sense, except how do i book keep things that do not exist yet?
ECS API is tough xD
you should read conversion workflow part
in manual
yup lol, i just wanna istantiate 1 entity that exists, and i have to deal with trial and error due to there being no documentation on the structural changes thing
this is how you are supposed to create entities
i know, i read that part, about 5 times now, perhaps more, i understand how to do it, and i have done it, but when it comes to instantiating, it breaks the entire thing
you cant convert while instantiating, because there is nothing to convert about it
yup i know that, i dont see how that helps me, sorry lol, im a bit of an idiot
you can do it inside OnCreate of System
once again, i dont understand how this helps me with istantiating, im sorry...
just tell what you want to achieve in the first place
I suggest you to start learning how manual suggest - with rotating cubes xD
i shall probably try that, but what i am trying to achieve currently is creating one entity with a few components like colliders and rigidbodies, and then istantiate that one entity a bunch, i have already achieved the creating of the 1 entity, it is the instantiating part im stuck on
they are not easy to make
oh, then i somehow stumbled my way into doing it then, i dont know lol
anything related to physics is advanced
oh
well i now that somehow i do have the physics stuff, i no longer need to touch them, all i need to do, is create more of them
luckilly there are so many tutorials everywhere on how to do instantiaing with dots, but all are out of date sadly and no longer work
try moetsi dots manual
that is multiplayer and stuff, i dont want to touch advanced stuff yet, i just wanna duplicate stuff, im really an idiot im guessing
oh is it, ok welp ill go through it, thank you so much, sorry you are having to put up with my stupidity
so far i have managed to heavily distort the dots text in the entity hierarchy thing to the point of almost unreadability, i cannot appear to replicate this amusing bug, but ill still consider it a personal win!
and it seems when i add my first entity i drop from around 400 fps to 10 fps, so quite the slow down so far, but im certain i must be doing something wrong to get such a performance drop
can't help until you show what you do
i dont know what im doing, as such i cant show you what im doing, as such i cant be helped by you, but still all the stuff you have said has been very useful, and shall continue being of great use
haha i got it working!!!
this clump of ominous spheres might not be the exact result i wanted, but hey im just so happy that my instantiating script works!!!