#archived-dots
1 messages ยท Page 136 of 1
I'll likely maintain that repo - I don't think I'm jumping on UIElements soon for runtime stuff - but who knows
Like I still can't figure out an adequate 2D solution for animation that isn't extremely involved
extremely involved or extremely generic like animated 1 BN Sprites!
haha that too..
@dawn badge from the 2D sample what I understood how it could potentially work was relinking the texture entity to your 2d entity over time ๐ค
pretty sure they'll have a better workflow down the line lol
Yea I am probably going to go with a sprite sheet and just change position after a certain amount of time
but learning the inner workings of how to render everything is kind of difficult with the current set of docs
ah yea - I was confused at how the conversion pipeline added the SharedTexture/SharedMaterial to the entity with subscenes
I kept getting a null reference so I havent looked at it lately ๐ค
I might just load individual sprites as materials on my main class and swap based on health/animation step
unclear..
Sooo its able to attach dynamic buffers to entities right ? This can be used for lists.... but what if i want to attach a Map to a entity ? :/
Ahhh nevermind... im gonna choose a different approach
Btw... can i use Entities.ForEach with IBufferElementData ?
yes
What batch size should I select?
Ehh that's a bit broad of a question, but just wondering if there's a "decent for all" approach to it.
if you don't specify, I believe it defaults to 8.
Really dependent on how much you expect to be in there
finally found the bug in burst thats been crashing my editor. Stackalloc in burst will give Invalid Instruction exception, worked fine before.
how could I go about writting to multiple NativeArrays at once in a IJobParallelFor (already using the index in execute for something else) ?
I thought of using a NativeQueue with the available indexes at first but we can't concurently Dequeue..
TIL GameObjectConversionSystem has the method DeclareAssetDependency since 0.9 - big deal if you're working with ScriptableObjects and Livelink.
Crazy question. This works:
using Unity.Entities;
using Unity.Mathematics;
[GenerateAuthoringComponent]
public struct HexCell : IComponentData
{
public float3 HexPosition;
}
This doesn't work:
using Unity.Entities;
using Unity.Mathematics;
[GenerateAuthoringComponent]
public struct HexCell: IComponentData
{
public float3 HexPosition;
}
The only difference is the space before the semicolon. Does GenerateAuthoringComponent really depend on a space before the semicolon, or is something else going on?
๐ค
What do you mean it 'works' tho, what error does it give if it doesnt 'work'
Afaik, GenerateAuthoringComponent creates a script called "XAuthoring" where X is the name of the component so HexCellAuthoring for your case, so it you already have a script called HexCellAuthoring there will be collision.
I really doubt 1 space will make it work or not ๐ค
Yea Editor/IDE should auto format
the 1 space actually does make a difference - they're not using proper parsing yet
there's a forum post about it somewhere
(unless they fixed it in a recent version of entities and I'm unaware)
I mean if I don't put a space and hit save it adds it in (VSCode)
@opaque ledge, sorry I wandered off after asking about the space around the colon earlier. It looks like Timboc answered my question. It manifests in two ways. If you try to drag the script onto a gameobject in the editor, you get a warning that <class name>:Authoring does not exist. If you fix the formatting, attach the component, then break the formatting again, it shows up as a broken component in the inspector view. I think there's supposed to be some code-gen happening at build time, but it doesn't trigger if the colon isn't quite right.
It seems crazy on two fronts. First, that they successfully parse a language as complicated as C#, but mess up this one small piece of it. Second, [GenerateAuthoringComponent] is an attibute. I would think anything they do with it would happen at runtime, way after lexing.
huh
wonder if this really was on Burst 1.3.0p10:
Cache of Burst JIT compiled results in the Editor to the disk, so that reloading after an editor restart should be faster
I didn't see it mentioned on the changelog
this post lists it as it's feature though: https://forum.unity.com/threads/burst-new-release-1-3-0-preview-10-we-need-your-feedback.874543/
EntityManager.GetName() doesn't work in builds (it gives me errors when I try to export the game). Anybody has the same problem?
it is editor only thing๐ค
@warped trail it stop building, it says I have to solve the errors
@wide fiber you have zero need for entity name on build, it's extra so they don't want to support it there by principle
it's purely for visualization anyway
It's really weird that my game runs fine on device but would crash in editor play mode.
I suspected it had something to do with Burst/Job so I tried moving my code to MB instead.
same thing happens to me, i reported it but no answer so far, been 2 weeks
Somehow that still crashes the editor.
The code is basically a simple language interpreter, and it goes something like
float Execute(...) {
switch (func) {
case Add:
return Execute(...) + Execute(...);
// more stuffs
}
}
I attached debugger and stepping into it one by one, and I think around the 5th layer deep it somehow went from Execute to Unity's debugger code, and then somehow went to CanvasScaler code.
I'm completely baffled and just going to accept that no editor play mode for this project ๐ข
I have a prefab. If I put it inside the scene (manually, by dragging it inside the hierarchy), it works normally. If I spawn it through the code the Pathfinding script that I have gives me some weird errors.
Are manually put in the scene and instantiated through code entities different?
I have a fun usability question. How do you do a query, or get a collection of components, outside of a system?
So far I've done this by having the code in question call into a system, which makes me the data I want, and returns it
But since querying for something, even if only once, adds the query to a cache it starts requiring it for its Update cycle.. this might not be the best approach
EntityManager.CreateEntityQuery(typeof(Translation), typeof(Rotation));
But since querying for something, even if only once, adds the query to a cache it starts requiring it for its Update cycle.. this might not be the best approach
@stiff skiff what do you mean requiring for its Update?
@opaque ledge how did I miss this... thanks!!
@fleet hemlock if I understand correctly, queries made through GetEntityQuery are added to system's list of queries made. Which is checked in ShouldRunSystem
Though this is overridable by specifying specific queries to be required, or marking as "always run"
i see. good to know
Do you guys know how to access entity inside IJobChunk?
I have only found information about how to access entities' componentData inside Execute
using GetNativeArray?
how to define ArchetypeChunkEntityType?
like this? ๐ค cs public struct ChunkJob : IJobChunk { public ArchetypeChunkEntityType EntityType; public void Execute(...) { var entities = chunk.GetNativeArray(EntityType);//NativeArray<Entity> } } protected override void OnUpdate() { var tmp = new ChunkJob { EntityType = GetArchetypeChunkEntityType() }; }
SystemBase.GetArchetypeChunkEntityType() - should be it
anyone knows if WithNone works AND or OR for multiple types?
@warped trail thx for reply. how can I define which entity is the right one for that specific componentData?
{
public ArchetypeChunkEntityType EntityType;
public ArchetypeChunkComponentType<MyDataType> myDataType;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var entities = chunk.GetNativeArray(EntityType);//NativeArray<Entity>
var entitiesDatas = chunk.GetNativeArray(myDataType);
//How TO Loop?
}
}
protected override void OnUpdate()
{
var tmp = new ChunkJob
{
EntityType = GetArchetypeChunkEntityType(),
myDataType = GetArchetypeChunkComponentType<MyDataType>(),
};
}```
they are all arranged sequentially 1 to 1
same index give same components for an entity
for (var i = 0; i < chunk.Count; i++)
{
var entity = entities[i];
var someComponent = someComponents[i]
}```
{
var entities = chunk.GetNativeArray(EntityType);//NativeArray<Entity>
var entitiesDatas = chunk.GetNativeArray(myDataType);
for (int i = 0; i < entities.Length; i++)
{
var entity = entity[i];
var data = entitiesDatas[i];
//mutate data
ecb.SetComponent(entity,data);
}
//How TO Loop?
}```
you don;t have to use ecb๐ค
Does SystemBase.GetArchetypeChunkEntityType() only get a general Entity Type? Which only defines the class of Entity? Is this type ArchetypeChunkEntityType always
fixed๏ผ
Can I use parallel job for the loop inside IJobChunk?
.ScheduleParallel( ) yep
Hallo guys. I kinda need some help again from the community regarding dots. I am not getting the idea of the WithAny<T> function within Entities.Foreach. Entities .WithAny<SomeTag>() .WithAny<OtherTag>() .ForEach((Entity entity) => { if (SomeTag) { // do magic } else if (Other Tag) { // do other magic } }).Schedule();
Is there a way to ask which component exist?
@digital scarab ah ok thanks for the link. I read that you can't access the component though in the lambda function. So I will really have to split it into multiple jobs than. But thanks ๐
The thing I found not so obvious at first @humble falcon (just in case it helps) is that at least one of the tags specified in WithAny must be present
@amber flicker what do you mean that it has to be present? Do you mean that lets say either one of the tag component has to exist? If yes. How can I check within the lambda function if the component exist?
Ok so the WithAny helps define the conditions under which the lambda will run. If you want to check within the lambda whether the component is present you need to use HasComponent<SomeTag>(entity) - under the hood this uses ComponentDataFromEntity - it's good to be aware it's a random access but it's still very fast
@amber flicker Yeah it sounds like a good solution. I will try it out. Thanks ๐
Is there a way to run a system every second instead of every frame ?
i do it by, having a system that creates a singleton (lets call OneSecondTag) every second and have my system that needs to run every second require OneSecondTag singleton to run
then i have an another system that destroys the tag when it spawns (therefore it only remains for 1 frame)
@amber flicker Ah something to add. How do I call HasComponent function within a lambda expression. Because I am getting an error that it is only possible with Run() and WithoutBurst().
Thats a cool idea ๐ I need to increase a progress bar in my case... for example a progressbar should take 7 seconds to finish... is there a way to calculate how much that bar needs to get increased each step ? In this c ase i wouldnt need to code such a huge infrastructure
are you using SystemBase? you shouldn't be using e.g. 'EntityManager.HasComponent' - simply HasComponent inside systembase @humble falcon
Another good example are waypoints... when a entity should take exactly 7 seconds to move to the target...
or myProgressBarEntity.TweenProgress(100f, 7f); with a future dots tween lib ๐ #shameless
@amber flicker ah ok yes I was using EntityManager.HasComponent. I couldn't find HasComponent within Foreach. Only as you say outside foreach in the OnUpdate(). Maybe I missed something.
can you share code via hastebin or similar? You should be using SystemBase not ComponentSystem or JobComponentSystem
@digital scarab Thanks ! Thats exactly what i could use ๐
oh no, guys I need your help again. I know I am a leech
what is the equivalent of [NativeSetThreadIndexAttribute] for Entities.ForEach?
it has a special name.. 1 sec
@amber flicker yeah sure. https://hastebin.com/atovotojos.cs the code within onupdate
can you put the code outside OnUpdate too?
oh is this in a monobehaviour update or something?
I can technically put it outside the foreach function. but wouldnt it be slow
?
no it is in systembase
I just meant could you include the code with the SystemBase so we could see that. Which version of entities do you have?
@scarlet inlet https://docs.unity3d.com/Packages/com.unity.entities@0.9/manual/ecs_entities_foreach.html#special-named-parameters
@warped trail thanks, I was checking the documentation, I am not sure I will figure out the paramters without an example
unless I have literally to call the parameter int nativeThreadIndex
did I get it right? Must actually be called in that way? SHocking!
where is the mindblow smiley
I guess it makes sense once I get used of it ๐
@amber flicker I am using the current entities version. https://hastebin.com/yezarajaju.cs
0.9.1? You really should just be able to delete the EntityManager. from inside the lambda
Yes. I want to delete EntityManager within lambda but than there is no HasComponent<T>(entity) only if i write it outside the lambda.
you're missing a semi-colon on line 14
ok the reason why it says HasComponent doesn't exist is because there are other issues too
ah yeah thanks. Btw. Is it because the Tag component doesnt store any value that i cant use it?
you can also delete line 53 - comment out the HasComponent lines and get the rest compiling first
@amber flicker Yeah the codes in hastebin has lots of errors. I just simplified the code so i didnt copy and paste right away ๐ weird. Somehow I am not getting any error anymore after some adjustment you said to me.
Before I coudnt call HasComponent within the lambda.
Glad you got it working ๐ - the intellisense error is a bit misleading if there's a problem somewhere else in the code
my intellisense cant 'sense' the components that i get with ForEach query ๐ฆ
@opaque ledge they fixed this in 16.6 if you are using visual studio๐ค
Have you imported your Components? I use different namespaces for comp/systems so if I pull the namespaces in, intellisense can infer the type. To be fair I use VSCode so YMMV
General question about Components. Say I have 200 enemies, one dies, how to I undraw it, or how do I remove it from my collection?
Graphics.DrawMesh(
playerMesh,
translation.Value,
rotation,
playerMaterial,
layer
);
Can't seem to find a method to remove the mesh?
I would prefer to just set a property to 0 and undraw the mesh
is 16.6 preview ? i am using normal one latest
@opaque ledge yes
ah okay thanks
Is it possible to have generics in SystemBase lambda, or do I need to specify IJobForEach's for it?
Can I somehow create a prefab with a ConvertToEntity component and at runtime instantiate the entity directly from its archetype without having to create an instance of the prefab each time?
I feel that there might've been a breaking change somewhere in ecs
I've been on ecs 0.4 or something a bit ago, just upgraded to the latest release
@bold pebble you can convert at runtime and put the converted entity to a component or shared static or whatever then you can do EntityManager.Instantiate(convertedEntity), this is what i do for my prefabs
Basically, I have some systems that are executed in a particular group (via the attribute) and the group has disabled auto-creation (also via the attribute)
What I would do is create the group at one point and poll it via its Update method
That got my systems running, cool n good
That being said, Topher said that they are working on making entity prefabs much easier later on
This doesn't seem to work in the latest ecs version though
The group creates just fine, but it has no systems in it
What's wrong with that? Is it even wrong at all?
Because using CreateSystem for all of the systems sounds super fun
@opaque ledge How do I convert it at runtime? Just have one instance of the prefab in the scene? And how do I then access the converted entity?
with using GameConversionUtility class or smth, let me find my script as an example
Ah, GameObjectConversionUtility
ah nvm you can do it via authoring
you use IDeclareReferencedPrefabs interface
[FoldoutGroup("Prefabs")]
[LabelText("Pirate")]
[SerializeField]
private GameObject piratePrefab;
[FoldoutGroup("Prefabs")]
[LabelText("Trade")]
[SerializeField]
private GameObject tradePrefab;
[FoldoutGroup("Prefabs")]
[LabelText("Police")]
[SerializeField]
private GameObject policePrefab;
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
Shared_CampaignPrefabs.TraderPrefab.Data = conversionSystem.GetPrimaryEntity(tradePrefab);
Shared_CampaignPrefabs.PiratePrefab.Data = conversionSystem.GetPrimaryEntity(piratePrefab);
Shared_CampaignPrefabs.PolicePrefab.Data = conversionSystem.GetPrimaryEntity(policePrefab);
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
referencedPrefabs.Add(piratePrefab);
referencedPrefabs.Add(tradePrefab);
referencedPrefabs.Add(policePrefab);
}```
in here i am just putting into Shared Statics, but you can also put it into a singleton component
blobAssetStore = new BlobAssetStore();
GameObjectConversionSettings settings = new GameObjectConversionSettings(World.DefaultGameObjectInjectionWorld, GameObjectConversionUtility.ConversionFlags.AssignName, blobAssetStore);
testTargetEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(testTarget, settings);
and this is how you do in runtime, this snippet is from a monobehaviour
you have to dispose blobAssetStore in OnDestroy method(or rather whenever application ends)
@opaque ledge Thank you very much for the hints!
I feel that there might've been a breaking change somewhere in ecs
I've been on ecs 0.4 or something a bit ago, just upgraded to the latest release
Basically, I have some systems that are executed in a particular group (via the attribute) and the group has disabled auto-creation (also via the attribute)
What I would do is create the group at one point and poll it via its Update method
That got my systems running, cool n good
This doesn't seem to work in the latest ecs version though
The group creates just fine, but it has no systems in it
What's wrong with that? Is it even wrong at all?
Because using CreateSystem for all of the systems sounds super fun
This is Kolyasisan's post btw putting it for visibility
The reason why I do the polling manually is because I use my systems for some rendering stuff
So I can't just get rid of the DisableAutoCreate attribute
@opaque ledge I could successfully implement it with your method. However I had to make sure to remove the ConvertToEntity component from my prefab. Otherwise Unity will crash if I instantiate the entity (2020.1.0b5) ๐ฎ
does it build for other platforms ?
in burst manual its says macOS to IOS is supported, even if it wasnt it would still built, but perhaps you hit a bug
Yeah the project builds fine on Windows for Android
I don't have experience working in macOS at all so I'm not sure if I missed anything.
I have done the xcode-select --install already.
ah no idea then
In this session we'll talk about how our partnership with ARM helps bringing the power of the Burst Compiler to Android, enhancing multicore processor performance and power management. You'll learn how Burst grants ahead-of-time compilation of critical C# code to native code a...
Frolic here, guys?
So I'm using Entities 0.9.1-preview.15 and the following archetype gets created, but nothing is rendered on screen:
EntityArchetype beeType = m_EntityManager.CreateArchetype(
typeof(BeeComp),
typeof(RenderMesh),
typeof(Translation),
typeof(Rotation),
typeof(Scale),
typeof(LocalToWorld));
I have given the Mesh the standard Unity cube and the Material a material I made. Am I missing a component to showcase the render? Or is it something else you think?
m_EntityManager.SetSharedComponentData(entity, new RenderMesh()
{
castShadows = ShadowCastingMode.Off,
mesh = BeeMesh,
material = BeeMaterial
});
pretty sure you are missing WorldRendererBounds component there which is required by HybridRenderer
I want to ask my question again
Recently I switched from ECS 0.4.0 to the latest version and I feel that there might've been a breaking change
I use ECS in my project for some rendering features. Previously I had some systems executed in a custom group, which had the [DisableAutoCreation] attribute on it, which prevented it from being initialized by default
Then I would just create the group with GetOrCreateSystem<> and poll it. It worked fine
That doesn't seem to be working now.
When I create the group in the latest version of ECS the group is empty. It has no systems in it.
Is this a normal behavior? If so, how do I deal with it?
I don't want to just do AddSystemToUpdateList on all of the systems and go back to it every time I add some more, it's a very awkward thing to do.
I guess perhaps not many people do this. Could be worth posting on the forums if this change is considered a bug or intended. As for me, I need to do a similar thing for edit-time non-subscene stuff - I use reflection.
Which I guess is probably how the existing attributes work anyway
@fringe sinew I understand you might want to avoid reflection at runtime but on the off-chance it's useful or helps get you going again, I use something like this:
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(World.DefaultGameObjectInjectionWorld, systems);
ScriptBehaviourUpdateOrder.UpdatePlayerLoop(World.DefaultGameObjectInjectionWorld);
``` DefaultWorldInitialization also has a GetAllSystems method but I think [DisableAutoCreation] systems aren't included in that
Reflection is fine, yeah, ECS uses a chuck full of it during initialization. I might use it too, but I just wonder why it broke in the first place
It worked just fine on 0.4.0 and newly created groups already had components also created
If it's not a bug, why was the behavior changed?
That's what I wonder about
Not sure you'll find that answer here - slightly more chance on forums with more staff monitoring it
Yeah, already wrote there
@naive parrot will try that thanks
Though why would you ever have a mesh with a texture without having it render on screen?
Seems weird
What does that particular component do?
WorldRendererBounds is automatically created for you (there is a system for that), but i do remember an Unity staff saying that you shouldnt create renderable stuff from code, you should instantiate from a prefab
(first post)
But then it isn't really pure ecs any more is it?
And the code I presented above have worked in a previous version of ECS so I was very confused when nothing rendered to screen
So...to use ECS programmatically, don't?
Just make prefabs?
How can I call a non-static function in a Foreach with burst?
HasComponent is a non-static function and I can use it with burst, but if I make a function and I try to call it from the Foreach it gives me errors
I need to use the entity manager inside the function, so I want it to not be static
Has/Get/SetComponent are part of SystemBase, and Unity generates a code from your ForEach
You cant use Entity Manager inside ForEach (with burst) since its a reference type
Ok.. I was trying to make a GetChildrenWithComponent function, why Unity hasn't provided an easy to use function to get the children entities that have a component :(
I don't think children entities make sense, that seems straying away from "data oriented"
you can have "DynamicBuffer<Child> children" in your query and check if they have a component or with HasComponent<X>(children[i].Value)
Or another potential way is to let children have a parent component.
Well it depends, normally it should be done as Burrito said, but if there is a need of hiearchy and child has a render component that needs to move with parent then you add to Child buffer, this is how its done if you convert a prefab for example
DOTS Editor got 0.5.1 update, but its only for "Updated package depenencies"
Reposting in case someone knows https://discordapp.com/channels/489222168727519232/497874303463850004/704823189951217704
So...to use ECS programmatically, don't?
@tardy locust Only thing changed is RenderBounds component now not adding automatically by HybridRenderer system. You should only add RenderBounds to your archetype and set proper AABB because in other case AABB will be in pivot and frustrum will cull your mesh when pivot out of screen. I explained and showed every thing here https://forum.unity.com/threads/issue-with-rendermesh-component-mesh-not-displayed.835858/#post-5524012 (can read whole thread)
okay
WorldRendererBounds is automatically created for you (there is a system for that), but i do remember an Unity staff saying that you shouldnt create renderable stuff from code, you should instantiate from a prefab
@opaque ledge RenderBounds enough, Chunk and World render bounds will be added automatically if you have RenderBounds
@opaque ledge that's what I am trying to do but I want to be recursive (to search also in the children of the children...) and I want to put it inside a function. But I can't use burst :(
You can use static functions.
then do GetBufferFromEntity<Child> to access the child buffer of every entity
why not just a custom implemented RecurseChildren(BufferFromEntity<Child> children, Entity current) function?
You can even flatten the recursion
Have a NativeList of entities you want to process, process one from the list, if it has children then add the children to the list, then process next.
that too
@lusty otter that's what I am doing.. but I am using NativeQueue instead of NativeList, I hope they are faster
@opaque ledge if the entity hasn't got the buffer Child and I call GetBufferFromEntity what happens? How can I check if an entity has a buffer?
@mint iron did you have issues with this? Editor: "Generate all .csproj files" setting needs to be toggled on every startup for all the csproj files to actually be generated.
(fixed on 2020.1.0b7)
or was it some other related issue
@lusty otter how? How can I call GetBufferFromEntity inside a static function?
Some sanity checking here and asking for help. I want to spawn a lot of bees and then move them to a random position on screen to sort of test some technical limits on my hardware.
protected override void OnUpdate()
{
float deltaTime = Time.DeltaTime;
NativeArray<Entity> Beentities = m_EntityManager.CreateEntityQuery(typeof(BeeData)).ToEntityArray(Allocator.Temp);
for (int index = 0; index < Beentities.Length; index++)
{
BeeData bee = m_EntityManager.GetComponentData<BeeData>(Beentities[index]);
Translation translation = m_EntityManager.GetComponentData<Translation>(Beentities[index]);
Job.WithCode(() =>
{
float3 target;
if (targetPositions.TryGetValue(Beentities[index], out target))
{
if (!translation.Value.Equals(target))
{
// move towards targetPositions[Beentities[index]]; ??
}
}
else
{
float3 randomLocation = rnd.NextFloat3(new float3(-20, 0, 0), new float3(20, 20, 20));
targetPositions.TryAdd(Beentities[index], randomLocation);
}
}).Schedule();
}
}
But I can't quite figure out how I'm going to figure out if a bee is at the final location and how I figure out how to move it towards a location, if it's not. With traditional gameobjects I'd use something simple like "MoveTowards" but what would be the Unity ECS equivalent?
GetBufferFromEntity returns BufferFromEntity struct, iirc it has a "Has""Exists" method for checking if that entity has Child buffer
You can check if a buffer exists on the entity by using the Exists functionality @wide fiber
EntityManager.Exists(whatShouldIPutHere);
Isn't it a Exists<T>() ?
๐ค cs var temp = GetBufferFromEntity <T>() Entities.ForEach(()=> { tmp.Exists(entity) })
You can still use MoveTowards function inside ForEach, you just convert the result from Vector3 to float3 and put it into translation.Value
also where does targetPositions come exactly ?
It's a map
public class MoveBeesSystem : SystemBase
{
private EntityManager m_EntityManager;
private NativeHashMap<Entity, float3> targetPositions;
private Random rnd;
ah ok
I was thinking it would just be a simple way to keep track of all bees target location right now
It wouldn't be the solution long term
you simply lerp between current position to target position
But to do that, I'd need a Time
And I don't have a time
It's not a set time to go from A to B
okay so, BeeData has the speed ?
Yes
in my naive tests GetComponent<T>() was faster than hashing and getting values with NativeHashMap๐ค
Does that scale?
Ok thanks
i think its much better if you do this with ForEach instead of Job.WithCode, and put target position as a field into BeeData or independent component
float3 newLocation = Vector3.MoveTowards(translation.Value, targetPositions[Beentities[index]], deltaTime * bee.Speed); ?
Isn't using Jobs faster?
You could do something like that
or position += math.normalize(destination - currentPosition) * speedOfBee
What is the difference between Job.WithCode() and Entities.ForEach then?
Job.WithCode is like IJob, Entities.ForEach is like IJobParallelFor
Oh I see.
you can think ForEach job is specialized for ECS usage, while Job.WithCode is an IJob
and Entities.ForEach is just IJobChunk under the hood
So like this..?
Entities.ForEach((Entity entity, ref BeeData bee, ref Translation translation) =>
{
});```
if you have a system that should run on per entities you should go with ForEach, your bee system is good for that, as all bees needs to move
yes
Are those three refs automatically injected?
internally it does an IJobChunk
Unity generates a code from your ForEach
So it does an EntityQuery then?
Yes
effectively yes
float deltaTime = Time.DeltaTime;
Entities.ForEach((Entity entity, ref BeeData bee, ref Translation translation) =>
{
float3 target;
if (targetPositions.TryGetValue(entity, out target))
{
if (!translation.Value.Equals(target))
{
float3 newLocation = translation.Value;
newLocation += math.normalize(targetPositions[entity] - translation.Value) * bee.Speed;
}
}
else
{
float3 randomLocation = rnd.NextFloat3(new float3(-20, 0, 0), new float3(20, 20, 20));
targetPositions.TryAdd(entity, randomLocation);
}
}).Schedule();
idk, all i know is it works
but i guess answer is yes ๐
you have to assign newLocation to translation.Value again after calculating
so translation.Value = newLocation
Yes, just wanted to see if I was on the right track
When it generates code it create EQ for system, this is why you can use WithStoreEntityQueryInField(ref _q) and use that _q before ForEach or inside OnCreate
and you have to put WithReadOnly(yourMapVariable) before you do Schedule()
does your system change map values ?
If the bee reaches its destination, I want to give it a new random location
https://docs.unity3d.com/Packages/com.unity.entities@0.9/manual/ecs_entities_foreach.html?q=Entities.ForEach has a good overview for ForEach clause
ah okay then, dont
protected override void OnCreate()
{
base.OnCreate();
m_EntityManager = World.EntityManager;
NativeArray<Entity> entities = m_EntityManager.CreateEntityQuery(typeof(BeeData)).ToEntityArray(Allocator.Temp);
targetPositions = new NativeHashMap<Entity, float3>(entities.Length, Allocator.Persistent);
rnd = new Random();
rnd.InitState();
entities.Dispose();
}
I set it up like this
but like i said, imo just give every bee a destination component, it makes much more sense that way
I'll probably do that later
Just wanted something that works now that I can make better later ๐
the SystemBase has a function GetEntityQuery(EntityQueryDesc) and a few overrides
You know, don't optimise before you got something that works
m_EntityManager = World.EntityManager; is unnecessary ๐ค
๐
I've made one ECS project before and I needed the EntityManager everywhere
So I just went with that hah
the
SystemBasehas an functionGetEntityQuery(EntityQueryDesc)and a few overrides
@coarse turtle Which you can pass to Entities.ForEach yet
My first ECS project. It's pretty bad in retrospect, but was nice to get it to work.
https://gitlab.com/omniowl-public/unity-ecs-2d-life-naive
@tardy locust will your NHM writing safe in context of race conditions?
NHM?
NativeHashMap
I use "TryAdd"
It's not what I'm talking about ๐
he is only doing it for testing
Will be the case in your ForEach when you'll try to write and write\read to the same index from different execution paths?
Should not be possible.
float deltaTime = Time.DeltaTime;
Entities.ForEach((Entity entity, ref BeeData bee, ref Translation translation) =>
{
float3 target;
if (targetPositions.TryGetValue(entity, out target))
{
if (!translation.Value.Equals(target))
{
// move towards targetPositions[Beentities[index]]; ??
float3 newLocation = translation.Value;
newLocation += math.normalize(targetPositions[entity] - translation.Value) * bee.Speed;
translation.Value = newLocation;
}
else
{
float3 randomLocation = rnd.NextFloat3(new float3(-20, 0, 0), new float3(20, 20, 20));
targetPositions[entity] = randomLocation;
}
}
else
{
float3 randomLocation = rnd.NextFloat3(new float3(-20, 0, 0), new float3(20, 20, 20));
targetPositions.TryAdd(entity, randomLocation);
}
}).Schedule();
The same index is never written/read at the same time
if so your passed in to ForEach map can be .WithNativeDisableParallelForRestriction(map)
Thus you can read and write if you sure in safety and it wouldn't the case of race condition
Oh see your code
nope it wouldn't be safe
you should also multiply by delta time so it will be frame independent
why don't you just store target inside component?
๐
I just wanted to make something that worked right now @warped trail
And that was my first idea
Well as mentioned above you should definitely go through component for target
It will work in your case only if your job will be on thread
sigh =_=
๐
by Run or Schedule, when all your entities will be processed on same thread
you are angering DOTS Gods ๐ฑ
ScheduleParallel will cause race condition in that case
It's just frustrating. I got the idea this should be as simple as I presented it.
But then it isn't and I have to rewrite shit =_=
No it won't work. It won't make use of the system as intended which is the whole point.
just store it it inside component๐ค
Because all data will be processed on one (main (Run) or worker (Schedule)) thread sequentially
No it won't work. It won't make use of the system as intended which is the whole point.
@tardy locust It will, but it wouldn't be multithreaded
It work ๐ But work on one thread ๐ If it "won't work" it doesn't work anywhere ๐
We are talking ECS here
If it doesn't use multithreaded functionality like this, then it's as good as not working.
Might as well not bother
Either way I'm frustrated. So please stop poking the bear as they say .-.
I'll be back and cooled off
you are underestimating burst๐
The compiler literally told me "DontUseBurst()"
So burst clearly don't want any part of this
ECS it's about data layout in general which give you performance gains as bonus but not as initial point
eizen
You can use burst here
You hopefully got what I meant and isn't obtuse
So please
I get it. And thank you for your time, so far.
i think its because you are doing TryAdd
but yeah go for target position component
thats the proper way
as systems shouldnt have data
Lots of things is the "proper way". That doesn't mean it's where you start.
TryAdd not a problem
As long as you learn i am cool^^ i have been learning ECS for 4-5 months now, and i have to get better everyday
That's fine, but people have got to learn how to let go and let me be frustrated so I can come back and not be frustrated.
doesnt TryAdd introduces try/catch/finally block which is not supported by burst ?
well anyway, gl out there Omni ๐
In UsafeHashMap which data is what NHM uses under hood
The compiler literally told me "DontUseBurst()"
@tardy locust Share what compiler told you ๐
ah, perhaps its because that hash map is class member and he doesnt get it locally, so he is working with class member and not a local catched variable
Yep right
And note about rnd in your case ๐ If you're using Mathematics.Random and your ForEach will be multithreaded - every thread will produce same set of values inside execution path. You should have array of predefined Random struct instances per thread and use them, and don't forget return values back
Its not too surprising that people have this idea that multi-threading everything will make it better. Its pretty much the marketing Unity has been doing, ECS - cachelines, multi-threading, make milliions of stuff at 60FPS!
isnt it true ?
Its not too surprising that people have this idea that multi-threading everything will make it better. Its pretty much the marketing Unity has been doing, ECS - cachelines, multi-threading, make milliions of stuff at 60FPS!
@mint iron Not ECS itself but DOTS ๐ General mistake is people think about whole stack as "It's ECS"
Multithreading and burst can live without ECS completely fine and this is what many people do - not using ECS and just using jobs and burst with existing OOP code.
That's what I ended up rewriting my project too.
My project is extremely simple so using ECS brings more complication than benefit.
it can be process to get some migration paths to ECS
use of all the cores will always be better than not for performance paging @dull copper ๐คฃ
but agree with sentiment
Utilizing multiple core is also energy intensive too, especially on mobile it's a big concern.
hes not wrong, but only when things are done properly. (outside of the obvious mistake there that the work to be done needs to be more than the overheads.). But i mean you can easily have false sharing and a myriad of other issues and see less performance.
Multiple cores not might better performance, you can use multiple thread but with wrong interlock usage it will be much slower than one thread
You can use static functions.
@lusty otter I can't, I can't use GetBufferFromEntity inside a static function
Utilizing multiple core is also energy intensive too, especially on mobile it's a big concern.
@lusty otter opposite ๐ in general it's better because off less CPU working time
And Unity promote that in same way
energy consuming in this case less than betefits of CPU idling
But as said before - proper implementation that's all that matter
because with "wrong" multithreading you'll destroy performance
should get back to that test project
Here is the sitch:
https://www.youtube.com/watch?v=7NEXsKuygkw
I have a bug in there where all the bees decide to become a big blob of a box, but I know why that is. Forgot to change something about the randomized location.
Though what is weird is that some of those boxes just starts vibrating violently in place before they go somewhere else. I'm assuming it's because the random generation doesn't produce a value that's different enough to warrant much movement.
@digital scarab since you have TR, have you noticed that DOTS packages like physics and hybridv2 doesn't really scale well past few cores?
I am trying to make the function static and pass the EntityManager as a parameter (I know it won't allow me to use Burst but at least I can call this function without having a reference to the class) but entity manager doesn't have the function GetBufferFromEntity
Angelo I haven't tried using GetBufferFromEntity, can you use it in a static function of SystemBase?
this is essentially what I'm building a test project for, if I have more than few workers, perf declines
I have to manually limit the worker count to get the best perf
GetBufferFromEntity is a function from a SystemBase @wide fiber
@digital scarab and more threads will produce more bad performance with wrong implementation
because of more context switching
on 23 workers (which I get by default on my 12core), I get like twice worse perf than with 3-4
because of more interlocks ๐
GetBufferFromEntityis a function from aSystemBase@wide fiber
@coarse turtle Yeah I know that, the problem is that I can't check if the entity has the buffer
That's 50,000 bees btw
But with proper usage - of course multithreading better
Because in a system base function I can use GetBufferFromEntity<Child>(true).Exists(entity) to check if entity has the buffer Child
The early days of programming when multithreading is so easy to do wrong and so difficult to do right, most people didn't even attempt it, the performance gain was not worth the development cost.
It's so much better nowadays it's amazing to witness things change.
@tardy locust read above about how you should work with Mathematics.Random
@digital scarab I'm building a test project for this, will post it on forums too once I've gotten some generic cases there. I currently have a tool that lets you adjust and visualize worker amount and also see profiling samplers for dots so it's really easy to tell the cost per system on different worker amounts
@lusty otter if a function is static it can't access to not static values/functions. GetBufferFromEntity isn't static
it's a simple thing but it's harder to see the effect just by looking profiler
I'm actually surprised that dots physics performs like best on 0-1 worker count
Why not pass it to the static function @wide fiber ?
rendering seems to peak around 3-4 workers on my test scene
Not sure which message you are referring to @storm ravine
anything else and perf declines
@tardy locust and second thing I guess you not clamping newLocation += math.normalize(targetPositions[entity] - translation.Value) * bee.Speed * deltaTime;? And it's floating point numbers
Yes
I'm really waiting for the perf improvements on "more typical" game scenarios... in other words... not only for brute force massive scale sims
That's what ECS is for anyway. Bigscale sim
it shouldn't be
There is that pong video from Unity where the author is even like "We are doing pong in ECS. This is pretty overkill though."
@coarse turtle that's what I've done.. (but I can't use burst, EntityManager is a reference, so I can't pass it to the function using burst)
but how unity has showcased ECS has made people think you should only do large scale sims with it
No ๐ ECS not about Bigscale sim, please don't think so.
Oh you should be using EntityManager inside a job @wide fiber
Why do you need EntityManager inside a job
ECS allows you to do more processing seeing as memory layout is better.
This naturally leads to want to do more
aka big simulations
nah
well, I'll just disagree on that ๐
you were saying its what its for
It's side benefit of ECS yes
People really like to be pedantic in here I've noticed ๐
yeah, it does suit that really well
but having things in more optimal way for cpu does benefit smaller scale things too
Because if people think so they will spread this across other ๐
Sure it does
It's already out there
The generalizations always flow better than the specifics
And every one will think about ECS only like its all for bigsim
I don't know. Ask someone to make pong using GOs and using Entities. I guarantee you they'll likely hate their lives a bit after trying to do something so simple in
ECS compared to GOs
fyi update from Joachim on scheduling overhead ```When you have small entity/chunk counts, the overhead of scheduling can be higher than just executing the code with .Run(). Do note, that we are doing a lot of work in order to make that not be so...
Specifically we are:
- Adding support for completely bursted struct based systems. So a system itself can be burst compiled.
- Doing a bunch of optimizations in IJobChunk & JobScheduler to reduce overhead.
Essentially you can say right now what DOTS is truly amazing at is scale on the axis of large entity counts.
But what we are focused on optimising now is speed on the axis of number of systems with small amounts of entities.```
(quote from Timboc's message earlier)
Timboc be lurking
Enough cooks already ๐
Still hi Tim
hi hi
the bursted system is interesting, there is a significant cost to just calling all the base class stuff, branches and before/after update, query checks etc. if that all becomes bursted it will help a lot with system scalability.
ECS exists long before multithreading every thing times ๐ I prefer ECS because of how you structure and architect your code, I used ECS before DOTS things with mono behaviour land ๐
I know that ECS was here long before
As far as I remember some game companies tried to do it in the mid-ninties already
We're talking about DOTS here ๐
And context of ECS here the same
projects that will use DOTS for large scale sims will eventually be a niche
probably more will do it than now because its simply possible now
but even Joachim acknowledges on that post that they need to make this scale better to smaller things too
Yeah would be nice
most games will not be huge mass simulated things
What I think is the longterm goal is to have everything under the hood just be ECS by default and then the user can do whatever
Kind of like the next type of GameObject
something like that yes
I see no reason to teach everyone how to do ECS this way. It's something programmers care about for sure but designers and average Joe certainly doesn't
Somewhere one Joachim crying ๐
Joachim is super Joe
its ultimately a way to get rid of the massive code debt in Unity, re-write the engine and have people be excited about it in the process.
Dots Joe not like GI Joe
for avg Joe they will introduce object oriented technology stack stack
@mint iron Right
stack stack
I want a stack of stacks pls
Scratch that, I want a StackStack of Stacks
or just do the hack with physics joints to keep them in place.. ..can imagine how well that would scale ๐ค
And then you get a stack that flies off into space, colliding with itself perpetuatlly
Probably one of the most fun quirks of game engines imo
the issue really is the lack of cache so things keep drifting all the time
if you want stacking there is Havok๐
btw, i like your bee box, you should keep that as a feature
but it's not stateless and will never be crossplatform deterministic
(havok that is)
only like every networking programmer out there ๐
Every network game
It was a joke..
We're dont understand jokes, we're linear as memory 
still wondering if the burst crossplatform determinism has been pushed to backlog
or if they actually did it but it didn't really work as planned and now they just keep silent about it
Question; I have a system that I want to be able to configure via an inspector, just like I do with GOs. Is this something I can do?
I want to set up random spawn parameters.
No
crossplatform determism was supposed to arrive like 2 years ago already
So I have to hardcode that in every time?
Conversion Workflow
I have these two in my BeeSpawner script which is a MonoBehaviour:
[Header("Debug")]
public float3 LowerLeftCorner;
public float3 UpperRightCorner;
But in my BeeMoveSystem I have no way of bringing those over.
You say conversion workflow. I don't know what that is.
You have your GO MonoBehaviour
this at load converts and in conversion you process things and store it inside blobs, singleton entities, static field (meh) etc.
@dull copper it's not something we're working on right now. It's definitely a feature we want to do (maybe later this year), but it's a significant piece of work and (so far) not as high priority as the other things we're working on. We do listen to feedback though so it's useful to hear that it's something you're interested in.
How can I get a component from an entity as a reference? I want to modify it and automatically apply the changes
GetComponent gives me a copy
simplest thing is to just make IComponentData and set GenerateAuthoringComponent for it, slap that then on your GO with convert to entity script
or whatever those were named
@warped trail yeah, that's kinda been the thing with it as long as I've been asking about it ๐
I do believe they've done some work on it already though
For example we're using Addressables load SO and GO from them async and convert data to entity prefabs with blobs and singleton entities which hold some shared data
@wide fiber you can use SetComponent() which uses ComponentDataFromEntity
And just use that data inside systems by querying it with Require(Singleton)ForUpdate
So I make that setup @dull copper , then what? How do I retrieve that and use it?
Query that
You definitely should start from docs and samples repo. They have described authoring samples
@warped trail There is no way other than this? In the Entities.Foreach when I get a component as a reference it works in this way?
basic workflow is you get something with ComponentDataFromEntity[entity] change it and assign it back to ComponentDataFromEntity[entity] = modifiedcomponent
In samples repo you'll see how they convert things like spawners etc
@tardy locust you may want to go through that Unity's pong tutorial
pretty sure it explains things like these
samples repo is also good if you are fine with just small examples
it's not really highlighting all the possiblities tho
I do hope they make more practical samples some day
The mega city and FPS samples were practically not of any use to me
Way too big
Could not get the understanding of even a fraction of it
sample repo, tiny racer are probably much easier to digest
tiny spaceship too if you want to dive into their 2d content
The entty debugger has a lot of problems, when I am playing the game and I select an entity to inspect, the entity disappears randomly..
I can't inspect entities when I am playing.. (without breaking things)
i couldn't even open megacity, let alone run it, you need a really good machine ๐
I had trouble downloading it ๐
Gives me errors when trying to query
// Private variables
private EntityManager m_EntityManager;
private float3 LowerLeftCorner;
private float3 UpperRightCorner;
public void Awake()
{
m_EntityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity boundaryEntity = m_EntityManager.CreateEntityQuery(typeof(BeeBoundariesData)).ToEntityArray(Allocator.TempJob)[0];
BeeBoundariesData boundaries = m_EntityManager.GetComponentData<BeeBoundariesData>(boundaryEntity);
LowerLeftCorner = boundaries.LowerLeftCorner;
UpperRightCorner = boundaries.UpperRightCorner;
}
just do what 0lento suggested, make a component, slap the authoring component attribute on it, add it to a monobehavior.... profit
I fucking did though ๐
ahh yep, guess i should actually read properly lol
i wonder if the default world is fully constructed
Ik ConvertToEntity is called in Awake
Okay moved it to Start
now I just have a memory leak
But that's at least just because of the query I guess
any time you use Allocator.Something and that something is not .Temp you'll need to dispose it manually.
Yeah I get that. It's just so much more code to do something so simple
I'll do that now I guess
can likely just change it to Temp for now I think (editor restart to hide leak warnings might be necessary though)
it would be nicer in a system if thats possible
I had to make it TempJob at the time
Otherwise it wouldn't let me
I need this on spawn and in my system @mint iron ๐
yeah does a job under the hood ๐ฆ
public class MySystem : SystemBase
{
private BeeBoundariesData _boundaries;
protected override void OnCreate()
{
_boundaries = GetSingleton<BeeBoundariesData>();
}
protected override void OnUpdate()
{
var boundaries = _boundaries;
Entities.ForEach((Whatever data) =>
{
// do something with boundaries
});
}
}
super clean!
Every time I've tried to make a field out of anything
And put it in ForEach
It tells me "You can't do that"
So I have no chance of ever thinking the above solution should work
i think for start you can probably just write the Entities.ForEach() statements with an explicit WithoutBurst()
Get used to structure I'd say
u cant access the field directly it needs to be local var
i wish they would change that cause it bloats the code so much
See I knew that shit wouldn't work
Moving it to OnUpdate
Now I get "The Entity does not exist" ๐
can you post your code
Which part
all of it ๐
This is where I spawn my stuff in a MonoBehaviour
// Private variables
private EntityManager m_EntityManager;
private float3 LowerLeftCorner;
private float3 UpperRightCorner;
public void Awake()
{
m_EntityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
}
// Start is called before the first frame update
void Start()
{
NativeArray<Entity> boundaryArray = new NativeArray<Entity>(1, Allocator.Temp);
BeeBoundariesData boundaries = m_EntityManager.GetComponentData<BeeBoundariesData>(boundaryArray[0]);
LowerLeftCorner = boundaries.LowerLeftCorner;
UpperRightCorner = boundaries.UpperRightCorner;
boundaryArray.Dispose();
This is where I try to initialise my stuff in the system:
protected override void OnUpdate()
{
float deltaTime = Time.DeltaTime;
Random rnd = new Random();
rnd.InitState(++randomSeed);
BeeBoundariesData _boundaries = GetSingleton<BeeBoundariesData>();
Entities.ForEach((Entity entity, ref BeeData bee, ref Translation translation) =>
{
if (Vector3.SqrMagnitude(bee.Destination - translation.Value) < 0.001)
{
float3 randomLocation = rnd.NextFloat3(_boundaries.LowerLeftCorner, _boundaries.UpperRightCorner);
bee.Destination = randomLocation;
}
else
{
float3 newLocation = translation.Value;
newLocation += math.normalize(bee.Destination - translation.Value) * bee.Speed * deltaTime;
translation.Value = newLocation;
}
}).Schedule();
}
NativeArray<Entity> boundaryArray = new NativeArray<Entity>(1, Allocator.Temp);
BeeBoundariesData boundaries = m_EntityManager.GetComponentData<BeeBoundariesData>(boundaryArray[0]);
Wondering how this is supposed to work, I dont think the entity allocated in the boundaryArray is a registered entity to the World
Where should I direct my Animation Questions with the new DOTS implementation? I would assume art, but the new animation package is only something that programmers can make sense of. so do I ask here, or still in Animation?
I do what I've seen everywhere else.
Do a query, get the entity, find the data you want.
Yes, but I dont think that entity is a valid entity in Start. I'm pretty sure that entity is initialized with the default constructor. If you tried m_EntityManager.SetName(boundaryArray[0], "Some Name"), do you see the entity's name in the EntityDebugger?
I don't know how Unity expects me to do what I'm doing right now
I want to have an inspector-like setup so that I can both set the values I want, while passing them to my system, where I can iterate fast (that's the whole point of Unity's inspector anyway), to do this I've been told to make a Data Authoring setup. Okay. I've made a script that holds the two values I want to use at generation and in my system. It is now an entity.
How am I supposed to retrieve it and use it in both cases? Because nothing works right now.
Well Unity samples have entities created through ConvertToEntity or via subscenes.
I'm already using ConvertToEntity
On my game object
In the scene
So it can be converted
have you checked that it shows up in EntityDebugger?
NativeArray<Entity> boundaryArray = new NativeArray<Entity>(1, Allocator.Temp);
BeeBoundariesData boundaries = m_EntityManager.GetComponentData<BeeBoundariesData>(boundaryArray[0]);
this two rows above wrong. If you want get entity outside of system you should create query
and get entity array from query
Where should I direct my Animation Questions with the new DOTS implementation? I would assume art, but the new animation package is only something that programmers can make sense of. so do I ask here, or still in Animation?
@bitter socket depends ๐
if you have only one BeeBoundaries you can just call๐ค var tempBoundaries = GetSinglton<BeeBoundaries>()
void Start()
{
NativeArray<Entity> boundaryArray = m_EntityManager.CreateEntityQuery(typeof(BeeBoundariesData)).ToEntityArray(Allocator.TempJob);
BeeBoundariesData boundaries = m_EntityManager.GetComponentData<BeeBoundariesData>(boundaryArray[0]);
LowerLeftCorner = boundaries.LowerLeftCorner;
UpperRightCorner = boundaries.UpperRightCorner;
boundaryArray.Dispose();
This works. That's a lot of code for something that's a single line in the GO setup.
But it works, I guess.
I'm also curious about set up
wondering if the script with the boundaryArray[0] lives on the same gameObject that gets converted
i think he is overcomplicating stuff himself๐
I'm trying to follow what's being said here
I have a MonoBehaviour that inits all the bees and a system that makes the bees move
if you have only one BeeBoundaries you can just call๐ค
var tempBoundaries = GetSinglton<BeeBoundaries>()
@warped trail inside system, not inside MonoBehaviours
It shouldn't be super complicated to have a single structure of data that both of those can share.
And it appears that it was
I don't see how you can conclude that this is me over complicating things
You need that Monobehaviour with Awake\Start?
i think you should consider using subscene๐ค
I don't know what subscene is in this context.
with subscene you can change component values via editor
Subscenes not solve that. Authoring already solve that
in playmode
I mean there is no need to use subscenes
You need that Monobehaviour with Awake\Start?
@tardy locust
I'm setting up things in it, yes
Well if you need that in your MB this is how it works with entity query etc.
For systems it will be just 1 line var tempBoundaries = GetSinglton<BeeBoundaries>()
maybe he is using mb so he can change values at runtime?๐ค
Painful delivery but there it is
Look at 'em go
I don't think I'll need 50,000 bees but it's good to see what that looks like
Good start ๐ We using 50k+ for armies ๐
Wishlist on Steam: https://store.steampowered.com/app/1272320/Diplomacy_is_Not_an_Option/
In the RTS-game โDiplomacy is Not an Optionโ, you will become a medieval feudal lord in a midlife crisis. Due to your position, you must constantly make hundreds of decisions a day relate...
very cool, how are you using character animation, is it all MB/Animator still or using animation package?
Wishlist on Steam: https://store.steampowered.com/app/1272320/Diplomacy_is_Not_an_Option/
In the RTS-game โDiplomacy is Not an Optionโ, you will become a medieval feudal lord in a midlife crisis. Due to your position, you must constantly make hundreds of decisions a day relate...
very cool, how are you using character animation, is it all MB/Animator still or using animation package?
@mint iron No
inferiority complex intensifies
I wrote custom animation logic with couple of converters and shaders
Most part of our game is custom
oh hey eizenhorn
own physics, animation, navigation
was literally just checking the forums and your thread
I'd like to say thanks for the help from here so far. I get frustrated when shit that's supposed to be simple doesn't work as I thought it would and in fact requires more complexity than I'd have thought reasonable.
It makes me feel like I truly am a fucking dumbass.
And then it adds to the frustration
thats so cool
was literally just checking the forums and your thread
@low tangle yeah, after release will be second big thread, again with implementation tech details, how we evolved with DOTS, because we use it from the beginning of DOTS ๐ How we use Addressables with DOTS, and about our custom solutions, from Fog of war to navigation
looking forward to it then
wish I could've gone as full custom as your game
multi player + modding prevents it though ๐ข
BTW if it's not in yours wish list ๐
In the RTS-game โDiplomacy is Not an Optionโ, you will become a medieval feudal lord in a midlife crisis. Due to your position, you must constantly make hundreds of decisions a day related with city- management and economic development. You are tired of this monotonous and, so...
2020
Well there is nothing new, it's already on Unity official site and forum https://forum.unity.com/threads/unity-ecs-and-job-system-in-production.561229/ ๐ Just as reminder ๐
Where I post from time to time showcase of things implemented through DOTS, and my talks from conferences
Well, only hard thing for me from the beginning was switch mind form many years of OOP to DOD. All other things has nothing special ๐ What you see now it's much more developer friendly than it was at the beginning ๐
In Future it will be more convenient, because it's still in preview ๐
People just should be a bit more patient ๐
How come NativeArray can be used in Burst, while it holds a reference type in the editor?
But as someone like me, who is just getting into this now I can tell you that it feels about as inaccessible to work with as it did 7 months ago when I made an actual project work and even before that when I tried to just learn how it was supposed to work at all
ecs is way easier now but the tooling still sucks ๐
Every thing will be easier for newcomes in DOTS
I like how they got rid of the boilerplate on the code side
Hey @storm ravine I also heard you were adopting UIElements too for you game how was the workflow with integrating it with dots ๐
ecs is way easier now but the tooling still sucks ๐
@dull copper yeah true, switching from DOD to OOP - never ๐
I'd say all of us have been frustrated at times with DOTS - it's new, it's changing, it breaks. Though a lot of us here probably think that actually, although it's very different, it's not necessarily more complicated. Potentially the opposite. So frustration, absolutely, criticisms of the technology - you have to get more specific. Just my opinion.
I do feel it does complicate some interactions way more
A friend of mine put it nicely once, I think; "Unity is trying to make ECS accessible to everyone. Therein lies the frustration with its development."
but I do like the separation between data and systems
And as I've shown earlier
Making an inspector setup with ECS and GOs as it is right now, takes 5 times as many lines of code for every component you want to work this way
it's still like 5x less than it was half a year ago ๐ค
Accessible to developers rather than everyone right? I know I've improved massively as a developer since this push.
I don't really know if preview and heavily wip tech needs to be accessible for all though
its a shame they nuked the ECS visual script
I get frustrated because something that was so painfully simple with GOs has been made very tedious to do with ECS
they nuked it?
Hey @storm ravine I also heard you were adopting UIElements too for you game how was the workflow with integrating it with dots ๐
@coarse turtle Yeah we using UIElements in couple of places, but it's just test mode now, because for runtime it even not released as preview yet, we using unity temporary implementation of drawers from unity
ive allways thought that ECS maps fairly well to visual script due to the fact that most of the systems you make are "small"
And I'm guessing that as time goes on this becomes less and less the problem.
@dull copper yes, it no longer does ecs queries and does systems
Yes it's for DOTS only. That being said, we want to keep DOTS editing very similar to current GO editing. So even though you work in the editor with a familiar GO workflow, all is being converted to DOTS at runtime.
that does sound like ECS thing still
nah its 100% rip
Making an inspector setup with ECS and GOs as it is right now, takes 5 times as many lines of code for every component you want to work this way
@tardy locust well it's you want to use it inside MonoBehaviour ๐ In pure DOTS pipeline GO needed only for authoring
yes
This is probably unrelated, but thought I'd mention it:
Two days ago I tried to download 2019.3.11f1 and the DOTS Editor
It broke the project immediately and made it unable to build
Had to remove the DOTS editor
Then it worked again
Can't say any thing about 2019.3 sorry. We always on latest Beta
@tardy locust might've been a dependency mismatch
2020.1b7 now
Had that issue too not too long ago
hmmm, dots editor should be updated to be compatible with current entities now
Yeah dependencies it's more Package Manager problem than DOTS, they will improve that definitely
yea - I thought it was updated too (havent tested it yet tho)
@amber flicker I want to make it clear here that, I don't think this is a bad thing that Unity is doing. I just wish it didn't have to come with this much frustration doing the most simple things. It's a growth pain, right now, but will turn off a lot of people from even getting into it when you do get further which to me is sad.
I don't use DOTS subscenes now so DOTS editor package does nothing for me
so haven't really used it lately
I'd say this transition seems similar to how ppl felt about opengl -> vulkan ๐ค
I sure hope the upcoming entity visualizing tools will not work only on dots subscene
I mean, I'm afraid they do, but you never know
@amber flicker I want to make it clear here that, I don't think this is a bad thing that Unity is doing. I just wish it didn't have to come with this much frustration doing the most simple things. It's a growth pain, right now, but will turn off a lot of people from even getting into it when you do get further which to me is sad.
@tardy locust Just small note - it's in preview, yeah it can be frustrated, bet in other hands we can affect development in early state, and not when all done in way that Unity decided and released and full rewriting just not the case ๐
but vulkan is still a bit of a disaster? ๐ค
@storm ravine I know it's in preview, but considering how hard Unity is pushing this in their blog posts, it feels far from the case that it should still be considered preview.
Yep how marketing pushing it - a bit misleading for newcomers
@tardy locust that's cool, it's a sentiment I relate to - it's just going to take time and over time you'll see us rant and get frustrated too. That said, "I'm frustrated, here are my pain points, I can see the promise and I'm looking forward to the future" is different to "This is overly complicated".
idk - I havent used opengl lately, I kind of got used to the verbose explicit stuff in regards to vulkan lol @dull copper
public int myVar;
is very much simpler than;
Make a query.
Get the entity.
Get the data.
Dispose the resulting array from the query.
Right?
That's really the crux of what I was frustrated over earlier.
Some things are more complicated. Overall, likely more simple. Give it some time (to get used to it).
technically using public variables was never preferred on gameobjects either
it's the easy way, sure
We tried something similar. Didn't work during user research/feedback from studios. In my experience, and according to the data we have, our target user is not comfortable with queries - "I will break something as I don't know what I'm targetting", "But I just want to operate on that object", etc. were common.
As said previously: we have plans to cater to these workflows, but later. We're trying to ship a good solution first for specific references (let's call that "scripting" - which happens to be in the name of the tool), then we'll have a second look at system authoring, which will probably include some take on visual queries, which ideally would be reusable across multiple tools.
It's for inspector use.
No need to get pendatic over that too now.
Also have to consider how most people use Unity
DOTS does not mean ECS๐
@vagrant surge I have to agree with that quote
I think my point has come across at this point and that I reached an understanding of Tim's side too.
@dull copper well, of course if you ask people who dont know anything about ecs, they just ask for a blueprint clone
I mean I've tried some of the earlier DOTS VS preview and I can't imagine any noncoder being able to understand that easily
but we all know the sheer level of busted blueprint really is
@dull copper well, without any docs...
also this doesn't mean they won't redo that part later on
but they need to have something that artists and designers can just use out of the box
Even coders with docs will be tricky, those restrictions applied through Burst are sometimes hard to get used to / work around
the part that I was most bummed of was them getting rid of the nice C# generation
at least, if I understood it right
lets see, but they are, again, pivoting 180 degrees
it doesnt give a good image whatsoever
it's pretty typical at Unity
I started using Unity since 5.x and I've been under the impression that the editor itself always tries to be "designer first", not "programmer first". Whereas programmers can go do their thing and provider designers with what they need in an easy-to-use interface. The DOTS VS has to be that level of intuitive
you saw the visual scripting that had a leaked package but wasn't for DOTS?
yes, but tools already exist for that
they literally did it all
bolt, etc
and then dropped it before release, redid it for DOTS
Imo now is a fantastic time for making tools and I'm really grateful I'm able to access this in preview... people Like Eizenhorn are blazing the way forward with games but yea, it's very early to be immediately productive at the same rate as MB stuff.
tiny has gone through quite many stages
first they had the typescript libaries and scripting
then they did the c# version
then dots mode with different editor scene format
and now on conversion workflow
I doubt this is the last version either
every step mentioned meant you had to redo your project
editor was before C# Tiny iirc
yeah javascript one had editor
then it changed to C#, still with editor, but BIG drop in functionality
and then they went to 3d dropping the editor and the 2d functionality they had
Yep C# editor was different in comparsion with TS version, until they decided to pause that and use conversion
tbh I've never really had much interest on tiny other than thinking it being fancy concept
Not sure what it is
the ecs editor was only thing I was interested at on it
and even that was total all or nothing approach
i had a lot of hopes for tiny
as a "from scratch" unity rewrite, focused aorund the ecs and dots stuff
a clean cut removing all legacy stuff is a pretty great opportunity
could start by building a fully-feature DOTSbased 2d toolset
Well Tiny will be cool at some time definitely ๐ Now it's too early, they now like DOTS was at the beginning )))
that would allow very small and performant webgames
issue with tiny is that i get the feeling they have no idea what to do with it
I really dislike the hybrid approach they are taking with ECS, with all the converting stuffs.
they have very little focus, and scratch a lot of work multiple times
our target user is not comfortable with queries is anyone clear on what their target personas are? i've been looking but its never explained.
@mint iron blueprint fans
People who can't program
I'd guess artists and designers
yup
The kind of person who would primarily use VS I guess
I mean that's the typical user for visual scripting
our target user is not comfortable with queriesis anyone clear on what their target personas are? i've been looking but its never explained.
@mint iron 3d Artists ๐
Kind of makes sense
okay well thats already lots of different interpretations, all of which have different expectations. Its something they need to be really really clear on, or its going to end badly.
3D artists knows node editors
the thing is that houdini node editors and the likes are much more similar to the concepts in ecs than OOP graphs
for example in houdini, every node is a "data transformation", input->output
I don't think avg 3D artists can wrap their head around to use Houdini ๐
It's not a coincidence that Epic took a page out of the 3D programs books when they made their visual scripting
it's more of a tool for more technically minded people
Yeah node editors, but not ECS way of things ๐
@tardy locust blueprint graphs are an oop model directly based on how unrealscript worked
esentially visual unrealscript
I know
its not like the node graphs on art programs
I mean in easy way. Definitely everyon can learn that, just matter of time
the material graph is much more like that
But the design philosophy behind the blueprint node system (which came from KISMET in UE3 or even before..?) was based on the node based workflow of 3D programs
its not like the node graphs on art programs
@vagrant surge still people keep saying even unreals materials being "blueprints"
rizu's (I remember your old name ๐ ) Houdini sample better ๐
I know, silly right?
heh, rizu is actually my old irc nick, I would have changed the forum nick earlier if Unity forums actually allowed to put 0 at the start of the nickname
ahh IRC, does anybody still use that?
I still occasionally check few channels there
I swear everyone forgot that KISMET is where bp came from
Yeah here in Russia some people still using that ๐
@low tangle Right?
we have this tiny gamedev channel on my old uni + there are some people at #igda.fi I've chatted for a long time
if you peak though bp its still littered with kinsmet refs
not exactly. Kismet mental model was pretty separated from bps
i dont even know what kismet is ๐
irc is practically dead tho
No June is correct here @vagrant surge
there is obviously a shared root, but they are too different
its a evolution
(im fully aware blueprint was even called kismet2 at the start)
earlier versions were very very similar
It's a new iteration of kismet, sure. But the workflow of that came from 3D programs.
yes, but kismet was kinda its own "thing", with manually made custom nodes
blueprint on the other hand is more of a direct translation of unrealscript to nodes
The node based design philosophy was still lifted from 3D programs...it is entirely irrelevant what it became
in fact, kismet was its own system, blueprint compiles to unrealscript VM
blueprint source code talks about kismet all over it
BP's are great for what they are IMO
blueprint is basically the gold standard of visualscript
yeah, wish they did better on the codegen though
I feel like you keep stopping at the topic at the start of this:
Blueprints came from Kismet.
Kismet came from 3D modelling programs.
like had c++ nativization as first class citizen there
The whole node based system is lifted straight out of those programs
the thing is that nativization is done on top of the bytecode
not on top of the graph
And with UE4 Epic even prided themselves on making a Material editor that was 1:1 with 3D programs for that very reason
well no shit you cant just 'run' a graph 1:1
unity visual script first C# versions were looking at the node graph, and outputting code
blueprint compiles into unrealscript
Blueprint compiles to C++ now
and then the cpp converter takes that unrealscript IL, and turns to cpp stack machine
that step is what causes the autogenerator to be this... weird
with the huge state machine
there always is
well, even Unity's IL2CPP and Burst first build to IL and then convert it further
no, but i mean a huge boost @low tangle
That wasn't the topic though
instead of looping on that switch statement, go with gotos
and in fact, computed-gotos
il2cpp output is a monster for almost no gain
The actual topic here is where blueprint came from and this has gone so far off the rails due to goalpost moving that it's a rather pointless discussion ๐
yeah its offtopic af
burst compiles from C# directly, no?
or does it compile from .net il?
clr il
pretty sure it goes through IL
so burst is C# subset -> LLVM-> machine code
Why is it that Entities use .NET 2.0 and not 4.0?
or C# -> IL -> LLVM -> machinecode
burst is clr il -> llvm
so basically same as IL2CPP but bit better
smaller subset
yeah
all the new codegen stuff is done before to generate more clr il
i see
i always thought burst actually compiled C# itself directly
not like IL2PP + lots of restrctions to generate better code
Why is it that Entities use .NET 2.0 and not 4.0?
@tardy locust It use .NET Standard 2.0
Sure...why not 4.0
@vagrant surge
There is not exist Standard 4.0
(from: https://youtu.be/WnJV6J-taIM)
In this session we'll talk about how our partnership with ARM helps bringing the power of the Burst Compiler to Android, enhancing multicore processor performance and power management. You'll learn how Burst grants ahead-of-time compilation of critical C# code to native code a...
.NET Framework 4.0 is different
i see
.net assembly = CLR IL
common language runtime
.NET Framework 4 is part of NET Standard 2
you can view it using the jobs debugger
Yes, it's different...but also allows for a lot of different things that 2.0 didn' no?
So why does entities require 2.0
yeah, it's bit weird to call that .net assembly tbh
but it's meant to be simplified slide
burst inspector*
Yes, it's different...but also allows for a lot of different things that 2.0 didn' no?
So why does entities require 2.0
@tardy locust https://docs.microsoft.com/ru-ru/dotnet/standard/net-standard
Again Net framework 4 is part of Net standard 2
Then why the distinction at all?
Like you look in the Unity Player and it has 2.0 and 4
Why is the distinction there if 4 is part of 2?
its a sub set
standard 2.0 can't use win forms and system .drawing
not exactly those two, but those were some in the past
yea some part of the library doesnt exist in other platforms like nix based systems
its all mono runtime in the end so its mostly converted anyways
I thought the whole point of 4.0 was to move on
it isn't old unity 2.0
If not then that naming convention is pretty damn misleading
Like you look in the Unity Player and it has 2.0 and 4
@tardy locust You miis my messages
It's Standard and Framework
I understand that you are talking about the standard.
But what is the point?
which is the companion to 4.6+
Which point
basically plugin support
Standard it's newest than framework
And it's include that
Why is 4.x there if it isn't supposed to replace 2.0
That is a super misleading naming convention
By the same reason why there was framework 3 and 4 at the same time
When would I want to use 4.x vs 2.0?
if you had an external library that you want to plugin which requires 4.x
I remember using a db plugin once which required 4.x
2.0 also does have smaller codebase, resulting in smaller binaries - altho they did somewhat recently do better stripping code to compensate that
But according to the standard, 4 is in the 2.0 standard?
if you talk about framework alone, you don't even have to think about it in Unity as they completely removed the 3.5 framework already
as for the net standard, I've found 2.0 to be just safer pick overall
some stuff doesn't seem to be compatible with 4.x atm on Unity
4.x is just a misleading name
It seems like it would be newer than 2.0
Regardless of it saying "standard" or not
it's Microsoft problem ๐
This is why they decided create one net standard containing all things ๐
now that there is .net standard 2.1 and the new dotnet 5 coming this year
i assumed it was based on their .Net Core version track, https://dotnet.microsoft.com/download
Free downloads for building and running .NET apps on Linux, macOS, and Windows. Runtimes, SDKs, and developer packs for .NET Framework, .NET Core, and ASP.NET.
well standard was also for mono runtime too
core it cover fully in net 5