#archived-dots
1 messages Β· Page 143 of 1
Hmm My bad - there probably is a way - maybe Run? Afk atm
This physics engine is confusing me to no end without being able to find the source to see any per function docs. Apply a impulse to a entity with no gravity and no damping. On the z axis 1f * deltaTime and it gains 10f velocity a second not 1f as one would expect.
Im not sure what I did wrong but I copied hte sample again and it works π
@mint iron Did you say you were using Unity.Physics?
After all this time I'm finally able to see InverseMass = math.rcp ... sooo it's not inverse it's reciprocalMass some of the weird ass results I've been seeing are starting to make sense
Youβre using light theme (jk π ) - you need to put your code in a class that extends SystemBase to use Schedule etc - might be worth checking out the samples quickly first.
@amber flicker You don't Job's itself independent from ECS. You feel free run them in monobehaviour land without any problems
In ECS, is there an multiDim array type?
public int[,,] terrainMap = new int[ChunkData.ChunkWidth, ChunkData.ChunkWidth, ChunkData.ChunkWidth];
If you want something like that, you need write your own native container, it's pretty simple, just don't forget wrap it to tests π
Yep you can do that too
just not sure it feels rightr π
it felt bad as I use my Convert XYZ to I function thousands of times
Point was if you want it to be like [,,] with convenient accessors etc. you need native container or custom struct around flatten array π
in my old style unity project, I just grabbed direct by index which I know
I should write my first ever test one day ..
Well your Convert XYZ is just x + w * (y + d * z) not so much work which can be replaced to math.mul(w, math.mul(d,z,y) , x) which will be compiled to only add instructions (2 per 1 multiply) instead of multiplication.
But of course all depends and should be profiled
ok thanks a lot
this ECS is hard ot get started, but I feel the power although I have nothing working jkust yet π
is it safe the update the dependencies of the 2D Entities package to their latest versions?
You can try and see if anything breaks π
Usually it shouldn't be a problem, but I don't think they guarantee such things
I looked into it a bit more in the forums and it seems like it's not possible atm, they're planning to merge the 2d entities package + 2d foundational dots features with the rest of project tiny soon
so it seems I just need to wait for that to happen, hopefully it'll be soon
You can get the radius from the
BlobAssetReference<Collider> SphereColliderthat's created for the entity. Should be accessible fromPhysicsCollider
@loud matrix I can't find it, how is the field called? There is no Radius field inside the BlobAsset and inside the Collider (for now I've found inside the mass properties the volume, and with the volume I am calculating the radius)
Hi there, is there a way to convert gameobjects to entities without running playmode ?
that is on editor mode
and using authoring script on the gameobject
if someone could answer that it will be a happy day for me π
So you want them to become entities while in editor mode?
Where can I ask a "math" question?
Basically I have a circle in a grid and I want to get all the nodes in the grid that are touched by the circle (I've made an example, the red dots should be the one that I get from the function)
I thought it would be easier, but the circle can be of any size and it can be in any position
I have already made a function but there are some scenarios where it doesn't work
No really a dots question, no, but to me it sounds like you need to check for circle overlap on _each of the corners. Any corner with overlap you can mark all four nearby squares as in contact
Yeah that's similar to what I was doing but there is a problem (I can send other examples to make you understand what's the problem). This question is not DOTS related so I've asked it inside #π»βcode-beginner
i'm looking over the dots samples. is there any way to pre-compile all of them at once? so i don't have to wait before each one is being burst compiled before running it?
ctrl+shift+B in Visual Studio should build all projects, not sure if that uses burst properly, but I assume it should. Other IDEs should have similar commands.
@tawdry tree yeah thats it i want them to become entities while in editor mode
i really want to use ecs systems, component and entities while editor mode is on
i read about DOTS mode on editor but not sure that is what i really want
okey i think i found the solution
I just have to activate DOTS->Live link mode -> Live Conversion on Edit Mode
my next question , and i really sorry cause it seems i only know to ask. Its if subscene will respect authoring monobehaviur script added to a gameobject when it convert it to entity
thx really much guys
hello, is there a way to visualize native container data in the inspector? ATM I'm writing an additional debugger for each script that uses one which is an enormous hassle.
Is there a way of having a nativecontainer inside a blittable struct? Specifically I need to have an array of integers
nativecontainers aren't blittable afaik @rigid cosmos
Is there a way of having a nativecontainer inside a blittable struct? Specifically I need to have an array of integers
@rigid cosmos through pointers.
or (in case you're unaware of their existence) there are DynamicBuffers for array per entity
^
Why isn't there a "method" that automatically converts float2 to float3, I hate the fact that I have to create another variable float3 because I can't cast it..
you can create your own method for that
just do an extension method 
@storm ravine how would one go about creating a pointer? I've not used them in C#, no clue where to start
Why isn't there a "method" that automatically converts float2 to float3, I hate the fact that I have to create another variable float3 because I can't cast it..
@wide fiber float3.xz, float3.xy, float3.yz, etc.
@wide fiber public static float3 ToFloat3(this float2 target)
^
Or that ^ π
Float3 constructor will accept a float2 as one of the parameters. You need to provide the other value so it knows what you're trying to do.
float2 float_2 = new float2(0, 0); float3 float_3 = new float3(float_2.x, float_2.y, 0);
guess theres alot of ways
Do not reinvent the wheel.
@storm ravine how would one go about creating a pointer? I've not used them in C#, no clue where to start
@rigid cosmos read source code of native container for example. Or plain C# documentation about pointers, low level memory manipulation etc.
Alright thanks, will do!
Why isn't there a "method" that automatically converts float2 to float3, I hate the fact that I have to create another variable float3 because I can't cast it..
@wide fiber You cant cast it by obvious reasons, how it should be casted? To float3(x, 0, y) or float3(x,y,0) or float3(0,x,y)? Someone often using float3(x, 0, y), someone float3(x,y,0).
I get the feeling I need to tweak some of my physics settings, maybe.
maybe
only takes 1 second to get that fast too
You cant cast it by obvious reasons, how it should be casted? To float3(x, 0, y) or float3(x,y,0) or float3(0,x,y)? Someone often using float3(x, 0, y), someone float3(x,y,0).
@storm ravine same as Vector2/Vector3 casts?
I guess it would cast ... x =x y=y drop z π
is there a reason that the contents of a subscene wouldn't appear in a build? the subscene works fine in the editor but when using it in a build it's like nothing exists. im using hybrid renderer v1 and have tried building with the subscene both added and removed from the build settings, with the base scene there. without the subscene everything renders correctly. here's the subscene component
@fleet hemlock you shouldn't compare math lib with Math\Mathf libs. Because math lib written with shader like syntax, and behaves absolutely similar. They looking to shaders core math behaviour when they write math. And in CG you also can't cast them implicitly π Same as in shaders you can implicitly cast floatt to any - float2\3 but not float2 to float3 and all of them have the same float2\3.xx, float2\3.xy, float2\3.yx etc.
@craggy orbit do you build with new build tools or old one?π€
build tools? that might explain why i'm having trouble π never even heard of them
oh are those the Platform packages?
yes
ah. i'll give those a try then. i remember getting lots of errors be just installing them a few months ago. maybe they've been fixed
just copy buildconfigurations from ecssamples
the way i was spawning prefabs in the subscene had to be changed but it's all working now, thanks!
I want to destroy an entity using a command buffer
How do I get a valid entity?
{
Camera camera = Entry.camera;
float distance = camera.transform.position.z;
Rect rect = camera.rect;
EntityCommandBuffer simulationCommandBuffer = simulation.CreateCommandBuffer();
Entities
.WithStoreEntityQueryInField(ref query)
.ForEach(
(in WorldToLocal worldToLocal) =>
{
float3 screenPos = camera.WorldToScreenPoint(new float3(worldToLocal.Position.xy, distance));
if (!rect.Contains(screenPos))
simulationCommandBuffer.DestroyEntity(???);
}
)
.WithoutBurst()
.Run();
}
This is what I'm trying to do: When an entity goes off-screen, I want to destroy it
Entities.ForEach((Entity e) => { cmdBuffer.DestroyEntity(e); }
Yeah, but there's a condition involved
Oh
Right
Hm, can I get a component off an entity fetched that way?
You can pass in the entity and its component data as arguments in the lambda
Phenomenal.
So you can do (Entity e, ref ReadWriteType c0, in ReadOnlyType c1)
So Entity.Foreach(Entity e, ref WorldToLocal worldToLocal) => { /*check camera stuff*/ }
yea pretty much
So
Entity.Foreach(Entity e, ref WorldToLocal worldToLocal) => { /*check camera stuff*/ }
@outer swift replacereftoinas you not change that and only read from.
@storm ravine Thanks, already did
@storm ravine While I got you here ...
Is there something akin to a camera in Hybrid Renderer V2?
I'm currently using the standard camera to check if objects are on the screen, and that feels very wrong
{
EntityCommandBuffer simulationCommandBuffer = simulation.CreateCommandBuffer();
Camera camera = Entry.camera;
Rect rect = camera.rect;
Entities
.ForEach(
(Entity entity, in WorldToLocal worldToLocal) =>
{
float3 screenPos = camera.WorldToViewportPoint(worldToLocal.Position);
if (!rect.Contains(screenPos))
simulationCommandBuffer.DestroyEntity(entity);
}
)
.WithoutBurst()
.Run();
}
Only conversion by your self or enabling built in conversion by setting define HYBRID_ENTITIES_CAMERA_CONVERSION
Any documentation on this?
Aha, found this thread: https://forum.unity.com/threads/solved-hybrid-conversion-broken-or-just-me.880252/
I'll have a look at that. Thanks, @storm ravine!
anyone know how to ForEach entities witrh buffer?
Entities.ForEach(( ref MyBufferArray myBuff ) => { });
ForEach((DynamicBuffer<T> buffer) => {});
Ah thanks
God I may have just sent 3 days on physics and only now discover the unit for PhysicsVeocity looks like it's units/s not units/frame
I guess thats good maybe?
Ok, no its not, I'm just going insane now. If i set PhysicsVslocity to a new float 0, 0, 1 it moves forward 1 unit a second
but if i add a impulse, with a inversemass of 1 so that the values would be the same it goes 1 per frame
Oh I don;t even know what I'm doing anymore, Never been more tempted to just delete unity off my computer
ForEach((DynamicBuffer<T> buffer) => {});
argh thats still not happening for me
The type 'Unity.Entities.EntityQueryBuilder' cannot be used as type parameter '
do you mean ForEach or foreach?
I just wanna make a simple system to edit this buffer π
Entities.ForEach((DynamicBuffer<MyBufferElement> buffer) =>
{
foreach (var integer in buffer.Reinterpret<int>())
{
sum += integer;
}
});
foreach has become one of those questionable words with ECS as it could be the entity loop or a normal froeach
or both
I think its cause im mixing non buffer componenets, with buiffers
sactually I have no idea π
its workiong
Thanks
Ok, I muist declare the Buffer first in the list of componenets for it to work
Entities.ForEach(( DynamicBuffer<RequestedChunks> requestedChunks, ref ChunkLoader chunkLoader) => { }) WORKS
Entities.ForEach(( ref ChunkLoader chunkLoader, DynamicBuffer<RequestedChunks> requestedChunks) => { }) DOESNT
I'm curious about one thing.
Vanilla unity had an interesting rewrite of the transform system in 5.4 I believe. The rewrite sped up the CPU usage when updating large hierarchies so that only those gameObjects that had important components actually received the callback.
So, for example, empty gameObjects will not cause any performance penalty if the parent is moved, but if the gameObject contains a collider or a meshRenderer, it will cause a performance overhead
Now, regarding ECS's Transform system
Considering that I have an "empty" entity consisting only of the basic transform components, will it incur any penalty if its parent entity moved?
yes
the solution is "dont have that entity have a transform component"
or have it flagged as static
if the entity has a transform component, then you are directly telling unity systems that you want it to be updated
Yeah, that's exactly the solution one would come up with, I was just curious
I can see one concrete example where it falls apart. Imagine that I have a gameObject positioned somewhere in the hierarchy that represents a pivot of sorts upon which I can look up the world transform, for example. Now such a thing won't work within ECS because the pre-5.4 style callbacks are brought back apparently.
it is possible to do something similar-ish to the callbacks
Without introducing some workarounds
version IDs on the component arrays
I meant, like, the whole process of ~transform changed -> notify all children~ thing
thats what you can do with version ids
you will have an archetype for those pivot thingies
you can check with the ECS if their transform changed since last frame
and if it did, then you do whatever
btw, this is done at a per-chunk basis, not per-entity, but if you really want per-entity, you can store "old transform" and do comparaison
Yeah, I just wanted to know if the transform system did stuff internally just like with pre-5.4 or if it did something interesting
it uses those version numbers to not update what doesnt need updating
but im not fully sure how its internals work
Well open source code and read? π Also you can look at Mike's talk about transform system, and moreover docs have pretty deep explanation how transform system group work. About exact implementation everything in all transform systems (TRSToLocalToParent, TRSToLocalToWorld, LocalToParent etc.) all based on IJobChunk with chunk version change detection. They all pretty simple, mostly 1 system with just 1 IJobChunk doing thing.
oh wait that part is open sourced?
Of course, all packages source code in Library -> PackagesCache
In very rare cases it has reference to UnityEngine internal things (like BatchRenderGroup which used by HybridRenderer)
is there anyway to inactivate an entity like we do we gameobjectsd?
@vagrant surge what do you mean?
thought the transform systems were on the closed soruce side of unity
like Eizen said, most packages (from package manager) are just c# code
well, they do have native code counterparts too
like, ECS is fully in c#, including all dots transform math
but job system is on native code and more so if you go to gameobject side
Does StepPhysicsWorld update in a fixed interval if you don't bootstrap it yourself, or why does it use fixedDeltaTime?
I'm using NetCode and i had to replace fixedDeltaTime with deltaTime since the update interval of StepPhysicsWorld was different on the client and server.
Anyone have any reference on entity streaming? Is it a thing?
ExclusiveEntityTransaction. This is what subscenes use for streaming under hood.
hmm, its complex to find good samples, my old code worked well just using GameObject.Inactive π , for ECS do you think a suitable way could be to disable the Meshrenderer componenet?
(its just terrain)
any my ChunkLoading system, just tags these entitys with a MeshRenderer componenet when player is near
isn't there a property on the renderer to disable it ?
yeah just wondering how best to "unload terrain" as I walk away
all terrainchunks are entitys, with a mesh. (I have a list of terrrainchunks I want shown)
just have a system that somehow knows the camera bounds and check if your chunks are in it ?
isn't there a property on the renderer to disable it ?
Ill research that
Im too dumb to understand the docs π
it's an ICD, so when you want to not render a chunk you add the ICD to your entity
Usually im ok with python docs, but still learning C# or whatnot so it can be hard. My day job is in GIS and our API docs aree insane good I now realise
ok that makes sense, so rather than remove the mesh and readd it, you just add this
meshes are (afaik) shared components, it would be unholy bad perf wise if each time you wanted to not render something you had to remove a shared component
Is there a "best" practice for native collections and resizing?
My NativeMultiHashMap is running out of space and i need to resize it
You can resize it on a thread, so you could calculate the needed space and resize the capacity as needed before utilizing it.
what about native lists?
will they resize automaticly as i try to add?
answering my own question, no cant resize if using parallel writer
If you use Schedule instead of ScheduleParallel for a job that should work just fine, since it will only be on one thread it shouldn't have contention between writing and resizing.
otherwise you'll need to calculate and preallocate on a job that the writer jobs are dependent on
i would like to caculate
but ill have to do the same bit of code 2ce
seems wastefull
and even then i might not need to resize
but i guess thats the cost of splitting the next peice of work up
try looking at NativeStream then. It requires a bit of setup for the number of ForEach loops (separate writers/readers basically), but then you could merge the result on an iJob to a native hash map or what have you.
I do something similar for one of my system chains
Oooooo native stream... can they be used for networking?
they may be what i need
basicly i loop over a bunch of stuffs, check to see if i should be sending it, if i should i write it into a nativehashmap with the id of the player to send to
then update some caches so i dont reloop over the same stuff next time, and dont resend same stuff
yeah NativeStream first then caching it in an IJob might be a better fit
i might save that steam stuff for a optimization later
im already thinking about replacing ENet with Unity.Transport, when i do that i think i sawp
for now will go with Schedule
Can we use any Generics with SystemBase yet?
not that I'm aware of.
lame
i have almost identical code, only real difference is a few types passed into WithAll<> and stuff
Translation VS Rotation
ect
yeah it's a bummer for sure, hope they fix it eventually
hi there
it is possible to authoring on edit mode ?
i know i ask all time same questions sorry
is it *
Hi guys,
I'm starting from Unity's DOTS Sample and trying to recreate a new character (different model&Animations)
I've gotten quite far, The character spawns and is able to move around, but I'm having difficulty with the custom animations playing. and I was wondering if someone else has tried succesfully something similair?
If so , @ me and I'd truly appreciate it!
@ocean tundra I know it's not the same but extracting a bunch of code out to static methods can be really helpful (and works smoothly with burst)
@amber flicker Can the static method be generic?
All attempts I've made previously to work with generics in DOTS at all have failed. I rely on a significant amount of code-gen combined with static methods that take concrete types.
I appreciate it might not be that helpful if you were already aware of that way of working. There's also the potential option of a shared interface across components but like I said, not the same power as generics.
e.g. I don't think it's obvious if one was new to DOTS that you can swap out HasComponent in a SystemBase for a CDFE and pass by ref to a static method.
ComponentDataFromEntity (what HasComponent/GetComponent/SetComponent use behind the scenes)
Yea I've been using that
Has anyone got any automated testing setup for their project?
I'm looking at getting my build pipeline up and working, then i want to investigate automated testing
hello guys .. I search for a long time now .. I wonder how to reference a child GameObject of a Prefab as an Entity in a IComponentData .. to enable/disable it later .. thanks π
Are you using IConvertToEntity?
Sure π
I wonder how to get the Entity from GameObject
Has anyone got any automated testing setup for their project?
@ocean tundra what do you mean by automatic testing ? I did some unit test if it is what you talk about. CopyingECSTestsFixture.cs
Are you using IConvertToEntity?
@ocean tundra sure.. Iβ―also tried[GenerateAuthoringComponent]
in the IConvert... one of the paramenter (sorry cant remember which one, Conversion System??) has a method you can call, get entity or something like that
you pass it a game object reference which you expose as normal
GetPrimaryEntity ?
I already tried that and got GetPrimaryEntity(Object 'QuestMarker') is a GameObject that was not included in the conversion and will be ignored.
its a child right?
you have to implement IDeclaredPrefabReference interface, and add your game object to method's list, then you can use GetPrimaryEntity in Convert method
No because it says it is not a prefab (as it is a child of a prefab)
then you cant use it, are you trying to get a child entity reference ?
yes Iβ―am
What is the best way to activate element of a prefab then in ecs style ? here a quest marker on a character (to give you a bit of context)
you can use Child Buffer
so if your quest marker was first child of your prefab then you could do buffer<Child>(prefab)[0].Entity, which would give you the quest market entity
But it is no straightforward to get the right children (not really clean also)
It is a bit dirty, donβt you think ?
perhaps yeah
π
well, i never needed to do that, so idk
how would you have handle that then ? @here any other ideas ?
i think you shouldnt use everyone or here tag π
well, i mean i probably make the quest marker a prefab itself, then when i activate it i would put it above the player's head
sorry for the here
someone knows what to do?
tbh, using child buffer is simple and easy
its definitely not 'handy' as monobehaviour style, but in ECS it works like that
@sudden comet I also haven't had to do this yet. However have you read this article? https://gametorrahod.com/game-object-conversion-and-subscene/
I think you might be able to achieve what you want using something like:
{
public GameObject itsChild;
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
Entity childEntity = conversionSystem.GetPrimaryEntity(itsChild));
}
}```
What is the best way to activate element of a prefab then in ecs style ? here a quest marker on a character (to give you a bit of context)
@sudden comet In general, it's with EntityManager.Instantiate(Entity src)
I made a prefab factory class that converts a list of gameobject prefabs into entities.
With that you can pull the prefab entities for systems in the main thread update or on init
It's fast, no need for pooling or activating/deactivating
Right now, unity itself has no real means of linking converted entities and their gameobjects. so you have to make some kind of key to get them. either a int with your own Ids, a guid/string hashed to an int
if your job is not bursted it's also possible to just make a call to a static dictionary that has all relevant information
as in, directly inside the system. for jobs you'd have to get all keys for the systems in the main thread
@amber flicker your example is missing the IDeclaredPrefabReference
@sudden comet I also haven't had to do this yet. However have you read this article? https://gametorrahod.com/game-object-conversion-and-subscene/
I think you might be able to achieve what you want using something like:{ public GameObject itsChild; public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { Entity childEntity = conversionSystem.GetPrimaryEntity(itsChild)); } }```
@amber flicker It does not work because GetPrimaryEntity(Object 'QuestMarker') is a GameObject that was not included in the conversion and will be ignored.
Anyway thank very much for you time
eh, it's IDeclareReferencedPrefabs ... why do I copy/paste from other users? ^^
eh, it's IDeclareReferencedPrefabs ... why do I copy/paste from other users? ^^
@viral sonnet what do you mean ?
the posted example misses this interface. you have to declare converted gameobjects with that otherwise you won't get anything from the conversionSystem
@viral sonnet not sure that's true - you don't need it for the conversion system to work
I think the code I posted would work if it's in a scene.. as a prefab I'm not sure - I'm expecting more stuff from Unity soon to help with the whole prefab workflow
Either way, it does not work
If you want to get an entity representation of the QuestMarker, it would seem the first problem is that it's not being converted?
it is converted .. it just that Iβd like a proper mean to interact with it
I will probably put a TagComponent on it, or make the child register in the parent itself
what do you mean with interact? instantiate it?
reference it when Iβ―need to enable/disable it
In the convert method you could write the entity to a static dictionary<string, Entity>
But Iβ―donβ t have the Entity
or have a static Entity in the authoring monobehaviour
how do you convert it?
you said it's converted
There is an entity in the World that correspond to the "QuestMarker"
But Iβ―donβt know how to get it from the Convert method
I was wrong .. because Iβ―used "convertandinject"
is there any authoring component on the questmarker before it gets converted and injected?
no
without any custom code you don't know where the entity ended up and you either have to get it by tag/comp or by the gameobject which you could also use if you inject it
Now that Iβ―destroyed the entity it seems to work ..
I have other problem to handle π and need to check if is really working
Hi all, I'm getting crashes in builds but not the editor, struggling to see where they're coming from but some of the error logs hint that it could be either or both trying to access singleton components or persistent native arrays.
Does anyone have any tips for debugging this? So far I'm looking up the error.log and player.log files but the messages seem inconsistent. I didn't used to have any crashes a few builds ago, although quite a bit has changed, singleton components among them.
have you tried with all safety checks off?
ahh good call thanks I'll try that now
well, yup that crashes Unity silently π¦
weird that it doesn't give me any errors about what is underlying this though
there should be some output in the editor or editor-prev.log
a time ago my builds crashed because i had a try/catch in a componentSystem.
oh boy sorry that was longer than expected
ugh sorry will delete, I'm reading thsi the wrong way around
Has anyone worked with the DotsFormer Character within Dots Sample to help me with some animation issues? My Bones seem to animate (I tested this by attaching a cube directly to the bones) but my skinned mesh isn't following the animation set on the bones?
I noticed that when I explicitly create the client or server world from a system in default world (override bootstrap), I get an InvalidOperationException in ComponentSystemGroup.UpdateAllSystems due to collection was modified on m_systemsToUpdate.
anyone dealt with creating the client world outside of bootstrap?
I have the 1 Entity, which is the only one with a particular compnenent. Any better way to get reference to it than this?
WorldData worldtmp = new WorldData(); Entities.ForEach((ref WorldData world) => {worldtmp = world;});
Debug.Log (worldtmp.name);
I have the 1 Entity, which is the only one with a particular compnenent. Any better way to get reference to it than this?
@graceful mason GetSingletonEntity\GetSingleton<T>
Thanks again your a guru π I copying some of your codes from the forums too.
Which Unity version should I download to try the latest dots stuff? 2020.2 alpha or 2020.1 beta?
Either should work fine I think
Can I make a sphere cast (Physics) without the UpdateInGroup(typeof(EndFramePhyscisSystem))?
It isn't a problem if the sphere cast is "older of some frames" because the physics has not been updated yet, but does it work?
I have done some tests and I think it still waits for the physics group (I have the dependencies for the physics, should I keep them?)
anyone know if can you profile inside a burst job? so far from my own attempt, doesnt seem like it picks anything up
yep you can, gimmi a sec and ill remember how
run that and search for Job1z in the profiler and it should show up
thanks @mint iron
anyone got a good example of Authoring component, for a buffer of simple components. (more than 1 field)
you want to put a BlobAsset/Fixedlist/unsafeList in a component or something?
I just want a GUI like I had before in editor,
X items, simple schemas
I can generate the authoring component for 1 item, but not when its in a buffer
as per docs: IBufferElementData authoring components cannot be automatically generated for types that contain 2 or more fields.
I guess this is more "GameObjectData" rather than "GameData", so perhaps it shouldnt even be entities anyway
i would recommend you write a converter and use a subscene (but you could also use convertAndInject script), ill see if i can dig up an example from somewhere.
thanks man
can the markers only be used with run? doesnt appear to do anything
hmmm, im not sure sorry.
yeah appears it only works with run, oh well
ProfileMarker useful, but for parallel profiling can be tricky π
yeah was attempting parallel profiling
BTW leave the feedback: https://forum.unity.com/threads/feedback-request-ijobentity.888121/
oh I didn't imply they did that without reasons
@graceful mason
ConversionSystem: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/bec317babc4170a605c9b0bdb30bd8916bcaf184/UnityPhysicsSamples/Assets/Common/Scripts/PhysicsSamplesConversionSystem.cs
IConvertGameObjectToEntity: https://github.com/jeffvella/UnityEcsEvents.Example/blob/11e0a09f8592dc3b947686f7ab7af2b739d153f6/EventsExample/Assets/Game.Scripts/Support/SubscenePrefabConversion.cs
Advanced Version with Blobs: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/71ee2024d554ba1c090408b886d47bfb5b6d0179/ECSSamples/Assets/Advanced/GridPath/Scripts/CartesianGridOnPlaneAuthoring.cs
Contribute to Unity-Technologies/EntityComponentSystemSamples development by creating an account on GitHub.
An example showing the how ECS Events package can be utilized in a game. - jeffvella/UnityEcsEvents.Example
This is what we asked in IJobForEach deprecation thread
it's just, DOTS, and ECS has gone TONS of API changes so far, it moves really fast
I don't mean that's a negative thing for the end result, but it's not great for the early adopters (but again, it's still in preview so that's what you get)
I like the name :p
as well as for any optional attributes placed on the OnUpdate method ([AllInQuery], [AnyInQuery], [NoneInQuery], etc.). ugh, anything with attributes always tends to turn out nasty.
Why but it's not great for the early adopters ? Nothing changed, only added convenient middle ground job replacement which will reduce IJobChunk complexity for some type of jobs which will be mess in Entities.ForEach π
also would like if they actually deprecated .Schedule and just renamed it .ScheduleSingle for all types
I'm not going to get into that debate (about IJobForEach deprecation and new replacement NOT being an API change - because it is π )
as well as for any optional attributes placed on the OnUpdate method ([AllInQuery], [AnyInQuery], [NoneInQuery], etc.).ugh, anything with attributes always tends to turn out nasty.
@mint iron this is why I mention in feedback explicit EntityQuery usage (and similar request for Entities.ForEach) π
so is the OnUpdate like Unity's MonoBehaviour's message callbacks in a way? The method would just need to be called OnUpdate(...)? π€
Well that name definitely will be changed
Not suitable here
as systems already use that. IMO they should leave Execute for that.
yea i agree with that
well posted my thoughts, id personally prefer to schedule them like regular chunk jobs, over using Entities.OnUpdate(job).with_stuff_.schedule
this is why I mention in feedback explicit EntityQuery usage (and similar request for Entities.ForEach)
π
They will do this in the end I guess
yeah, i also just wanted to add in my preference of not using the Entities.xxx part π
More similar feedback - more chances that Unity will see that is not only one person requirement and this things really needed for community
I'd much rather they directed the energy into a chunk api myself but I realise I'm probably in the minority
what is chunk missing that you would want to see?
chunk.HasComponent without the penalty of CDFE.. that's it.. then I'd be happy π
@mint iron those authoring scripts are complex, its insane it cant generate a GUI for you, considering it can make a GUI for BufferInts, and also a gui for MySimpleComponent. Why not smosh them together
thanks though, I will try to implement something π
@amber flicker Mmm canβt understand your problem? Maybe I miss your point. Chunk has HasComponent(ArchetypeChunkComponentType) for example. And which case you have when CDFE cost is affect you?
Chunk api pretty nice it self. It cover every thing I need, when I want performant scalable low level data processing, and when they added OrderVersion in last versions it become much nicer
@storm ravine SystemBase.HasComponent = 1 rand access per entity.... chunk.HasComponent = 1 linear memory access per chunk. In complex jobs it's useful to be able to switch some small logic on the presence of a tag for example. For now, I use IJobChunk but, as it's often with more complex jobs I have the issue, the IJobChunks ends up really verbose. Would be so much cleaner if you could e.g. ForEach(..optional MyTag), ForEach(..[] OtherChunkComponentTypes) or Chunks.ForEach (which is something they've mentioned doing at some point) even if they were always readonly it would still be v useful imo.
Or if one day they just changed the underlying behaviour of SystemBase.HasComponent to do the same, that'd be perfect.
Well Chunks.ForEach is on their radar for simplification IJobChunk. I see what you want with this message (because previous was absolutely unclear in that π and not even points to systems).
BTW cdfe.HasComponent and chunk.Has both random memory access π But yeah in chunk iteration you only check on chunk level not per entity, this is only difference
ah yes, ok that makes sense
it bothers me that I have a lot of code that, if I wrote more verbosely, would be quicker but it's a relatively minor issue
When Chunks.ForEach will be done it will cover your case for code clearance
yes exactly - I was saying that for me, that api has higher priority than another way to do pretty much the same thing we can already.. for me π
Hmm are you using namespaces? I have made a namespace for a part of my game. Within that namespace I use Unity.Physics. But for some reason when I change my PhysicsVelocity while inside the namespace my Velocity is not updated. The system is running and when I remove the namespace i can see the changes in velocity.
I have not overwritten PhysicsVelocity inside my namespace but I think Unity confuses the namespace and PhysicsVelocity and thinks it's not the correct component. Any ideas? I would like to keep the namespace
Can you use the Unity NavMesh with DOTS?
this is like the only thing that you can use in jobs https://docs.unity3d.com/ScriptReference/Experimental.AI.NavMeshQuery.html
Ive integrated with https://arongranberg.com/astar/ for pathfinding, but I cant use it in jobs
this guy did a nice implementation for dotsifying navmesh if you dont want to make it yourself https://github.com/reeseschultz/ReeseUnityDemos
Thanks I'll check it out
is it possible to have 'big entities' in some way, or thats counter to the spirit of the system and stuff? 'Archetype too large to fit in chunk'
just working out where to store my mesh verts and tris etc π
I think I can just go: [InternalBufferCapacity(0)]
Can't you control chunk size?
I think 16064 is hard max due to mem allocation and stuff
but mybe tht [InternalBufferCapacity(0)] thing llocted outside chunks
Both what data you store and how your store it
I can generate it in 4 seconds, just trying to work out how to store it in memory
Maybe you could make a "LinkedList" setup with entities
lemme try this [InternalBufferCapacity(0)] thing
Every entity stores a part of the data split up into reasonable chunks
And a reference to the next entity that stores the next part of your data
Until you reach an entity that doesn't have the next reference you know?
ohh this [InternalBufferCapacity(0)] has beasted it itr looks like
beasted?
I read it stores it outside chunks, so it not so good
it shows all my data in the entity inspector
[InternalBufferCapacity(0)] public struct ChunkMeshUVsElement : IBufferElementData
so I think it working as good as can, just performing a biut like classic unity
Could try what I suggested too
sounds complex π
doable but complex
Be my guinea pig damn it
for mesh data wouldnt it be better to store it in Native Collections ?
i guess if its super dynamic it would help to have it attached to the entity
Why not float3?
Im new π they worked out great so far, tho not sure why I use those
I think float3 was specifically made to be used with this too
Or at least the types from math
could technically just make a class component and use AddComponentObject
for the big component thing
Yeah the Burst Compiler is made for the Mathematics types @graceful mason
May 2018 update: Some of the information in this talk is now outdated.
For up to date news about our C# Job System, join us here: http://bit.ly/2hDuJSx.
Dive further into the upcoming performance optimizations coming to Unity. This talk covers the continued development on de...
Yeah, Will defo need to convert to that after I get my prototype going
want 1-2km draw distance ideally for voxel game π
I had 2km in unity classic at 1400FPS, but it took 3 hours to load + populate the meshhes π
and trying to implement threading got me into ECS π
but my 2km demo, had only (terrible) terrain gen and no other code so seemed great to switch, I only started recently
and ran at 0fps for 3 hours til it generated. (or less / view distance setting)
is fun π
I think I have a different understanding of fun π
you are making a game to?
@graceful mason I love procedural generation
doing anything cool with it inside ECS?
3 hours is crazy long
I am making a game yes
And have a lot of side-projects
Probably too many π
Currently not utilising ECS and DOTS in a serious capacity
I did this a little while back https://gitlab.com/omniowl-public/unity-ecs-2d-life-naive
To try and learn about ECS in Unity
nice
It's free for people to disect and look at but it is months old so, Unity doesn't do things like that any more
yea they change so quickly now
i love it but it gets annoying having to rewrite older systems
yup
have you tried any automated testing in unity?
I've missed a few bugs lately that could have been caught via a automated test. but of course dont have any yet
and not 100% sure how to make any
Look up the Unity Test Runner
thats for unit tests tho?
Well sure, but it's for testing in Unity at the very least
Automated Testing would require there to be tests in the first place π
i was more thinking of end to end tests
like it could start my game as a host, and then start some clients, connect and play
somehow...
its automated as no human needs to do anything
"like it could start my game as a host, and then start some clients, connect and play"
Sounds like humans involved
Yeah okay...you still need to actually write the tests
If you want to really look into a client/server setup that you can use as a playground, albeit a rather advanced one, get the FPS sample
i have all the networking working
It's a DOTS FPS sample project by unity that has both server and client
just want to test it well π
Well, do you have agents that could play?
Because really what you need is a simulation of your game, not to play the actual game.
That would take forever.
You should, more or less, be able to simulate the whole thing server-side and let agents work with the data the server has access to. No game required.
Agents would be necessary if you wanted it to be automatic
and both full end to end and being able to simulate super quickly would be amazing
Please also elaborate on what you mean when you say "end to end"
sorry its a team we use at work in web dev. basicly end to end for this game would be starting the game like a normal player, clicking buttons ect to start a game (host) and also doing the same thing for some clients, they join into the same game instance, game starts
so its a actual networked game, running like it would for players
You can simulate all of that
Let me rephrase; You should simulate all of that
the purpose of the tests are different tho
If you want automated testing, that is
i want to confirm it ALL works
I mean yes..
But what does that have to do with simulating it?
If you want to keep your sanity you'll find a way to simulate the whole session, preferably at upscaled time so you can speed up the simulation and not have to wait forever for results.
Once you feel comfortable in the simulations, you could make a more elaborate "closer to real life" test with bots
But that shouldn't be the goto. Iteration time will likely be abysmal
yea thats probs a good idea
time isnt really a issue
was more for a overnight test
like stellaris and factorio teams do
But first get the tests right. Then think about CI / CD
they (stellaris) run the whole game every night on a bunch of machines, all with AI playing π
Yeah likely not in realtime though
And probably also with a lot of simulated environments
Automated tests are supposed to be predictable
@ocean tundra You can definitely make tests like that, but requires a bit of an elaborate setup and probably can't be done entirely within Unity. What you can do is write unit tests in Unity with the Unity Test Runner (UTR). These would verify your basic functionality.
Then you could write some script (Python or whatever you like) to first start a server, where you could run the tests from command line. Once they have been validated, you can run clients, and then run tests on those.
However such a big setup will require quite a bit of work both to implement and maintain.
@bright sentinel do you think it would be worth it tho?
I want AI's in my game anyway so hoping that it wont be much extra work to allow a AI vs AI game
That's not really something I can answer π
π
Unit tests should always come first, at least for the most important "units"
But some launch argument which starts a constrained AI-vs-AI match with minimal extra fuzz shouldn't be too hard, assuming you already have AI
I rpobably wouldn't bother doing that until I had 90% of game, though, too easy to fall into the trap of non-progressing work
ive tried to do unit tests on multiple projects
including PUBG itself (research)
unit tests for games... doesnt work
at all
the only case where it can work is for a online game, live service, where you absolutely dont want any regressions
its not just about the unit test development itself,but about the "lockdown" they cause
once a sector of code is well tested, that section of code is basically "frozen"
doing any change means having to adjust tons of tests
so unless you actually want to freeze that section of code because its "final-ish", then dont
what works much better is integration level tests. For example shove 10 bots into a deathmatch and see if everything happens at expected
those cost near-0 to implement, and can test big chunks of the game at once
Replays also can do that, you can try to run a replay and see if stuff still happens as usual
How can I get the LocalToWorld.Position of the current frame? Because I spawn a prefab (that has transform 0,0,0) in a random location, but the first frame when it spawns, LocalToWorld.Position gives me 0,0,0 instead of the new position
@wide fiber I see 4 solutions. 2 of them requires that you spawn the entity before the transform systems run. This can be achieved by using the EntityManager directly. However, that doesn't allow you to do it in parallel. The 2nd solution is similar, but with an ECB. This requires you to set up a ECB before the transform systems, which then causes a sync point. This may not be ideal either.
A 3rd solution is to disable the renderer for the first frame. This should be done right after you spawned the object, and then a system that enables it again next frame.
Finally, the 4th solution is to change LocalToWorld directly after you spawn the entity. Then you would have to mimic the behavior of the Transform systems. You may be able to do it simply by setting position and rotation, but I haven't really touched it, so I wouldn't know.
does this code have any hope of working: https://pastebin.com/rJGMdzMa
Anybody know how close burst 1.3.0 is to release, or if 1.2.3 supports compiling to linux from windows?
vblanco, sure unit tests in code works.
You can do it on the traditional "units" of methods, typically helpers and such, and on the "unit" of game mechanic. DOTS especially makes the latter easy - spawn entity with MoveForward and a given speed, simulate x time, check if position is correct. Repeat for a couple different speeds.
That tests one system, of course, but barring corner cases you can at least verify that the basic functionality of your core systems work.
@bright sentinel Ok ty (the problem is not the renderer, but it's another system that checks the distance between him and another object, if it's less than a 1 unit for example, he does a thing)
Traditional tests work the exact same way, and have some use, but the "unit" of a minimal system iteration takes a bit of time and might need somewhat fuzzy checks. I made some basic tests of a "move forward" system which could test a dozen tests in time not far off from traditional unit tests.
The real question is whether it'd benefit the game and code or not - iterative processes already makes tests more dodgy, and the nature of games does not help with that.
Hi guys, I'd like to confirm something with you about memory layout with DOTs. When querying for some entities, it is the entire chunk that is brought to CPU cache? correct? And because of that, reading more or less components in a query shouldn't affect performance?
Out of curiosity @tawdry tree , what kind of things can mess up a system to move forward an entity that a test like that would catch?
Only poor coding, really. Admittedly, it's pretty much a hello world example.
Hence why you would ask whether the tests are worth it or not
@eager jungle yes, that's my understanding - so long as you're reading components that are part of the chunk (rather than ComponentDataFromEntity).. well, every operation has some cost but it wouldn't have a performance cost in terms of fetching data
I wouldn't do that test outside learning, but combined with a "turn towards" system you could automate testing of agents (stupidly) "pathfinding" towards player/food/whatever
@amber flicker OK great. I understood the "wouldn't" :p
haha yes sorry about that π
not related, but do you know what it the proper way (or suggested way) of handling events in ecs? I was thinking of creating entities carrying over some "event" component, notifying system, which would then be destroyed afterward. Event would be like: notify UI, trigger something... etc
Events, as in...?
The "Options for Entity Interactions" talk might be what you're looking for. Either way i found it very helpful to understand some concepts.
https://www.youtube.com/watch?v=KuGRkC6wzMY
The "Options for Entity Interactions" talk might be what you're looking for. Either way i found it very helpful to understand some concepts.
https://www.youtube.com/watch?v=KuGRkC6wzMY
@tawdry tree k thanks, i was just about to watch it, already in a tab. Any other hints before i continue with that? I've heard some stuff about system state components of something. Is it worth digging into?
system state components are a good tool yeah
@eager jungle Honestly you should probably just watch that first. System state components should not be used for entity interactions, but if it's an event in the meaning of "thing happened, all systems that care can check the state and do their thing" they are good
@eager jungle tertle on the forums made this https://forum.unity.com/threads/event-system.779711/#post-5189462 - I'm not sure I'd ever include it in a project myself (although I'm sure it's very good) - this may be a good reference for what a complete 'event system' might look like in dots - but what an 'event' is and how it relates to your data & systems means it's a bit of a vague term
It's actually some kind of observer pattern I'd like to implement. Some system throw an event in the wild, and some system may or may not react to it by "subscribing" to that event, whatever this would mean in ecs
That's a good point - In DOTS you might want to think of it differently. Events are generally rather OOP.
For that use case, creating message entities or system state should do the trick
Which is better depends on the use case - how often will this happen, what's the magnitude of changes here?
One thing to be mindful of is when and where timing is implicit or explicit. i.e. the order of your Systems can be explicit. Mixing that with firing off an event and responding means you need to be aware of when the data is changing and which systems will operate on it.
The simplest, most naive way it to set a public static variable. I'm sure you can find reasons why that isn't the best idea, but if it's simple and works... Mightnot need anything else
let me give you a real life example maybe
That too, the order is absolutely crucial. You wanna be explicit about Before/After.
my vehicule is moving and got hit by a projectile. I want to spawn a particle effect, and also shake some UI element say.
Entity Interactions cover stuff like that pretty well
But the mechanics at play is a collision, and N number of other systems that want to react on that
I think that kind of thing I'd handle with Tags
yea, its just that i don't want to collision system to be in charge of spawning the particle for example, i just want it to trigger some events that the collision system isn't even aware of
Regarding before/after, consider one "frame" of the game - you generally wanna make sure the order of operations is consistent, and that you do [other stuff][reset state][set new state][other stuff]. Depending on order you can have things reacting in different frames, which might be bad or ok, and to fix that you'd ensure the event is fired very early in the frame, and reset either end of frame of at the very start
i don't intend to use event to update states, but most probably just for transient stuff happening. Not sure yet how I'll handle that, but if order matters maybe it shouldn't be an event like that. .. hmm
In this case state just means changes done in order for this to work, not game state or state of entities and such
what is the proper use case for system states components?
mainly to monitor component add/remove and entity create/destroy
@eager jungle I think it's mostly a semantic/organizational thing. You can pretty much get the same functionality with normal components, but it may be nice to organize components like that
@bright sentinel Hey thanks, can you detail what you're referring to? normal components vs system states components?
Normal components are IComponentData while system state components are ISystemStateComponentData. They function very similarly, except that when you destroy an entity, the system state component will still live with the entity, until the component is deleted manually.
It's especially useful for detecting when an entity has been destroyed
@eager jungle You can read more here: https://docs.unity3d.com/Packages/com.unity.entities@0.10/manual/system_state_components.html
thanks, reading that already, just wasn't sure your were talking about that
would you guys handle a bullet impact changing vehicle health in such a way? FireSystem => Spawn Bullets then CollisionSystem => Spawn Impact then Damage System => Deal Damage ? Can impact be considered an "event"?
That seems pretty accurate to me
I'm also still trying to figure out events in ECS, so I don't really know of any alternatives
When querying for some entities, it is the entire chunk that is brought to CPU cache? correct? And because of that, reading more or less components in a query shouldn't affect performance?
@eager jungle @amber flicker Wrong π Not whole chunk goes to cache. Depends on type you requested (not just declared in EntityQuery), cache lines (usually 64 bytes per line, but depends on hardware) only filled by exact type arrays parts you iterate linearly, amount of types listed in query not matter. What matter is how many of these types really used for processing and which types data you exactly gather. Processor not prefetch whole chunk (because there is no reason for that it's not SOA in regular meaning). When you requesting some component data (Translation, SomeTagfor example) you use EntityQuery as mask for chunks which contain both of them (but that chunks can contain other components, there is one reason why chunks not prefetched and shouldn't), for example there is can be archetypes ofTranslation, SomeTag, RotationandTranslation, SomeTagand etc. And when you doing chunk iteration (which happens under hood anyway) you iterate every matching chunk, and in this matching chunks you implicitly iterate through only required arrays linearly (include Entities which lives in chunk as pointer to 0 component type index array), and this is where processor cache lines utilisation become a thing, cache line prefetch different AOS of data, and this is why count of gathered types (not just listed in EntityQuery) matter and have cost (for example difference of iterating 1mil entities in case when you get only 2 types (where first type is Entity) ~8ms and in case when you iterate same 1mil entities but operate 8 types (where first type is Entity) ~12ms. With disabled burst. With Burst enabled it will be ~1-2ms for 2 types and ~3-5ms for 8 types). Also what matter here is what you doing with data - reading or writing.
Thanks for the clarification @storm ravine - so in your example, the archetype has 8 components but when you do e.g. ForEach(component1, component2) it takes much less than ForEach(c1,c2,c3,c4,c5,c6,c7,c8) right?
Yes
Where Component1 is Entity
Just note for remember that π
Of course you can exclude entity and thus it will be -1 type for gathering
so is the chunk a struct of arrays of components ? and only the interesting arrays of components are prefetched?
Chunk is struct with pointers to memory buffers and offsets.
But it's also true that ForEach(e,c1) for an archetype with 1 component will be quicker than ForEach(e,c1) for an archetype with 2+ components - I thought that's because the chunk could fit less entities in, meaning less entities were brought into the cache line to be iterated over. I must be wrong about this?
oh ok, so every component type of the archetype of that chunk will be stored somewhere in a contiguous array, but usually not in the same contiguous memory as some other archetype using the same component?
Numbers above is for writing, for reading (all components in instead of ref) it will be ~4 and ~9
But it's also true that ForEach(e,c1) for an archetype with 1 component will be quicker than ForEach(e,c1) for an archetype with 2+ components - I thought that's because the chunk could fit less entities in, meaning less entities were brought into the cache line to be iterated over. I must be wrong about this?
@amber flicker c1 is same type?
or just 2 different archetypes with different c1?
same type
Well these ForEach wil itarate same amount of data, because their EQ will be the same
I mean if you have 100 entities with c1
and 50 entities with c1, c2
they both will iterate 150 entities
because query mask here only by c1
different amount of entities will be only if you declare different EQ where c2 will be involved π
I'm trying to understand why foreach(c1) for 100 entities with c1 is quicker than foreach(c1) for 100 entities with c1 & c2
Time for more tests..
i don't understand either why that would be the same. Because if the chunk (of fixed size?) with C1+C2 contains less entities, they are more fragmented accros memory. Is that what you mean @amber flicker ?
I'm speaking about exact ForEach he wrote π
foreach(c1) and foreach(c1) - same
if you declare for example WithAny\None\All it will change count of entities
and of course will change timings
are you trying that @amber flicker ? π
yes... I must be wrong.. as sensei-Eizenhorn is always right π - but in my previous tests, I'm sure it took different amounts of time to iterate. In addition, I'm sure I've improved job timings by decreasing the size of components that are not being read/required/accessed by the job
Ok I'll clarify it without chunk and memory things involved by your latest case:
You have 100 entities with C1 without any other types. And have 100 entities (imagine we can fit only 100 entities in chunk for simplification) with C1 and C2 this you have 100 entities with C1, C2 and 200 entities (in sum) with only C1 for iteration. You iterate this 200 entities - you iterate through all chunks with that C1 type and through all "arrays" of C1. If you'll have only 200 entities with C1 (absolutely without C2) timings will be the same, because you iterate 2 chunks in both cases. But important note here - we speaking about optimised packed data case π
There is many things involved
There might be a miscommunication going on. Here is the code I just used to verify. The timings are in-editor with safeties disabled:
https://hastebin.com/cicupugomo.cs
In you code chunks count will be different
obviously..
Yep small error in my last example https://discordapp.com/channels/489222168727519232/497874303463850004/709770673219960863
it will be 2 chunks vs 4 chunks
Yes of course
ofc, so more component = bigger size = more chunk for the same amount of entities = slower
Hey guys -
I had an issue yesterday with DOTS animations not being played on my own custom character within DOTS. The skeleton played the animation but the skinned mesh didn't. The issue apparently, it seems was that for Unity DOTS Animation to work (as it's done in the DOTS Sample) is to use Vertex Skinning node inside a Shader and make sure you apply that shader to your character. Thought I'd share the solution, instead of always asking the questions! Hope it helps people!
@eager jungle indeed
thats also why it can be recomended that you split your object into multiple entities
for example having a few entities instead of a monolythic megahuge "player" entity
So this difference in speed is not to do with the cache line right? That was my mistake - thinking that it was related. But it's not - the time is spent fetching the pointer to the next chunk? or..?
btw, unity ecs has HUGE fixed overheads on the systems
so that might be why you find that iterating C1 and C2 while only accessing C1 is slower than doing C1 alone
essentailly the more components you have in your foreach, the slower those overheads are
at 10mil, ~20ms vs ~40ms fyi
uhm that doenst make so much sense, the overheads are more in the region of 0.1 ms
run it through profiler and check
and do something in the loop
like adding something to the comp
it's not about size, it's archetype
@digital scarab well archetype is about size in result. Because archetype define size of of your data and on how many entities will fit chunk and how chunks data will be spited (exclude all filtering, MaximumChunkCapacity etc. here for simplification and just speak about raw data)
Yep of course in tags case, but we again speaking about real data π Not about chunk header for tag components π I'm intentionally skipped all that additional stuff like chunk headers for tags, filters and all other stuff, because it affect things drastically π
So this difference in speed is not to do with the cache line right? That was my mistake - thinking that it was related. But it's not - the time is spent fetching the pointer to the next chunk? or..?
@amber flicker new memory zone (often) mean new fetching, so its kind of related i suppose
interestingly both scenarios take the same amount of time if I write to the component in the loop
hey do u guys know how to use tiny unity?
@gusty comet Believe you just need to install the packages required by Unity tiny via package manager. There's a pinned Tiny samples repository which shows the structure
@amber flicker do you mean that if you do nothing c1+c2 takes longer, but if you write, both (c1 vs c1+c2) take same amount of time?
yes - perhaps it is a symptom of not doing anything in the foreach
i did that, but theres no "create DOTS project" option under DOTS
@gusty comet I'm not sure about that option, haven't touched Tiny in a long time. IIRC you just need to author entities using subscenes and build with the build pipelines to build out a Tiny project.
@amber flicker you are likely running into some weird shit
being the same amount of time sounds about right
because the overhead of 1 comp foreach vs 2 comp foreach is like 0.01 ms or so
so if you have something that takes 10 ms, thats just noise
@gusty comet I'd follow the getting started guide in the forum post: https://forum.unity.com/threads/project-tiny-0-25-preview-is-available.881065/#post-5798350
@gusty comet the DOTS editor no longer exists
well... I'm pretty sure it was doing a test similar to this that sent me down the wrong understanding - It's good to know it's not true in general. I wonder if it is related to some in-editor safety test. As soon as I give it some work to do I get more expected results.
DOTS editor exists as a package still exists though right? It just doesn't do much and isn't related to Tiny π
@amber flicker from when i tested, with all safety checks disabled, but still in the editor
there is about a 0.025 cost per-component in your foreach
due to checking dependencies in the job system
linear
so a foreach with 4 comps will have 0.1 ms of overhead
and a foreach with 8 about 0.2
but i dont know if thats a thing in full build, outside of the editor
thisis from the vehicle move system in Tiny Racer demo
red part is the "actual" work (the stuff inside the foreach)
everything else is overheads
of course, this is both in editor, and with the profiler, so its bigger than they actually are
I'm taking my timings from the work done across the threads which I think might not include that anyway?
ya
That picture is a bit blurry to try and make out
But it looks like you got a spread of 10 micro seconds
Which isn't much
And I see a Singleton access?
Smells like main thread heavy
@digital scarab but you dont get zone traces with a native profiler
need the annotations
and function start-end
like the unity profiler has, where it shows the exact callstack
if with native profilers you mean stuff like vtune, verysleepy, or others, those are sampling, they just throw rng samples and record the callstack at points, those arent very precise for games
do il2cpp builds have markers for vtune? unreal engine has them
ah then perfect π
not the place
?
Any good reason as to why
for (int i = 0; i < 144; i++) activeBuffer.Add(new ActiveGrid_Buffer { value = 5});
Only adds 4 elements to the activeBuffer?
In systemBase OnUpdate
@digital scarab where for RPG,im new here.
or just help at all.
where for help then duh
my game
uh
okie then
I'm trying to fill a dynamic buffer inside a system, but it only fills up one page (5 elements). Not sure why it isn't adding all of it..
entity debugger
Well, If i do that same thing in monobehaviour it does show me all of the data inside the buffer.
I'm also in the process of trying to figure out how to debug.log inside a system π
no. I do mean dynamic buffer, as it is possible to use them in monobehaviour
Basically I create the entities in mono, and trying to process them in a system
I can understand why... It's how i'm getting started with it
I'm having a problem with a SingletonComponent apparently not being created in time. I create the component and use SetSingleton in OnCreate, then much later in a monobehaviour's event callback (which itself is called by the SystemBase in question) & after a bunch of setting up has happened, I'm calling GetSingleton() and that seems to be failing sometimes but not always in a build. I'm only seeing the errors in player.log (it doesn't crash):
at Unity.Entities.ComponentSystemBase.GetSingletonEntityQueryInternal (Unity.Entities.ComponentType type) [0x0001f] in <54c4447081104ec68f143a5cd752b3ed>:0
at Unity.Entities.ComponentSystemBase.GetSingleton[T] () [0x00006] in <54c4447081104ec68f143a5cd752b3ed>:0
at PlayerSpawner.SetUpPlayer (Unity.Mathematics.float3 playerStartingPosition) [0x0002a] in <2f470fd45f8140c79c7135ea4902628d>:0
at PlayerSpawner.OnGameLoaded (Unity.Mathematics.float3 playerStartingPosition) [0x00000] in <2f470fd45f8140c79c7135ea4902628d>:0
at (wrapper delegate-invoke) System.Action`1[Unity.Mathematics.float3].invoke_void_T(Unity.Mathematics.float3)
at GameStateSystem.GameLoadingComplete (Unity.Mathematics.float3 playerStartPosition) [0x0000a] in <2f470fd45f8140c79c7135ea4902628d>:0 ```
@digital scarab How would you suggest iterating over the dynamic buffer to see the results if not in entity debugger?
Yes. only one page. There are no other pages or it just wont let me see the next page
Well and dragging slider don't do any thing for you?
nope.
I already have some Dynamic Buffers I created in mono, and they work. Now I'm trying to do the same in a SystemBase
That was originally made in mono i should maybe add
: MonoBehaviour
Mmm you working directly with DynamicBuffer and not with IBufferElementData?
No, I have made an entity, addded a buffer to that entity with IBufferElementData in a monobehaviour script. Then I'm referencing that buffer with this entity in a system to fill it up with values
the values I am giving it in the loop inside the system are added to the buffer correctly, but not the entire 144 elements
just 5
Show your code in OnUpdate
And which value used in InternalBufferCapacity for IBufferElementData
` protected override void OnCreate()
{
zoneRoomsEntities = GetEntityQuery(ComponentType.ReadOnly<Tag_Zone>(), ComponentType.ReadOnly<PlayerEntity>());
playerEntity = GetEntityQuery(ComponentType.ReadOnly<PlayerTag>());
activeGridEntity = GetEntityQuery(ComponentType.ReadOnly<Tag_ActiveGrid>());
}
protected override void OnUpdate()
var player = playerEntity.GetSingletonEntity();
var playerComponent = GetComponentDataFromEntity<PlayerEntity>(true);
index = playerComponent[player].indexOnZoneBuffer;
topRoom = zoneBuffer[index + 1].roomEntity; `
var topRoomBuffer = EntityManager.GetBuffer<roomGrid_Buffer>(topRoom);
for (int i = 0; i < 144; i++)
activeBuffer.Add(new ActiveGrid_Buffer { value = topRoomBuffer[i].value });`
And what @digital scarab suggested - put debug log to every element or size in general just to be clear that elements in buffer (not by entity debugger)
damn... hopefully its readable
roomGrid_Buffer which InternalBufferCapacity ?
I have not set an InternalBufferCapacity. I only added 144elements to it
I'll read about it
I'm having a problem with a SingletonComponent apparently not being created in time. I create the component and use SetSingleton in OnCreate, then much later in a monobehaviour's event callback (which itself is called by the SystemBase in question) & after a bunch of setting up has happened, I'm calling GetSingleton() and that seems to be failing sometimes but not always in a build. I'm only seeing the errors in player.log (it doesn't crash):
at Unity.Entities.ComponentSystemBase.GetSingletonEntityQueryInternal (Unity.Entities.ComponentType type) [0x0001f] in <54c4447081104ec68f143a5cd752b3ed>:0
at Unity.Entities.ComponentSystemBase.GetSingleton[T] () [0x00006] in <54c4447081104ec68f143a5cd752b3ed>:0
at PlayerSpawner.SetUpPlayer (Unity.Mathematics.float3 playerStartingPosition) [0x0002a] in <2f470fd45f8140c79c7135ea4902628d>:0
at PlayerSpawner.OnGameLoaded (Unity.Mathematics.float3 playerStartingPosition) [0x00000] in <2f470fd45f8140c79c7135ea4902628d>:0
at (wrapper delegate-invoke) System.Action`1[Unity.Mathematics.float3].invoke_void_T(Unity.Mathematics.float3)
at GameStateSystem.GameLoadingComplete (Unity.Mathematics.float3 playerStartPosition) [0x0000a] in <2f470fd45f8140c79c7135ea4902628d>:0 ```
If you not set InternalBufferCapacity it will be 128 / IBuferElement sizeof
And if you exceed that value it will be moved out from chunk to heap
@storm ravine setting InternalBufferCapacity(144) did not seem to do anything
i'll try to do the same with higher capacity
to all of them
Well, if you debug log actual size of buffer or debug log this
Debug.Log(activeBuffer[i].value);```
Which result you see?
Put it after for (int i = 0; i < 144; i++) activeBuffer.Add(new ActiveGrid_Buffer { value = topRoomBuffer[i].value });
I understand that Debug.Log is not possible in Systems?
Why?
It's possible
and from latest releases it's even possible from bursted job with string literals
I'm still using 2019.3.3f1.. Might have been added since then
System itself it just code on main thread.
Doesn't matter
Debug.Log always worked in systems itself
Dunno where i got that idea from
huh.. Okay that answered a few questions then
It keeps on adding them nonstop
If i understand it right, a System will then keep on running over and over again. Which is where Entities.ForEach comes in to run the code inside it whenever theres a change, right?
instead of running it endlessly
A system runs whenever any entities it's querying for exist
Makes sense.
So in case where the entity its querying always exists, but needs to run a snippet of code only once in a while, is when i should use the Lambda?
The general idea is if you want a system to run you create an entity for it. When you want it to stop running you destroy the entity or remove the relevant component
There are performance concerns if you're doing that a lot in a single frame but that should be your starting point
So if you have some code that you only want to run once in a while, that should be in it's own system. You create the relevant entity/component, let that system do it's thing, then destroy the entity/remove the component when it's done
Okay! I think I understand now
I've been using entities.foreach exclusively until now, and it's been working great. But am I right to assume that it runs the code inside it only when there's a change in one of the reference components?
No, it runs every frame as long as the thing it's querying for exists
Unless you use change filters
I suggest you read this page carefully. It's long but very informative and thorough https://docs.unity3d.com/Packages/com.unity.entities@0.10/manual/ecs_entities_foreach.html
Good to know. Much thanks @zenith wyvern @storm ravine
I appreciate your educational help ^^
Can we still use normal coroutines, with Jobs?
All coroutine stuff is restricted to the main thread
yeah the coroutine running on main can call a job every now and then? Or thats just a bad idea?
I don't see a problem with it
Ah cool thanks
Finally, the 4th solution is to change LocalToWorld directly after you spawn the entity. Then you would have to mimic the behavior of the Transform systems. You may be able to do it simply by setting position and rotation, but I haven't really touched it, so I wouldn't know.
@bright sentinel how can I set a local to world? LocalToWorld.Position is only a getter, I have to change the float4x4 Value, but I don't know what's the position
you can create new LocalToWorld cs var ltw = new LocalToWorld { Value = float4x4.TRS(newPos,newRot,newScale) }
or cs new float4x4(rotation,translation)
Ok ty
(the solution doesn't work (the position is not changed, it spawns at 0,0,0), do you know other solutions?)
How can I get the LocalToWorld.Position of the current frame? Because I spawn a prefab (that has transform 0,0,0) in a random location, but the first frame when it spawns, LocalToWorld.Position gives me 0,0,0 instead of the new position
This is the problem
you have to set Translation and LocalToWorld
ecb.SetComponent(entity, new Translation { Value = yourRandomPosition});
ecb.SetComponent(entity, new LocalToWorld
{
Value = new float4x4(quaternion.identity, yourRandomPosition)
});```
hello, it is possible to create a subscene via code ? and save scene ?
save subscene scene
on editor mode
you have to set Translation and LocalToWorld
@warped trail ah ok, thanks :D
or use command buffer system which run before transform system π
I prefer the other way
is there a parent > child type of entity relationship possible?
ohh parent Component
There's also DynamicBuffer<Child> if you need to grab the children from the parent
and LinkedEntityGroup as well
weβve been internally prototyping a version of ML-Agents that is built for DOTS. Weβve successfully integrated our DOTS prototype into sample scenes (see above) and Unity demos such as MegaCity and TinyRacing. The results have been outstanding. We were able to train agents in complex and large environments such as MegaCity in just a couple of hours on a standard laptop. We intend to release an experimental version of ML-Agents for DOTS later this year.
oo
I wonder if they have internally a version of megacity that runs on latest entities
Can anyone help me with this error:
(0,0): Burst error BC1064: Unsupported parameter Unity.Mathematics.float3 linearVelocity in function VelocityStateMachine.ProcessVelocity.Invoke(Unity.Mathematics.float3 linearVelocity, Unity.Mathematics.float3 forward, Unity.Mathematics.float3 right, Unity.Mathematics.float3 normal, float t, float speed, float height): structs cannot be passed to or returned from external functions in burst. To fix this issue, use a reference or pointer.
Why can't I juse float3 parameters?
huh, I thought they got rid of that previously. So at one time you couldn't use external functions with return types. Instead you had to use the out keyword to return stuff, and the ref keyword to pass stuff in
It looks like you're using a function pointer. You need to pass/return structs by ref if you're using a function pointer in Burst.
Like it says
oh yes, it's not in general, specifically with function pointers that's right
According to the manual they are going to change it so you don't have to eventually, but not yet apparently
When I use pointers as parameters for my function pointer why do I have to use "unsafe"? Makes me feel uneasy
c# doesn't allow directy use of pointers by default since it's a managed language. To use unmanaged stuff, you have to use unsafe
and in order to do so in unity you have to enable Allow Unsafe Code in the settings, in addition to adding the unsafe keyword to the relevant class or method
A lot of the DOTS stuff is already using unsafe under the hood so
No need to feel uneasy about it
well the dots stuff is all wrapped so you still get error messages and stuff if you, say, go out of bounds while using a NativeSlice. Using pointers directly though you have no such luxury
Sure but considering how easily you can crash the editor while working with dots stuff
true dat lol
it's safe to say that...it's very unsafe
π
(did I win a nice subtle pun award there?)
I wouldn't call it subtle, but you get the award nonetheless
I'll take it
this might be the wrong place to ask, but why use a function pointer over a delegate?
Delegates allocate
you can't use delegates in unmanaged code afaik
Probably also that
the burst function pointers are also incredibly fast compared to delegates, at least when executed using Burst
unsafe...unsafe everywhere
the problem of being faster than light is you must live in the darkness
as someone who was about to use a lot of delegate for an ECS behavior tree, this is good to know π
we do
of course they do...
it do be like dat π
I don't really see it affecting us either way as it's not likely that they release it
at this point, would be nice to even have up-to-date ECS Samples repo π
It'll likely be like the FPS sample though. Continous iteration and release.
I don't see why they wouldn't release it with the official release of ECS
it's been discussed here in past.. FPS sample was supposed to be public iteration from the beginning, MegaCity was a tech demo
Well things can change :b
also it's probably nontrivial to decouple their internal wip versions of packages to actually make a new MegaCity release
or at least time consuming
and from what I've heard the FPS sample was also a tech demo before the choice was made to change it
I dunno about that, I mean once they showed it to public, they were pretty clear from beginning it would be updated
many were let down because it got canned quite early on
Don't I have to use a delegate in order to complile a function pointer and later Invoke it? In the Burst manual they give such an example
you do
the delegate itself is just a signature though, idt you use an instance of the delegate
if that makes sense
So thats a different delegate that you mean? Which is slow by comparison?
Func or Action are typically used in place of traditional delegate signatures, so something like
Func<float,float,float> myAdd = (a,b)=>a+b;
Debug.Log(myAdd(3,4));
where you do myAdd(3,4) is invoking the delegate, and compared to burst functionpointers is very slow
Oh I see, thats the alternative to function pointers within Structs I guess
Or any place really
yes, they're the traditional c# way of handling "function pointers"
do note I believe in order to get the speed up of Burst FunctionPointers they have to actually be called from within a Burst-compiled job, you can't just use them in place of every delegate and expect everything to be better
it is like magic at the highest level, or at least is indistinguishable from it
It's only indistinguishable if you can't fathom the technology
We do fathom
it
π
I lost my interest in programming for a number of years because it got boring, everything was so systematic with OoP, but now you have the ability to do all sorts of shenanigans with DOTS, things that would have previously been only done in such a straightforward manner you can for lack of a better analogy, throw a curveball
Sorry one last question, how can I get pointers within my lambda Entities.ForEach? float3* vel = *physicsVelocity.Linear; doesn't work. I tried &, ref, in, out
tbh I just try random combinations of * and & until it works
but you might want to just use a temporary variabl in that case, and set the Linear velocity to the temp variable
you might want to look into the fixed keyword though, I'm still a little shaky on pointer stuff myself
Okay thanks, if I cant figure it out ill just open a Thread on the forums
I'd like to implement behavior trees into my ECS stuff but I'm currently running into problems:
- a behavior tree might want to get access to all sorts of entity data, which would mean casting a wide net and accessing a large amount of components if I want to use jobs
- behavior trees for different entity types means making different jobs or versions of a job?
using EntityManager.GetComponentData in the tree nodes seems like an attractive alternative right now instead of creating a whole bunch of ComponentDataFromEntity objects, but then it couldn't be multi-threaded
I'm planning on using delegates/function pointers for tree nodes, basically Im trying to figure how I'm going to be passing info to the nodes, and right now just passing a big group of component data seems like the only way
From what I gather
Behavioural Trees have very simplistic components you can chain together in a lot of ways
Should be fairly generic
The problem is that the behavior tree will want to read component data to make decisions
am I hurt, am I in combat, am I casting a spell, am I hungry, etc, etc
But its up to you to formalise that logic in a way that can be data driven
"am I hurt" could be something as benign as the difference between 0 and 1
You'll need to store state somewhere
Of each agent
Ideally you'd make it so that state data can be attached to any agent
I guess I'm worried about having the size of state data balloon if keep coming up with behaviors that need new data
the frustrating thing for me is that running behavior trees will never write to the data it reads, parallelism isn't a concern
so ideally I wish I could just access the component data directly, speed, health, hunger level, etc
but then in ECS jobs, I have to set all that up before hand
I guess the issue is that number of potential components I'd want to access could get large
and having to do all that setup might balloon quickly
but I guess it can't be avoided
again, I wish I could do something like EntityManager.GetComponentData in each tree node
instead of creating a whole bunch of ComponentDataFromEntity objects at the beginning of the job
this is just me messing around, but this is what I was passing to my node delegates, in addition to the index
in an IJobChunk
wait does it even allow that? I thought you could only use NativeSlices in struts
I dont think I've gotten any issues with this yet?
huh
but Im also still sort of prototyping this whole thing
maybe it's only if you try and put that in an IComponentData that it starts complaining
oh yeah
this isnt data for a component
this is data from an IJobChunk to pass to a delegate
cmdState.state is an index for an array of delegates
so different behaviors like attack, follow path, etc are just delegates in that array
it doesnt execute the actual movement or attacking, those are separate systems
but it does check for when a behavior is finished or can move on to the next behavior or whatever
is it performance or convenience that makes you want to avoid using GetComponentDataFromEntity?
its the fact that the AI of the behavior tree could potentially want to look at pretty much any and all components an Entity has to make a decision
I mean, I'd be the one designing the AI, of course
but
it sounds like GetComponentDataFromEntity is the way to go to me. You can use the .Has method to check if it actually has the thing, and go from there.
the alternative would be to set up a "write" relationship instead of a "read" relationship
well the tree would never write to the components its reading
its just looking at them to decide on how the entity is going to behave
yea sounds like GCDFE is the way to go to me
I'm probably overthinking things
I just feel suspicious about accessing a huge amount of components from a job
I really should just try it and see how it works out
yeah, even if it's not the most efficient thing possible, it'll still be by itself many times more performant than traditional c#, plus it will also have multithreading
it's the whole idea, with "Performance by default"
I am very much looking forwards to also having a million units on-screen π
it's a hell of a thing. Here's a shot from my system that uses GCDFE
is this just rendering objects? or do they have some sort of behavior?
they all have collision, physics, and are moving and turning based on dynamic expressions
How many are there?
dynamic expressions?
I think it was 60,000 there
as for what I mean by dynamic expressions, that's a secret π
@vale stream The ECS system is fast enough to make up the difference from all the data you retrieve
If I have a NativeArray of job handles, is there a way to wait for ATLEAST 1 of them to complete (and it tell me which one)
For some context, I've scheduled about 10 jobs for different types, and need to do some follow up work after the job is done (that can't be in a job currently)
I have same question, I just have in my Update Loop..... for JobHandle in handles if .iscomplete()
but i guess that may be badd
I currently just schedule all 10, and then loop over the handles and call .Complete and do the followup work
But this is very wasteful if the first one in the array is done last..
I could do the busy loop, but then it won't use the main thread for doing the jobs while waiting.
i love scheduling jobs to run over multiple frames π
huuuuh, I get endless install for Entities with 2019.3.13 :(
any way to see what it's actually doing ?
ho nvm it was just rly rly long
I had an issue with procedural meshes in DOTS where they would go missing when refocusing unity or creating them within a few frames of hitting play. It seems the issue was Unity was deleting them, presumably thinking there were no references to them since the references were unmanagaged. Is there a way to stop this, other than just creating a list of all the meshes in managed memory?
isn't there an attribute to run stuff in the editor that should normally be only run in game ? @opaque escarp
tho idk if it works with dots systems
that's a different issue entirely. I think the thing here is Unity now tries to automatically delete unreferenced meshes to avoid memory leaks. But it deletes the meshes being used because their references aren't known by the garbage collector
hmm
the way I'm dealing with it currently is just having a List of the meshes. That's it. Doesn't do anything, it's just there, and that fixes it.
Hey, still new to DOTS and trying to wrap my head around the workings. If I make a temp native array in Start, why do I have to call dispose when I'm done with it? Shouldn't it get garbage collected automatically?
nativearrays are not garbage collected, period
the whole of DOTS revolves around using Unmanaged code, which means there's no garbage collection
theoretically they could set it up so that .Dispose is invoked automatically if you use a Temp allocator, but idt they've done that
Ah, interesting. I assumed since it was still C# it was still managed. How careful do we have to be about memory leaks (I understand the basic concept, but have never worked with unmanaged code)?
in editor mode it will shout at you really hard if you have any leaks @feral elm
as long as you use properly implemented native containers
so NativeArray, the stuff in Unity.Collections, and the jackson dunstan ones are nice to grab
you just have to choose the right allocator for the right thing
Awesome, I'll grab those and read up on them! Thanks @opaque escarp @zinc plinth

Is there a way to write (increase a component version number) only if a condition is met?
If i use ref in a Entities ForEach it will always think the value is changing
you could use an entity command buffer if you know nothing else will touch it before the command buffer system is run.
If you want to accumulate changes, you may want to look at NativeStream or NativeMultiHashMap<T,U>
depends on your usage patterns
Does something like an Heap container exists (NativeHeap doesn't exist)? I am trying to optimize A* pathfinding
hi there, where can i find subscene inspector script , i mean i want to know what happen when button edit is clicked
I mean
void Awake()
{
GameObject aux = new GameObject();
subScene = aux.AddComponent<SubScene>();
Scene subscene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene,NewSceneMode.Additive);
EditorSceneManager.MarkSceneDirty(subscene);
EditorSceneManager.SaveScene(subscene, Application.dataPath + "/" + "EJEMPLO.unity");
EditorSceneManager.UnloadSceneAsync(subscene);
subScene.SceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>("Assets" + "/" + "EJEMPLO.unity");
}
i have this test code for creating an subscene on editor but i need to add some sentences that made the same effect of edit button on click
this let me to convert gameobjects to entities via code on editor , i guess
please any kind soul there that want help a lost programmer
okey i just find the scripts
I had an issue with procedural meshes in DOTS where they would go missing when refocusing unity or creating them within a few frames of hitting play. It seems the issue was Unity was deleting them, presumably thinking there were no references to them since the references were unmanagaged. Is there a way to stop this, other than just creating a list of all the meshes in managed memory?
@opaque escarp It's known from 0.9.1 and they already working on fix, I reported that bug when they released 0.9.1.
Fix for this has landed in master, and will be in next release, also they will fix side issue with UnloadUnusedAssets related to this, in future
Hi there! I'm new to DOTS and Unity Physics and I've been trying to find out how to grab (aka parent) physics bodies and release/throw them. I know about the Parent and LocalToParent components, but I can't seem to find the correct configuration. Any help would be appreciated! π
@pallid rapids ecs samples repo has physics samples. Most of those are configurred to use mouse pick script that basically does what you just asked
Olento, burst .13 is up π
Just post the changelog if you feel like it :D
Been meaning to make a tool that polls these easier now that the convenient bintray polling is gone but there is quite much on my plste right now
I can post it in a bit too. Just not on computer right now
### Fixed
- Fixed incorrect struct layout for certain configurations of explicit-layout structs with overlapping fields
- Fixed a bug where the `mm256_cvtepi32_ps` intrinsic would crash the compiler.
Sounds like some minor fix then
not necessarily dots related, but I assume there is no way to get a nativecollection of verts/tris from a mesh other than using CopyFrom, even though they do have a way to set them?
Yes I am taking a base mesh and basically generating a loft from it so I duplicate the vertices and offset along a path
I'll check it out thanks
@opaque ledge Where you do get the notification of new package releases?
I previously just checked the notification stream on bintray, but that seems to be dead.
0lento π
π
i just check package manager time to time π
whenever i open my project rather
@storm ravine thank you for reporting it, I was just about to myself
Anyone know a good way to share materials? I think that may be my issue with my "batches" count and also, my game loop is spending 60ms "Add New Batches"
worldManager = GameObject.Find("WorldManager").GetComponent<WorldManager>(); entityManager.SetSharedComponentData<RenderMesh>(chunkTerrain, new RenderMesh { mesh = mesh, material = worldManager.material });
Is what I do now, couldnt work out how to simply pass a material to my dynamic mesh
my objects are also all stationary, so ideally I need to work out the ECS wayt to: mark GameObjects as static using the Static checkbox in the Inspector
adding typeof(Static) seems to have helped a bit. Im sure my material is setup wrong thou π
Has anybody made a movement system in DOTS using physics without overwriting velocity? (2D)
I have tried a lot of different ways, but it doesn't work as expected.. I can't overwrite the velocity because the entity will be affected also by other forces
I think you just overwrite velocity
i think you can look into physics character controller
as if you pull something-10 it doesnt care something else pushed it +10 ?
just dont overwrite the velocity, add to it, or subtract from it
The problem is that I can't add to it forever, I want a max speed thing..
I have done some tests, but it's harder than what I tought
I can't check the length of my velocity.Linear and if it is going slower, I add the force.. because the object would "move jerky"
i think you can look into physics character controller
@warped trail is it open source? I'll check it
Ty
so is this line of code, making a new Material instance of each of my meshes? worldManager = GameObject.Find("WorldManager").GetComponent<WorldManager>(); entityManager.SetSharedComponentData<RenderMesh>(chunkTerrain, new RenderMesh { mesh = mesh, material = worldManager.material });
anyone else have an issue with intellisense when using Entities.ForEach? it doesn't seem to track the type arguments correctly, but in normal lambdas it does
hmm when you access the param in the lambda?
@stiff skiff I guess one could just make bookmarks of the specific packages and poll them too
Hey guys.. Ideas on how to do RTS style drag select?
My options I've thought of
- All selectable entities are to have a "screen position" which is Camera.WorldToScreenPoint
- Calculate the camera frustum and figure out a Unity.Physics query somehow
Yeah, but considering "packages" is now the new delivery method for features. I assumed it would have a place to subscribe for updates
Any others I havnt thought of?
@coarse turtle yeah, as in here, t.Value doesn't pop up in intellisense, even though it's the correct thing
interestingly if I cause a syntax error by removing the parentheses at the end, it works
o - yeah I think I have the same issue
I wonder if it's a VS issue or something with Unity's integration...