#archived-dots
1 messages ยท Page 263 of 1
i might even consider removing CopyMode from authoring
and into the same part as instantiation
to avoid adding it to server
but anyway this here isn't that big a deal, pretty standard probably
the cool stuff is just being able to pick skin mesh renderers in scene view and returning the entity
it just ties the whole thing in
yeah, that's cool to be able to do that. I don't have much trouble in my current project but in another it was impossible to work without an entity picker. I'm still perplexed that Unity hasn't done anything for it.
with an entity picker everything seems so much more solid
so you have a gameobject/skinmeshrenderer loosely tied to an entity?
with no presentation entity, how are you handling animations? I mean there's no downside on putting an animation IComp on the main entity but I rather keep the archetype clean from anything presentation like
main entity has the animator
for my client/server architecture the client is nearly entirely presentation so this is fine imo
saves an extra copy between things
if anything i prefer to move logic to separate entities
Do you have any advice on how to debug jobs, since we can't step through like normal code, mine compiled but the output is wrong so i have logic error in execute function
why can't you step through them like normal code?
you can either turn off burst and debug like normal
or turn on native debug mode and hook up a native debugger and debug like normal (requires vs not rider)
damn, since the new VS plugin where for some reason Entities and Collections are added to the main project, VS is choking hard on every line :/
yeah i've been trying to find a way to remove that
bit annoying
dont want to see 2134 new projects in the side
i already have 12356234 of my own
My watch tools don't show anything in the unsafe list for some reason
oh you mean the contents?
unity setup debug viewers for them
[DebuggerTypeProxy(typeof(UnsafeListTDebugView<>))]
so they should work
no idea about vs watch tools (assuming vs)
i haven't used vs much in the past few years
literally only time i pull it up id to debug native stuff
hm, doesn't seem to have anything to do with the actual "Visual Studio Editor" package. Entities and Collections are created nonetheless.
how does that attribute work
it's this setting here
unfortunately you're own packages in the /Packages/ folder won't generate if you turn it off
i have turned this all off
did you delete the actual project files
yeah, deleted everything a bunch of times. csproj and sln files
I'm actually not sure when this started. I think it did with Unity 2020.3.33
but that doesn't make any sense
hmm interesting
i tested this just last weekend
and could stop entities/collections generating projects
but since 90% of my code exists in the packages folder it doesn't help me much
ahh, maybe it has to do with the asmref
hm, I have them all in Assets/Plugins right now. Question is, where could I move them?
do you have any code in Packages/
?
if not put them in there and it might hide it for you
directly in the folder? no, i'll try
yeah, wanted to do that if all fails.
I hope that's not the only way because frankly, having to add packages to an asset is annoying
still better than the editor lagging though
well, problem solved at least ๐
look at my project list ๐
question about job handles. Is there any difference if you write Schedule(Dependency) or just Schedule() which uses default then?
daaaym
You are using Rider, right? Is it also slowing down like crazy?
Now I can't peek into entities methods and see the code. There's always something new breaking ... Previously it was aaaall working so fine. Then I couldn't see the decompiled code anymore, just the signatures. Now I can't see anything anymore. How is this even happening...
nah no lag like this
once it's cached it's all fine
performance is why i moved away from VS in the first place
but features is why i stay with rider
ah cool, VS takes like 20 seconds to evaluate a new line of code if it's correct with collections as project
well that sounds horrible
Yeah and VS is so expansive on top. I mean, I got and need it for work. The pricing looks pretty good for 1 year of Rider
do you have resharper too or just base?
resharper is only a thing for VS
all those features are built in (and much faster) in rider
i used to use resharper but it slows down VS even more
(work pays for my copy though)
yeah, also what I noticed with resharper in VS
rider gives like discounts for future years, 20% second, 40% off third onwards
nice but kind of wish that 40% off was just the default pricing
be so much easier to recommend
yeah, 40% is quite the discount
at least for the individual pricing
make the companies stick with you to get a discount
true, I don't understand why individuals are milked so much anyway. companies should make them enough money.
to be fair, rider is cheap compared to other software nowadays
so i got my polygon tester working but just curious about if i am doing it the best way.
currently i loop through my polygons on the main thread (Since theres only a handful of them)
the job takes the vertices of polygon A and polygon B (as a paralleljob for each vertex ) and runs the test in my main loop
var job = new PolygonPolygonOverlap(poly1, poly2, flag);
var handle = job.Schedule(poly2.Verts.Length, 1);
but im calling complete on the very next line, some of these polygons have thousands of vertices to check, am i not getting any benefit by calling complete on the next line ?
@muted field you certainly lose the advantage of not blocking the main thread but you still get burst and parallel execution.
so whats the alternative? schedule it then poll in the update method to see if its complete? @solemn hollow
the code that needs the result should schedule another job with a dependency on this PolygonPolygonOverlap
what would that job do tho? be empty?
if you don't need the result of your job then i guess you don't need to do anything. just let it complete at any point later in the frame.
i thought u need the result for another operation that should then be done in this next job i spoke about.
btw are you using ecs or just monobehaviours with jobs?
i was reading the result on the main thread outside of the job
straight after i call complete atm
like this:
for (int i = 0; i < _polygons.Length; i++)
{
for (int j = 0; j < _polygons.Length; j++)
{
if (i == j) continue;
var p1 = _polygons[i];
var p2 = _polygons[j];
flag[0] = false;
var job = new PolygonPolygonOverlap(p1, p2, flag);
var handle = job.Schedule(p2.Verts.Length, 1);
handle.Complete();
if (flag[0])
{
Debug.Log("True");
result.Add(new int2(i, j)); // these 2 polys overlap
Debug.Log(new int2(i, j));
}
}
}
@solemn hollow are you saying this is basically going to be on the main thread all the time ?
yes that will be main thread
thats the general way for doing it in monobehaviours
if(!dependecy.IsComplete)
return;
dependency.Complete(); // this is still required to finalize
ah okay. is there a way to collect all jobs and schedule at once aswell im fairly sure i saw an example of that at one point
you should schedule individually
but you can collect all handles and merge the handles into one
JobHandle.CombineDependencies()
doesnt that only apply if jobs depend on others, in my case they are all stand alone and dont rely on others
JobHandle.CombineDependencies()
doesn't add them dependencies as each other
it just combines all the handles in to 1
so that you can wait on them all to complete
bruh
did Hybrid Renderer learn how to render objects without Companion GO?
looks like it did
omg, feels so bad
I need some kind of a way to draw lines. Gizmos for player, to see where characters are going.
Without Aline it feels like such a pain
since I need game objects, which I hate at this point
? thats how hybrid renderer always worked
its never rendered game objects
oh
Ahem, very weird situation
So, basically I instantiate new GameObject() in my authoring component
aaaaand, this game object for some reason only exists when I open subsystem in edit mode
So, I launched game, no game objects
I turned on edit mode and they suddenly exist
How do I avoid it?
what component is on it
empty
I use it so I can add other game objects with components on it
through prefabs
dstManager.AddComponentObject(entity,
new CompanionGameObjectComp() {Companion = new GameObject()});
well i dont know what part you think is setting up a companion object
looks like this
that gameobject ain't going to exist
does any of these native containers have a wrapper for readonly ? like normal collections have IReadOnlyList etc?
how do I make it exist, then?
companion objects are created when unity finds one of these components
{
typeof(Light),
typeof(LightProbeProxyVolume),
typeof(ReflectionProbe),
typeof(TextMesh),
typeof(MeshRenderer),
typeof(SpriteRenderer),
typeof(VisualEffect),
#if PARTICLE_SYSTEM_MODULE
typeof(ParticleSystem),
typeof(ParticleSystemRenderer),
#endif
#if SRP_7_0_0_OR_NEWER
typeof(Volume),
typeof(SphereCollider),
typeof(BoxCollider),
typeof(CapsuleCollider),
typeof(MeshCollider),
#endif
#if HDRP_7_0_0_OR_NEWER
typeof(HDAdditionalLightData),
typeof(HDAdditionalReflectionData),
typeof(DecalProjector),
typeof(PlanarReflectionProbe),
typeof(DensityVolume),
#if PROBEVOLUME_CONVERSION
typeof(ProbeVolume),
#endif
#endif
#if URP_7_0_0_OR_NEWER
typeof(UniversalAdditionalLightData),
#endif
#if HYBRID_ENTITIES_CAMERA_CONVERSION
typeof(Camera),
#if HDRP_7_0_0_OR_NEWER
typeof(HDAdditionalCameraData),
#endif
#if URP_7_0_0_OR_NEWER
typeof(UniversalAdditionalCameraData),
#endif
#endif
};```
in the subscene
if you want a gameobject to put something on, just create it at runtime
but I create me own companion game object system
so what?
soon as you close your subscene this game object is delete
new CompanionGameObjectComp() {Companion = new GameObject()});```
based on your questions earlier i think what you want to do is spawn your gameobject in the first frame the game is running and add it as a child to the companion. dont do it in conversion
how can I create it outside of subscene then?
just have a system create it
sry earlier i assumed you are already doing it in a system since you asked how to query it
well, I kinda did in a mixed way kek
I add prefab through authoring
and then convert it to other GO through system
var go = Object.Instantiate(create.Prefab);
EntityManager.AddCompnentObject(entity, go);
}).WithStructuralChanges().Run();```
but all that assumed I have companion game object to attach to
yeah, I get the idea
I just didn't realise
that detail regarding GO being deleted in subscene
yes hybrid workflow with subscenes is not really intuitive atm
I hope I won't need hybrid at all
why do i suddenly not have access to Schedule function ?
what is T?
public void Add<T>(in T job, Action<IJob> callback = null) where T : IJob
hmmm
I create game objects in systembase now
still they are inside subscene
public partial class CompanionGameObjectAddSystem : SystemBase
{
protected override void OnUpdate()
{
var em = World.EntityManager;
Entities.WithStructuralChanges().ForEach((Entity e, in AddCompanionTag tag) =>
{
GameObject go = new GameObject();
em.AddComponentObject(e, new CompanionGameObjectComp() {Companion = go});
#if UNITY_EDITOR
go.name = tag.Name.ToString();
#endif
em.RemoveComponent<AddCompanionTag>(e);
}).Run();
}
}
Maybe you need to manually assign them to a different scene? You could create one from code. Or maybe there is a way to get the parent scene of the subscene.
I just learnt that game objects can belong to subscene
I have little to no idea how to assign them to one xD
didnt u say u want to add your gameobject as a child to the companion? i dont think its a good idea to move the companion out of the subscene. why do u need to do this anyway?
first things first, I need to add game object
empty as base
I need it to have access to Unity components
in this case
it's Line Renderer
nah, moving away GO outside didn't help
hmm
make a prefab with a linerenderer and spawn that instead of an empty GO
I do have that
and in your query get CompanionLink
then you have access to the transform of the comapnion. add your spawned GO as a child
with all other prefabs like this
here's the problem
there's no CompanionLink
kek
huh
It's not created for my entities
which is exactly why I try to create my own here
var em = World.EntityManager;
Entities.WithStructuralChanges().ForEach((Entity e, in AddCompanionTag tag) =>
{
GameObject go = new GameObject();
em.AddComponentObject(e, new CompanionGameObjectComp() {Companion = go});
#if UNITY_EDITOR
go.name = tag.Name.ToString();
#endif
var currentScene = SceneManager.GetActiveScene();
SceneManager.MoveGameObjectToScene(go, currentScene);
em.RemoveComponent<AddCompanionTag>(e);
}).Run();
This also didn't help
CompanionUpdateTransformSystem
check in there
maybe you just didnt reference the assembly?
or is it internal now :S
I do have access to it
I used tertles trick
with internal
point is, it's not created at all
Hybrid Renderer renders mesh directly
without creating GO
ah yes you need to trigger the creation with one of the hybrid components i guess...
you could add an empty spriterenderer to trigger it and later delete it. until you find a better solution
or you write the transform sync system yourself
I do have it
my GO are being deleted/or not created
I'm not even sure
thats strange. i do spawn gameobjects too cause i need stuff from the 2D animations package. no problems there
here my game is running with the gameobjects spawned without the subscene beeing in edit mode
how do you create them?
huh why cant i post code? 0.o
sry new to this discord
what are the code tags here?
im on a mac keyboard. need to search a bit ๐
Entities.WithNone<IsBootsTrapped>().ForEach((Entity entity, HybridArtManaged hybridArtAComp,in HybridArt hybridArt) =>
{
hybridArtAComp.artInstance = MonoBehaviour.Instantiate(hybridArtAComp.artPrefab);
hybridArtAComp.artInstance.name =
"(" + hybridArt.rootEntity.Index + "," + hybridArt.rootEntity.Version + ")" + hybridArtAComp.artInstance.name;
ecb.AddComponent(hybridArt.rootEntity, new HybridArtChild
{
childEntity = entity
});
if (hybridArtAComp.artInstance.GetComponent<Animator>())
{
hybridArtAComp.animator = hybridArtAComp.artInstance.GetComponent<Animator>();
}
ecb.AddComponent(entity, new IsBootsTrapped());
}).WithoutBurst().Run();```
You can also copy entire code pasting string from #854851968446365696
thanks!
Dont be confused by the extra stuff in there. i just split up the component into a slow managed and fast unmanaged one
the managed component contains the prefab and the reference to the instanciatedGo
maybe the subscene had to be reconverted
maybe
Hello, do anyone know how to make the CopyTransformToGameObject system ??
Can't you just look at the existing system and copy that?
(what are you trying to achieve?)
oh man, feels good that it works
feels bad that I spent almost hour on it
If the question is for me, I spawn at runtime an animated game object and animate it that works but I can't make the animated game object follow the entity. (I can make it with a custom system but not with the unity system)
add CopyTransformToGameObject component
add Transform to entity - EntityManager.AddComponentObject(entity, gameobject.transform)
that's all you really need + LocalToWorld
main thing is just add the Transform so it can be accessed by TransformAccessArray
Thanks, I was just adding Transform component, not the gameobject's transform...
i thought you were trying to re-implement the bahaviour or something which is why i suggested looking at system
Is there a way to run code only during frame/tick of adding component?
Basically, I want system to only run whenever X component is added.
And another system only to run whenever X component is removed.
And either must only run once per entity.
I do have an idea how to do it through adding another component Tag, but I wonder if there's built in way
that would be a reactive system which is what your are think about. the only difference is that the tag component is supposed to be a private ISystemStateComponentData in the system.
hm
Unity is also not supposed to destroy entities that have remaining ISystemStatemComponent so that the system has a chance to do it's clean up when the entity is destroyed.
nah, I don't really need this one
I just need to be able to react of add or remove
so I can clean up LineRenderer points
or create them back
So I assume this is ready solution by you?
yes, but don't take the first post, there are some improvement done later (like detecting tag components) and also other people wit their own implementation.
should be good then but was not done in entities 0.50 so maybe some adjustments needed.
Sooooo
I want to make such game, where there would be some X amount of rooms.
And every character can travel freely between them, depending on some rules.
On screenshot you can see how it kind of supposed to look like.
Basically star systems. In order to travel between them, character must get to the edge of a system (which doesn't limit character from going further btw), that points into another system, to which character wants to travel.
What I'm asking for?
How can it be done through code?
Do I just make those rooms in world space?
Or maybe some other tricky way? Which hopefully will be simple enough in order to keep AI travelling between systems freely.
In the end all rooms (systems) are same:
Star in the middle. Planets around it.
You could make a world per room. whenever an entity enters a portal you send it to the other world.
Is it efficient though?
Goal will be around 100 rooms
Hello there, I really need a help, why does the render mesh not working? it doesn't render a mesh and it's material after I spawn randomly on that area.
I dont know your needs but id imagine you only want to simulate the room where the player is with the highest level of detail. The other rooms could probably run on a lower framerate? thats why i think worlds could be a good fit since you could update them in diffrent rates.
no, my goal is to simulate everything in detail.
Whole world must be simulated fully
isn't that what subscenes are supposed to be used for
that's what the whole megacity, I think I can't remember
I don't know, it must be pretty easy to load and unload and manipulate subscenes because thats the whole point
well, loading/unloading yes
but here the thing
I want world to be simulated fully
every tick
if player is in system 0
System 100 should be simulated in same detail
not to be a party pooper but that may not be always be possible
it depends on what your doing if its just data then I don't see why you couldn't(depending on how much data)
you don't need to render all the system, and calculate phsysics etc
just separate the data you need from the data you don't
and then have that as a background sim that's running all the time
and thats where a background world comes in handy
yeah then load the systems when the player enters them using the data from that background sim
out of interest, in your use case why does a 'background' world help here
you can't run worlds in separate threads
to me all it sounds like is you're adding overhead
first things first, there are no physics in game
It's all numbers basically.
Which makes sim kind of fast
well its probably best just to use a thread or several in the current world then, I just meant it as something you calculate all the time in the background
I can imagine how to do all that
in case where I literally just create rooms in world space
in huge distance from each other
but I worry about float precision
which will quickly degrade, if I try to follow space physics regarding distance between systems
well there are tricks for floating point precision
i could run a much cheaper version of systems on the background world. like an AI that is gathering Food could just tick alot less but gain more food per tick. that AI could also skip alot of systems since it would also never have to check whether it is in player combat etc.
but do you even need to bother with that if the systems are so far apart then just treat them as separate solar systems
This game is about living in space.
So in order to jump between systems, you use some kind of FTL drive or smth, which makes big jumps from star to star.
Meanwhile if you simply try to fly from star to star without that drive, you should spend hundreds of years.
Which I'm not sure if it will work out if I simply drop those rooms in world space
if your not using things like physics etc, if your talking about things like trade you just abstract and simulate things
yeah, only things like that
and I ask, how I can do it kek
you don't need to literally be travelling between the systems, you just need to pretend the player is
yeah, I know
but I don't know how
one thing is to simply teleport player changing his trasform from 0,0,0 to 100mil,0,0
the other is to change his subscene or smth
like you can calculate the distance, and how long it would take to travel etc and create the environment around the player according to that
I'm pretty sure thats how No Mans Sky does it
hmm
How to treat those systems
so all AI in them
can interact with each other
no matter in what system they are
so AI in system 0, which is furthest from system 100. Can always know there's another AI in system 100. And if required, will get the idea, how to get there.
first solution: rooms are literally apart from each other in same world space.
well if your talking about space which I'm presuming is really really big, you also have to deal with the time lag of information travelling from systems
nnnah, it's all just details
Which I don't need atm
I need base
for this all
the way I can create those system in the first place
on which everything else will be put step by step
so you say you have 100 rooms
but how big is each room
and how much is in each of them
personally I think you try should start with one system first and simulate that, seeing what data that has then try adding another
I already have one system kek
ok cool, if you can simulate one you can simulate two
depends
some room will be big
another will be small
you know, like how certain stars have 10 planets
while other just 2 planets
that's irrelevant
well it matters a lot
if they're 1k x 1k vs 100x100m
you can store a lot more in an area
before floats become an issue
well, it's more like distance between them which is issue
room itself is not that huge
how do you deal with the distance between planets
If I wanted to exclude all entities with <bastian> component tag from a small ITriggerEventsJob query: https://pastebin.com/aTCjfpQk Is there a way to do that, or do I need to check each Entity during the job for the <bastian> component tag?
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.
need to check
ty ty, tertle is a boss
there's an exclude thing in the entityquery None = new ComponentType[]{ typeof(Frozen) },
doh
well, I counted
On average those system are kinda 150x150 in size
but again, it's distance betweem them that is supposed to be huge
but like I said the distance doesn't need to actually exist the solar systems could exist as tables in a data base
well yeah player also should be able to fly indefinetely in one direction
or at least, have illusion of that infinite travel
ok, it's irrelevant detail
I still don't get, how can I make it work
one should not be able to fly from one system to another without portal
so if I put 2 systems in same world space
it kinda will be possible
WAIT A SECOND
what if I use Z axis
yeah that's pretty easy to do, I know one game moves the solar system around the player instead of player moving around the objects
anyway who will really fly for the years it takes to fly between the systems
this one is not the case
it's more like that when coordinates will become millions
and whether there's simply a better solution
than just dropping systems in world space far apart from each other
yeah you have to stay within a limit for that
you can delete objects that are to far and reset the player to zero
I've seen lots of ways of dealing with the floating point errors
meanwhile I need to keep simulation going
the objects that you see don't need to be the objects that are simulated though
Hello There! So, I'm trying to make an entity but it doesn't render (doesn't show in Scene Window and in Game Window) the mesh with material by using RenderMesh and RenderBounds. I'm trying to create using pure ECS which is EntityManager.CreateEntity(), and I made it with EntityArchetype.
// This is running on Start Method in MonoBehaviour Script
entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
minionArchetype = entityManager.CreateArchetype(typeof(LocalToWorld), typeof(Translation), typeof(Rotation), typeof(Scale), typeof(RenderMesh), typeof(RenderBounds));
// Followed with instantiating
I'm using 2020.3.30f1, Latest Hybrid Renderer, Standard Built-In Unity (Not URP/HDRP), I'm stuck at this point.
I'm trying to find out why on death, some entities drop multiple loot drops. 1) Has anyone experienced something similar? 2) Is there a way to print the name of an entity's to specify which one it is in relation to similar types (maybe an index)? If so, I could see which one is the offender to get close to the source of the bug. (Oh I can just entitycomponent data to get a specific index. Still warming up. I think I got this dots now.)
I think .5 requires one of those renderers HDRP or something
just don't do this
create your entity with conversion or if you're stubborn at least use the hybrid utility to add all required components - RenderMeshUtility.AddComponents
you're missing a bunch of components
https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.50/manual/runtime-entity-creation.html
Ah ok, I'll try with different method then
@astral parrot But as GoodNewsJim already said the built in pipeline is not supported
I am trying to do a simple "random" rotation for an entity like this:
float3 axis = new float3((float)math.sin(time), (float) (1d - math.sin(time)), 0f);
rotation.Value = math.mul(rotation.Value, quaternion.AxisAngle(axis, deltaTime * rotationSpeed));
But the rotation does seem to effect the scaling of the entity as if it was non uniformly scaled. Is this a bug?
I know slow and arduous ways to do random numbers in DOTS, but is there a fast function?
finally after a long struggle, It does works, thank you!
but still is it necessary that Hybrid Renderer along with ECS will be requiring URP/HDRP pipeline in the future
Turbo makes games has a 15 minute video on making randoms, so it ain't easy, so I won't useit for now: https://www.youtube.com/watch?v=s-nr9EMmhfo
๐ Download the project files from this video: https://tmg.dev/ECSRandom ๐
๐จโ๐ป Code featured in this video: https://tmg.dev/ECSRandomCode ๐จโ๐ป
๐ป My Game Development Setup: https://tmg.dev/GameDevPC ๐ป
๐ See below for time stamps ๐
- 0:00 - Random in Unity ECS
- 1:15 - Basic Use of ECS Random
- 3:28 - How ECS Random Works Behind the Scenes
- 4:08 -...
This is a simple default cube rotated by 1.3 around the X axis. The Transformation system seems to be broken ๐ค
Can I somehow disable drawing of certain entities?
Or maybe exclude them from being used by certain systems?
You can disable them by adding the disable component
no, I don't want to disable them
I only want to disable them for certain systems
primarily drawing
Afaik you can only do this by changing their components so the stop matching the systems queries
If you wrote the system yourself you can have a IgnoreBySystemX component which you add to the entity and exclude in the query
There's a disable for rendering also
I know, but this one is for hybrid renderer
in other words
I have entities
in same space
but on different levels
and when I switch from one to another
I need to stop drawing entities
that don't belong to level I switched to
maybe this can be handled by scene culling mask and multiple cameras?
I forgot that its a quaternion and I cannot just set one axis on it. But the problem with my rotation system still stays. I have the suspicion that the quaternion transformations are piling up rounding errors as the issue gets more extreme the longer/faster it rotates
Is there a way to "normalize" a quaternion?
how exactly are you rotating it?
float3 axis = new float3((float)math.sin(time), (float) (1d - math.sin(time)), 0f);
rotation.Value = math.mul(rotation.Value, quaternion.AxisAngle(axis, deltaTime * rotationSpeed));
Thats the rotation code
its because I want a random looking rotation
I first tried rotating it by assigning some random sin, cos values to all 3 axis via EulerXYZ
well
But randomly shifting the axis and rotating around it leads to a smoother result
maybe you should normalize axis first?
I just thought that too. And yes you are right ๐ Thx
How can i inspect the generated code for IJobEntityBatch jobs?
Im interested in how the LimitToEntityArray overload works
nvm found the codegen but it seems like IJobEntityBatch doesnt generate code
This is more of a design question with dots... If I wanted to add an indexing number on stuff dropped in a parallel job... I was thinking of throwing in a huge random variable and when indexing them later... But there's always the outlying chance of a conflict...
Say you had 3 parallel processes and you wanted to add indicies to them... How is that done? Is it something DOTS/ECS applies to every entity: A Unique qualifier identifier?
Right now if I make 3 lasers, they're all named laser, how do I know they're different? Like a memory address or anything would be good. Can someone help?
entityindex is just that. unique to every entity
thank you
Well i need to correct myself. The index could in theory not be unique
because you could create a new entity which gets a recycled index
yes with version it is unique
You solved a problem I had for about a year lol
so Entity itself is the identifier u need
Sometimes my lasers will hit a ship at the same exact frame, triggering a multi destroy event. I want to only drop its items one time, and not multiple times. It is tricky though... I tried complicated lists to make sure the same thing doesn't drop twice, but once again, that is done in a parallel environment so statics can't be used... Its a weird situation to think about. It's like a software architecture puzzle: https://youtu.be/895VPFsumKM Maybe when dropping the loot, I could verify in a special non parallel processing .for each?
Proof of Achievements no other gamer has: #1 world ladder Starcraft #1 World ladder Broodwar, #1 World ladder Warcraft3 at 200-0, first to 1500 wins Warcraft3, #1 World Diablo2 Hardcore experience ladder, #1 score Pittsburgh without Turtle Tip 1989 Nintendo World Championships, #1 world C&C3, #1 World SC2v2/l https://www.crystalfighter.com/achie...
you have a race condition. try to linearize it some way. you can write which ships are destroyed to a native container that can handle it and then process the destroy events elsewhere in a single thread or in parallel with a fitting native container like NativeHashMap where the destoryed entity is the key.
The multi destroy happens because my laser arrays are side by side like a dual or quad cannon and hit at the same time. Multi trigger events are not the bug.
I have a trigger event that adds a componenttag<bastian> to it.
easy way to do it:
tag the ship that gets destroyed by adding a component. let a system run on all entities with that component that is handling the drop of loot.
Then later I run a SystemDestroy
yes. or you combine those systems
Yes, correct, I too thought that would be the proper way to do it, but each has their own problems that would not allow it to work.
I can drop an excess amount of items or none at all. I have a lead, but it's very weird.
DOTS/ECS makes you think weirdly, and since it is non standard, you start even second guessing what you do know.
Cuz if you can't be sure what the issue is... You get a bit open minded about solutions and such.
i assume your issue is that you handle damage events right away in a TriggerEventJob and drop loot then and there which gives u a race condition. Marking all entities that should die this frame and then looping over them once gets rid of that problem
you just need to make sure the order of your systems is right
I think my Issue was using Remove instead of RemoveAt lol
Like I said, you can trip over stuff you should know when you're so busy stretching your mind to understand parallel processing.
tagging entities requires a structural change so -> not good
The problem is: If I tag it to die and drop loot in parallel: And 2 or 4 lasers hit, then it does 2 or 4 drops
It is common since lasers are aligned exactly next to each other as a space ship shot.
an entity cannot be tagged multiple times with the same component so that cant happen.
true but is it a problem if once every x seconds a ship is destroyed?
You can indeed add many of the same component to an Entity
no that's not possible
maybe you are confusing it with DynamicBuffers
well, no but the solution is quite hacky
I think you guys gave me enough info to solve this.
tagging is not needed. just write it to a NativeList.ParallelWriter or smth
Adding Components to trigger Logic on Systems is considered hacky 0.o
- Since Triggers and Obsticle collision does not happen in parallel... I can have an array list of things hit this frame.
the solution to this specific problem is hacky
- I will populate this list in my main Singleton global file of statics.
i prefer tagging as a quick solution because i dont want to pass nativeArrays between system boundaries
- On init of the frame, trigger will will init List triggerlistEntitiesDead=new List<int>(). Obsticle the same.. And when issuing a destroy, will cycle through those...
Now this assumes Trigger/obsticle run synchronous themselves and non asycnrhonously parallel.
tagging during runtime is considered malpractice and it's abused or encouraged way too much
To be honest I don't even have any solution at the moment
well tagging is the only way to not have to poll with systems atm. so for infrequent events thats what i am using until disable/enable components is out
I tried Manarz way already months ago... It has one problem to the next...
I may be closing in on tying up the loose ends tho
I don't mind if the first iteration of my game is tied together with duct tape and bubble gum as long as the design is refactor friendly.
as mentioned above. write destroyed entities to a NativeList.ParallelWriter, NativeQueue.ParallelWriter or NativeHashMap.ParallelWriter when you don't want to deal with handling multiple entities in a list and then process them in a single thread. If you want to have good refatoring split logics because your ITrigger is doing way too much at once.
Thank you enzi. I will study those.
the faster you get comfortable with this the better your code and architecture will be
Are there more memory things that can be changed in the parallel environment?
I remember catching wind of those about 8 months ago...
what do you mean with memory things?
Like if I have a parallel thread
and I'm writing to anything...
other than a parallel EntityCommandbuffer
I didn't know I had anything I could write to
well, any NativeContainer that has a ParallelWriter. NativeStream is also great
fastest writer there is in parallel out of the box
can also read in parallel because of the logic how it splits writes
Could it do a running total?
I'd be excited if I had a counter anywhere.
2 questions: If it can write across multi threads, and when it reads... is it using lock / unlock? Or could maybe I miss data mid process because though it was safe, I was writing an index of something that got destroyed while checking it someplace else?
https://docs.unity3d.com/Packages/com.unity.jobs@0.50/manual/custom_job_types.html at the bottom is an implementation for a thread safe counter
kk ty
parallel writers for queue, list and hashmap use Interlocked. NativeStream has its own memory block for every thread
so no, nothing can be missed
also something I can recommend: https://github.com/Dreaming381/Latios-Framework/blob/master/Core/Core/Internal/UnsafeParallelBlockList.cs
Well I have a lot of reading material and things to try out. I am very much appreciating this. If I ever make bank, find me and you get to withdraw lol.
hehe, that's nice of you but you're welcome without any money ๐
You say that til I'm making World of Wacraft money ๐ Then you'll be like,"Thanks doesn't cut it buddy! If you a real funk soul brother, then cut me a check right about now!"
haha, well, when your swimming pool is overflowing with money I'm open for donations ๐
just dont scrooge mcduck dive into a big pit of coins ๐
Got a broad question concerning some AI problem:
Let's say i have an EntityQuery and a DynamicBuffer on each AI.
Each Agent now wants to read Data from all Entities contained in the Query and the DynamicBuffer (the intersection of them). If the DynamicBuffer is empty the query alone defines the targets to read from.
Should i loop over all Entities in the query and check if the DynamicBuffer contains the Entity or should i loop over the DynamicBuffer and check if the Entity Matches the chunk (/ archetype). Looping over DynamicBuffer gives me random memory access while looping over the chunks potentially loads alot of unnecassary data if the DynBuffer is small...
It feels like i should implement both methods and schedule the diffrent variants depending on the size of the DynBuffer. I am overthinking it right? ๐
It feels like i should implement both methods and schedule the diffrent variants
^ This ๐
Although I would bet that looping over the chunks is a lot faster
also depends on how big the DB is and if it's a chunk based DB or heap based one
sounds like you don't know the internalCapacity of the DB so I guess it's a heap based one
yes heap based. the main problem is that its a very generic Utility AI that is fully authored in the Editor. if someone wants his AI to look at 1000 targets he can.
For example you could let your AI evaluate all coverpoints. Or you could restrict it to only see Coverpoints in a certain range (where the DynamicBuffer comes in)
hm, some hash based pre-processing could speed the process up
iterating brute force is not good if there are no limits
creating a HashSet out of the DynBuffer on worker threads is expensive too though
well, do you really need a DB?
yes. its a bit hard to explain but i got a hierarchical Utility AI that writes intermediate considerations into DBs to later use them in higher up considerations
those consideration results are what is used as a filter
basically i need arrays upon arrays on entities
Are decisions spatial based? If you mention cover point then they are
alot of them are in the end.
often its just a direct vectorization of the distance. sometimes its a Overlapsphere gathering targets
ah so there is already physics involved? and those results are written back to a DB and later evaluated?
yep in some rare cases
i try to avoid physics
atm im really not happy with the physics package performance
you can write your own quantisation and spatial lookup, especially when it's on a grid. doesn't need to be a full blown BVH ๐
Make sure you turn off physics validity checks
physics is quite fast though so I don't really understand that part
sadly not a grid and im not experienced with physicsengines
That thing slows it down 10x
yes i know it should be fast but somehow it takes 7ms in my frame
How many collisions?
and i tried to reduce potential collisions
where can i actually see the collisions that are happening? didnt find a debugger for it yet
huh, yeah, that's too much but I think that can be optimised
tertle, you mean the integrity checks for physics, right?
the whole AI takes little over 2ms on mainthread and its basically all the gamelogic i have. 100s of agents possible... the physics is the main bottleneck atm ^
np ๐
ah i have those on
also make sure that leak detection and safety checks are off
yep those settings i knew
Jobs debugger + integrity checks nuke physics performance
Integrity checks add a bunch of extra stages it's super slow
is physics integrity setting new?
another problem i have with physics is that it basicly enters a performance death spiral since the lower frames i have the more often physicsstepsystem runs in a frame...
i rly need to get back to 60fps
Well that's just fixed update in general
yes but i guess that is why it takes a whole 7 ms
Can always run it at a different tick
they really need to have IJob and IJobFor inherit from another base interface so i can use callbacks ๐ฆ
my fancy idea of using call backs on complete now wont work ๐ฆ
Are your compile times really bad too? My iteration speed sucks
i did split everything into assemblies. no idea what else i can do
whats the difference between IJobFor and IJobParallelFor ? they seem similar to me
I job parallel for is the legacy version
yeah, they merged this. so IJobFor can now Schedule and ScheduleParallel. pretty confusing, not sure why it's still there
Not sure why they didn't remove parallel for yet
Basically they standardised schedule naming
And couldn't automate upgrade
if a newcomer queries IJob, the list is just overwhelming when it's not that bad actually
oh so dont use parallelfor then since it'll be deprecated eventually?
yes
so is JobFor.ScheduleParallel the new version of IJobParallelFor or JobFor.Schedule? Not sure why it has both schedules, the parallel version requires dependency even though i dont have a dependency for the job., so currently i just put default but makes me wonder if im using the function wrong
var jobHandle = jobFor.ScheduleParallel(arrayLength, batchLoopSize, default);
var jobHandle = jobFor.Schedule(arrayLength, default);
what does the second Schedule method do with a IJobFor ?
Schedule makes it run on a single worker thread as opposed to multiple
oh i see
yay got call backs working \o/
by any chance is this related to some disposal issue with my collections:
im not sure of the origin of this error, its happening when im not even in play mode which is odd
but it just started happening since implementing and playing around with the job system
never seen it
i have found the culprit it related to [BurstCompatible]
but not sure why. removing it from my job fixed the error
did you mean [BurstCompile]?
no i have [BurstCompatible] on the Execute method
according to the description it goes on public methods
yeah thats only used for unity collections auto documentation and unit tests
you dont need to worry about that on jobs
oh okay
hmm not sure whats causing the error then but it only started happening once i got my jobs working havent been working on any thing else for over a week in the project
anyone ran into an issue with platform's build asset configuration where if you define the Scripting Defines that you need in a build, the build will take all of the Editor's Player Settings Scripting defines instead? Not sure if this was a recent thing with the latest DOTS 50 upgrade... ๐ค
you mean the edit -> project settings -> player defines?
because yeah it will use those
the ones in build config are additional defines on top of the player ones
so you can specify a server or client build etc
so it's not supposed to replace the scripting defines in a build? ๐ค
as far as i'm aware no because it'd break a lot of things
huh seems kinda counter intuitive cause that means it sounds like regardless I need to edit the scripting defines on the editor for the build :/
i've never encountered a situation where i'd want to take defines out of a build
what is the use case?
so in the editor right now I define SERVER and CLIENT so i can launch both a server and client and do quick testing in the editor. But in a build I only want to build a headless server so I have a build configuration that only defines SERVER
For the client I have a build config that only defines CLIENT and I have a build pipeline that builds them out separately
ideally, I'd like for each build to not have both server and client defined so I could just have 2 separate builds, but if that wasn't the use case then I guess I need a different solution ๐ค
netcode does this by having UNITY_SERVER, UNITY_CLIENT and if neither are defined do both
so you just add your define to your specific build config
yea I think the build config isn't respecting that and is building both with CLIENT & SERVER
well it is
but thats what i mean by netcode
you don't specify UNITY_SERVER, UNITY_CLIENT in editor
so if none are specified it sets up both
damn, yea I guess I need another solution lol
ah cool...I guess i was lucky enough that i mainly use those scripting defines in the world boostrapper, much thanks @rotund token
I've dropped this now on github: https://github.com/enzi/Entities.Exposed most of the credits go to @rotund token ๐
wonder if these verbose naming scheme will survive 1.0
I hope not, but I also don't want my muscle memory for GCDFE to be voided either lol
@rotund token you said you are using or planning to use rayfire.
Are you using netcode in your game as well?
I've been struggling to think of a way to handle high detail destruction in a networked environment.
Having 100+ ghosts per destructible object isn't really feasible.
yeah i use rayfire just to precompute some fractures - nothing at runtime though
and i use netcode
i put a demo here a couple of months ago
very interesting
we have preproduction project that is heavily going to rely on destruction (cant say anything more than that) so this was mostly just a proof of concept in my own time of how i was considering tackling it
apart from that it'll have a layer of particles etc on top
and probably shader based superficial layer
Do you "spawn" each fragment as its own ghost when it becomes dynamic?
It's very interesting that you have some simulation on the server and some on the client
only the red ones
the red ones are ghost, the rest are client only
each whole piece has a bit field on it
and any number of those bits can either be ghost or client only piece
Interesting... so are the client pieces visual only?
If so, that's a pretty reasonable optimization.
For me the physics of the destruction is more about removing collision geometry.
Altering collision geometry at runtime is always a massive pain.
they still have colliders etc to exist in the physics simulation but disappear quickly when coming to rest
i don't think from a rendering performance i can leave huge amounts of debris around
let alone a gameplay perspective of it blocking players
so i leave X pieces that are the ghosts around for player to collect or whatever, and the rest will be client only in the same physics sim but disappear after Y
anyway that was basically how i did it in the proof of concept. was trying to limit rendering + network costs.
Hi, me wanna ask, is there a way to run a script when the GameObject is converting to entity?
What I mean is that run a script before or after converting to entity
You can use GameObjectConversionSystems in different update groups
There's groups like
GameObjectBeforeConversionGroup
GameObjectAfterConversionGroup
the actual loop looks like
{
DeclareReferencedObjects(conversionWorld, conversion.MappingSystem);
conversion.MappingSystem.CreatePrimaryEntities();
conversionWorld.GetExistingSystem<GameObjectBeforeConversionGroup>().Update();
conversionWorld.GetExistingSystem<GameObjectConversionGroup>().Update();
conversionWorld.GetExistingSystem<GameObjectAfterConversionGroup>().Update();
}```
where the system that executes IConvertGameObjectToEntity, called ConvertGameObjectToEntitySystem, runs in GameObjectConversionGroup
@rotund token yesterday we briefly talked about physics. disabling integrity checks helped a bit but its still not great considering it barely has to do anything. I suspect there are some physics interactions i am not aware of. Is there some kind of debugger i can use to show collisions etc? I know there is one for havok but is there for unity physics?
yeah theres a debugger for physics
PhysicsDebugDisplayAuthoring
public int DrawColliderEdges;
public int DrawColliderAabbs;
public int DrawBroadphase;
public int DrawMassProperties;
public int DrawContacts;
public int DrawCollisionEvents;
public int DrawTriggerEvents;
public int DrawJoints;```
chunk a gameobject with that component in a subscene
creates PhysicsDebugDisplayData
Thank you! I havent found it mentioned in the Documentation last time i looked.
After a couple attempt while finding the documentation, I got it, Thank You!
After looking at the physics debug im more confused than before. it seems like everything works as expected and i barely have any contacts that register. So my limited understanding of the physics engine is that the buildphysicsworldsystem is the broadphase looking for potential contacts. the Stepphysicssystem (narrowphase) then resolves those contacts. Why is StepPhysicsSystem taking 1.4ms when no contacts are to be resolved? Or does the Collisionfiltering only happen in the StepphysicsSystem so the broadphase is actually finding alot of potential contacts?
so i added this to my job: [BurstCompile]
But when i ran it through profiler the jobs take around 2ms which is identical to what it was doing before i added the attribute, so doesn't seem like its working? I'm using the mathematics library none of the mathf stuff so what am i missing here?
do i need to enable something some where aswell
not sure where it would say?
its safe to say its not using burst if it takes 2ms for such a small job aswell
it woulde be a greenish color and it would say (burst) behind the jobname
yeh no green to be seen
what can cause burst not to be used even with the attribute
i've never had the case where burst wouldn't work without throwing errors. sry.
where did you add the burstcompile attribute?
do you use rider by chance?
nah vs 2022
hm k. Rider shows when a function is burstcompiled:
oh thats kind've cool
i dont think i have any thing in job that would make it non burst compatible
well if you get any testjob running with burst first then atleast you can see burst is working at all. then it must be sth in your real job that is not compatible
Cant promise i spot the mistake but can you share the code?
are you getting warnings in your log
it seems to show my job in the burst inspector if that means anything
how are you scheduling your job
no warnings
im scheduling them like this:
for (int i = 0; i < _polygons.Length; i++)
{
for (int j = 0; j < _polygons.Length; j++)
{
if (i == j) continue;
var p1 = _polygons[i];
var p2 = _polygons[j];
var arr = new NativeArray<bool>(1, Allocator.TempJob);
var job = new PolygonPolygonOverlap(p1, p2, arr);
var jh = job.ScheduleParallel(p2.Verts.Length, 1, default);
}
}
i call complete in my job controller which is just some boiler plate stuff
yeh it has a list of verts in an unsafe list
is that why it wont burst?
no
i get this in console by the way
o_O
just appears randomly some time later
ive never seen that
im pretty sure you've turned on burst timings
which is interesting
(its an option)
yeah i enabled it thinking it might show how long my jobs took using burst if they used it
but i dunno what that timing represents
my polygon struct also has an unsafehashset
could that be non burstable ?
I think it the time it took to compile the brust code
do you have the burst option enabled in the inspector ?
synchronous compilation ? sometimes it start the play mode with the non burst version because it's not compiled yet.
burst compiles asychronously
it could take a few frames before it switches over if you don't force synchronous compilation
oh wow i thought it just hangs when burst isnt finished yet
it does if you have synchronous compilation enabled
for me its probably the same thing since without burst my game wouldnt run at all ๐
confused why it worked now but not last time
sry to necro my question from before this burst problem but any insight helps me a ton rn
So in the game we play a bunch of zombies which have Colliders. But they are all set to not collide with each other
Would that incur costs in the StepphysicsSys anyways?
The debugger shows no Contacts.
why do you suspect setting them to not collide would incur costs?
Somewhere this CollisionFilter setting has to be checked for Overlaps that happen. I thought it is checked in the BroadPhase (BuildPhysicsSystem) and the not valid collisions are never passed to and processed by the StepPhysicsSystem. So i dont know what my StepPhysicsSystem is doing for 1.4ms when there is no valid overlap it could process
does the deep profiler work for the physics stuff to see what it might be ?
ive not used the new physics tools yet but i imagine the profiler might highlight some info
Let me check if i can get it working now. there currently is a bug with M1 chips that makes the profiler not work because of too much memory usage (normal profiler works after unity restart, deep didnt at all last time i tried)... only fixed in later unity versions i cant use because of entities... so annoying
nope... cant run deep profiler...
wait doesnt entities work on latest LTS 2021.3 now ?
0.51 is out???
oh i thought 0.51 came with the LTS of 2021.3 but turns out its still in progress
atm we are at 0.50.1
basic question but when converting GO to Entity is it best to just not use physics shape and physics body and use rigidbody and collider?
they seem to convert the same both ways but physics body is missing some of the options of the rigidbody like freezing axes and making iskinematic
not sure axis freeze is supported by unity physics then even though they convert the old components. the new components do have a kinematic motiontype though.
I have a feeling options like freezing axes aren't converted kek
but i have to say the more detailed options for filtering collisions are great in the new components
thanks yeah I just noticed they have setting where you can just use it as a a trigger which I presume is the alternative
The Physics Body component has a "Motion Type" field that can be set to Kinematic. This is the same as isKinematic on a Rigidbody. There isn't a way to specify axis constraints on a Physics Body, but you can do this with joints. There is an example of this here: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/PhysicsSamples/Assets/Demos/4. Joints/Scripts/Creators/Joints/LimitDOFJoint.cs
I uses this simplified version in my own game to keep my character upright:
public class LimitDOFJoint : MonoBehaviour
{
public bool3 LockLinearAxes;
public bool3 LockAngularAxes;
}
[UpdateAfter(typeof(PhysicsBodyConversionSystem))]
public class LimitDOFJointConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
Entities.ForEach(
(LimitDOFJoint joint) =>
{
// Get the destination world entity associated with the authoring GameObject
Entity entity = GetPrimaryEntity(joint);
var bodyPair = new PhysicsConstrainedBodyPair(entity, Entity.Null, false);
var physicsJoint = PhysicsJoint.CreateLimitedDOF(
RigidTransform.identity,
joint.LockLinearAxes,
joint.LockAngularAxes
);
World.GetOrCreateSystem<EndJointConversionSystem>().CreateJointEntity(joint, bodyPair, physicsJoint);
}
);
}
}
The usage is similar to the Rigidbody constraints:
Is DOTS supported in Editor 2021+ ?
entities and packages depending on it arent
So recommended to stick only with 2020?
Thanks @whole gyro I did eventually find that, I should prob read the docs and look at the samples
I don't blame you. I wish things like this were easier to find.
yeah, they are intending to release something to make it compatible with 2021 maybe around june(but you know how they are with estimates)
Any idea whether Unity mentioned when they plan on enable/disable component feature?
entities 1.0...
literally everbody is waiting for it for years now ๐
@rustic rain posted 18mins ago
huh
well, my use case: enable/disable rendering of entity
Maybe there's any other option to achieve same?
you do know about the DisableRendering tag right?
I hope this comes in 0.51
Hey all, I've been wondering, is there something akin to hot reloading for entities etc.. ?
I currently have a fairly long startup time, and it negatively impacts productivity
the first line of the post literally says 1.0 ๐
Things can change + who reads anything more than the title lol + we are kind of expecting you @rotund token to implement it because you make miracles happen
You may be tempted to locally flip these methods to public to start playing with this feature in your own projects prior to its official release. I want to advise you in the strongest, most sympathetic terms: please, for your own sake, don't do that.
yeah his warning came too late for me
already played around with this last week
if we have a native array for a struct. can those structs use interfaces or will that mean they are reference types and not allowed for jobs
struggling to understand how to setup my data =/
WDYM exactly? If you want polymorphism for your structs PhilSA has a codegen solution that is pretty neat
well i have a graph class and need nodes/segments where they have info about the segments and nodes they connect to, on top of that my segment needs to be generic since they take a spline type which governs the curviness of the segment
at most i can restrict the segment generic to struct but not an interface
since my spline type is not an interface
its confusing how i link it all together
you can have interfaces on structs
and you can avoid boxing by using generics
that said, most of the time this line of thought is misguided for entities/jobs
it's an OOP not DOD mindset
how would you setup a simple graph of nodes/segments in a DOD way ? my brain is so used to the OOP way
i cant use a list of a generic struct for my segments so i dont know how to give it a spline data field
You wanna think about it in terms of packing data as dense as possible. Its essentially a matrix right.
so the segment should have all the spline data rather than a field to another struct defined as a spline?
Yeah, thats more like it imo
i guess i could store the end points and end tangents which is what i need to calculate my spline, then calculate the spline when needed rather than store all that data in the segment
I would set this up as Node tag on entity
- Connection component struct with "to" / "from" Entity references to nodes
- Spline component struct as either buffer of float3 or a reference to some shared data if its a lot of points (but this is advanced for me)
I'm pretty Entity oriented though. A lot of people pack their data into jobs and store it differently for these kinds of structures
this is what i currently have but without the spline data:
private readonly struct Segment
{
private readonly int _nodeA;
private readonly int _nodeB;
public Segment(in int nodeA, in int nodeB)
{
_nodeA = nodeA;
_nodeB = nodeB;
}
public int Other(int node) => _nodeA == node ? _nodeB : _nodeA;
}
private readonly struct Node
{
private readonly float2 _position;
public float2 Position => _position;
private readonly UnsafeList<Segment> _connections;
public readonly UnsafeList<Segment> Connections;
}
i use index in graph array for nodes
in the segment rather than an actual node type to avoid copying
I think your private readonly UnsafeList<Segment> _connections; connections list there should really be a list of indexes in DOD.
oh good idea
DOD is sorta like every struct lives in a flat list of contiguous memory and you wanna just index into it
so generally speaking a struct with a struct inside of it is best avoided
Just like verts and tris in a mesh
except the basic types of course
hm only issue here is. if i remove a segment from my graph
all the indices change in the graph's list of segments
so now all my node data is wrong
This is the big pain with DOD. You need to manage which indexes are free and which are not if your data structure is large.
can i not use pointers directly to the segment instead no matter where in the list some how
something like int *ptr = &_segments[index];
then store ptr
I think that's probably fine (I have little experience with pointers).
As long as the data is stored contiguously it should cache local when you are looking it up
indexes are just pointers anyway
yeh ive not touched pointers before either but maybe it'll work =/
i'll give it a try and see if it crashes lol
I'm about at my limit of reliability for this kind of advice XD If I say anymore I'd be guessing and there are some very smart people on this discord that'll be shaking their heads.
I try to use the maintstream Unity sanctioned methods as much as possible because I don't have the C/C++ background to delve too deep into unmanaged memory stuff.
im getting this with just a regular native list =/
contains requires you to implement IEquatable<U>
you really should look at the source to figure out why you have issues!
public static bool Contains<T, U>(this NativeList<T> list, U value) where T : unmanaged, IEquatable<U>
oh i used the wrong comparer interface ๐คฆโโ๏ธ
though wouldnt that make my structs reference types if i implement these interfaces
no?
C# specification specifically defines reference-type as comprising class types, interface types, array types and delegate types.
so that would make my struct a reference type no ?
yes if you pass something by interface its boxed
oh so if its the type Node then it remains a struct
where T : unmanaged, IEquatable<U>
if you put a generic constraint unmanaged/struct it will not be boxed
tldr:
struct can have reference types on it
unmanaged can not
@rotund token did it actually work (enable disable)?
on my very very very small tiny sample yes
but i was mostly just exploring what was available by writing theoretical code rather than running the actual code
cort_of_unity has blessed us with useful posts! ๐
oooooh. so enable -disable is almsot here
VS confuses me so much. At the beginning I could see decompiled source code of entities, then I could only see the signatures, now I don't see anything at all. Go to definition just makes an error sound
I take a break, come back and now it works again. This is ridiculous ... lol
it confuses me how it took them this long to support 64 bit in vs lol
I heard a total rewrite of VS is coming. Not sure about the details but it's way overdue.
How do I say I want to foreach all the entities that are missing any of a set of components? For example if I have Component A, B, C, and D
and there is a a component set
ABC
ABCD
ABD
BD
and I have say
Without B, C, D
With A
I would expect only
ABC
ABD
I hope this make sense...
Are you using EntityQuery or Entities.ForEach?
for entity queries, this doc will help: https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/component_group.html
Hi, me wanna ask about the Physics Velocity, when I start my game, at one moment the physics starts slowing down. Even thought I made a system to maintain the Linear velocity by assigning it on job entity batch. What is actually happening? how to solve it?
I used Havok Configuration and set Physics Step to Havok Physics.
One day I just bit the bullet and bought Rider and now I can't imagine life without it.
For me its the mattress and shoes argument, if you use the bloody thing for 8 hours of your day, every day, then its worth it.
Post some code
And what do you mean by " at one moment the physics starts slowing down"?
Do you mean that the velocity of the entity decreases?
There's nothing wrong with it actually, but the simulation of the physics at some moment is slowing down
Eh I just play the unity again and the physics running normal again...
What...
๐ ez fix then
how do you enable full stack ?
console log tells me to but already got full stack error reporting on in the player settings unless it means something else
@muted field Doesnt it say enable full stack traces and disable burst?
all it says is A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
i assume it means in project settings -> player
but i have that set to full stack so unless theres some other location to enable it i dunno how to get the full strack trace
hmm maybe this only comes with entities? or collections package?
yeh i dont have entities
not available in 2021.3
bit strange leak detection is only for entities tho
sry i cannot help with the setting.
but it shouldnt be too hard to find the array you are not disposing
yeh i think i found it
i had mispelt OnDestroy method so it wasn't disposing when i exited play mode
With the new Debugging stuff that will replace the EntityDebugger I miss the option to find entities by Filtering for specific components. maybe i just havent found it yet?
Can anyone explain why JobHandle.Complete() is blocking for so long when none of the threads are being utilized?
the main thread is completing the job
Hi, me wanna ask, how to lock physics constraints like the same in rigidbody component?
there's Unity physics samples with examples on constraints
it's in first pinned message
link that directs to github
How do I differentiate between subscenes?
Let's say I have 2 subscenes
I want to add certain tag to all entities in Subscene 1
and another tag to all entities in Subscene 2
I can see those scene related tags
but I don't get the idea behind what they mean
The SceneTag identifies the scene. Sections are just another separation of the scene in order to stream them
The SceneTag is a SharedComponent so all entities in that scene will reference exactly the same SceneTag
huh
hm
any tip on how I can quickly differentiate between them then?
I have 2 entities
I want to know
to which subscene each belongs
depends on what you need from the scene? the name?
Some kind of ID
rn I am trying to make a system that will swap my player entity
from scene 1 to scene 2
and vice versa
and all meanwhile
will add DisableRendering tag to all entities in system player leaves
while removing those tags from entities of system to which player goes
I guess you would have to change the sceneTag and sceneSection on the player then
Yeah, I get that part
but first I also need to somehow know to which I should change it
maybe you could use the SceneEntity referenced in the SceneTag to add some kind of ActiveSceneTag to it?
Ah ok, lemme check it out, TQ
then you could use EntityManager.GetAllUniqueSharedComponentData<SceneTag> to get all scenes and check their referenced entities if they are the active one
then you can just remove all the DisableRenderingTags on the active one and add to the other one
ok, first I should begin with simply disabling rendering on all entities from X scene
should be easy to get the scene the player is in. Just query for your PlayerTag and SceneTag
yeah
but rn it's more of question
how to query smth that is not hardcoded
Maybe you know how to do it?
rn I have 2 buttons
I simply want to query with button 1 through one scene
and with button 2 another scene
I just need an example, hopefully I'll catch on everything else myself
kek
List<SceneTag> sceneTags = new List<SceneTag>();
World.EntityManager.GetAllUniqueSharedComponentData<SceneTag>(sceneTags);
Here I have my list of sceneTags in a list
I want to query only through entities of SceneTag in index 0 of list
yeah so there's really 2 parts to subscenes
each subscene can actually be broken into a bunch of subscenesections
and each section can be loaded/closed separately
if you look at RequestSceneLoaded this is actually applied to the subsections not the actual subscene entity
but in general you will also only have 1 subsection unless you've setup more
What would be required appraoch if I want dynamically created subscene/sections?
For those "rooms" I have been talking about
well technically if you're talking runtime that really doesn't make sense
since subscenes are pre converted chunks of data
it sounds like you more want to partition your world into separate rooms?
well yeah
each planet system = each room
player directly can only intereact with one he exists in
but player can also travel to others
I guess my solution would be to pre-create all systems
AT least in that case I can make them beautiful kek
well i guess the first thing to know is are these planets created in the editor and baked in a subscene
or created at runtime dynamically/by the player
I could use a bit of both
for example
Solar system, with planets like earth, mars and etc should be exactly same through every playthrough
while some fictional systems
can be randomly generated
i would probably just define my own 'Room' shared component
and use that
make each subscene define a new room component
and then you can also create rooms at runtime
this.query.SetSharedFilter(new Room {ID = 1});
oh
will only return entities from room 1
alternatively different worlds (some complexities here if you want rooms to interact)
or just simply poll it on the entity
or keep a list of every entity in each room in a buffer
theres a few ideas
no, should be only one world
so I don't have to invent information bridges between them
SharedComponent seems like enough, for now
i agree if they need to a communicate that's a huge pain
I just need to learn more about it
private void DisableRendering(int ind)
{
var em = World.EntityManager;
var query = new EntityQuery();
List<SceneTag> sceneTags = new List<SceneTag>();
em.GetAllUniqueSharedComponentData<SceneTag>(sceneTags);
Entities.SetSharedComponentFilterOnQuery(sceneTags[ind], query).WithStructuralChanges()
.WithNone<DisableRendering>().ForEach((Entity e) => { em.AddComponentData(e, new DisableRendering()); })
.Run();
Entities.SetSharedComponentFilterOnQuery(sceneTags[ind], query).WithStructuralChanges()
.WithAll<DisableRendering>().ForEach((Entity e) => { em.RemoveComponent<DisableRendering>(e); }).Run();
}
For now I have this idea
I'll try it rn
hmm, doesn't seem to work
ooor
oh wait, me dum dum
I don't think it works
I think my query options are faulty
WithSharedComponentFilter(sceneTags[add])
This works
Buuuuut
Some entities are unaffected
for parallel jobs is there way to give each index in the execute function its own native collection so not to interfere with another ? i need each one to keep track of where they came from like a pathfinder so i need to write to a hashset as i go
huh
GetAllUniqueSharedComponentData