#archived-dots
1 messages Β· Page 130 of 1
@mint iron Thanks ! Its already the latest version :/
i was doing some fun shit tho
i was storing meshes
into textures
and then using bindless textures to load many different meshes, of different sizes, allocated separately... into a single drawcall
then i learnt that there are actually bindless buffers and i was just an idiot using bindless textures for that
Packages\com.unity.entities@0.8.0-preview.8\Unity.Entities.PerformanceTests\JobForEachPrefilteringPerformanceTests.cs(146,18): error CS1061: 'MethodMeasurement' does not contain a definition for 'Definition' and no accessible extension method 'Definition' accepting a first argument of type 'MethodMeasurement' could be found (are you missing a using directive or an assembly reference?)
Any idea where the hell this error comes from ?
This setup is a real pain, why dont they simply fix the dependencies ? :c
i was somewhat correct in my earlier assumption that the Hybrid Renderer (v1) does not support Texture2DArrays. i updated my URP packages to 9.0 and it all works π
"does not contain a definition for 'Definition'" lmao
Definition of definition: See definition
downgrade performance package to 1.3x
@opaque ledge You are a demi god...thanks a lot, that did the trick ^^
Well i prefer God-Emperor, but demi god is good as well πΊ
Ignore the demi, probably a real god π
@craggy orbit Thats probably Hybrid Renderer v2 π€
Hybrid Renderer v1 was long long time ago, then it came render mesh v2 and then newest and shinest hybrid renderer v2
π€ i must've misread then. i was using whichever one doesn't require the define symbol for Hybrid Renderer 0.4
@thorny vault Thanks for the info, ill look into it!
Although, I have to ask, would dots netcode be currently suitable for starting development on an MMO?
yeah that should be render mesh v2
How should Input be handled in DOTS?
I am using Input.GetKey(..) in the function OnUpdate (the class inherits from SystemBase) but it doesn't work sometimes
I was thinking about using the new Input System, I will search how to implement it with DOTS
it still should, i am using new input system but old system should work as well
Sometimes it doesn't read the key correctly (when the key is pressed it returns false), it isn't a computer/keyboard problem.. Later I will send the code
hmm it should π€
i mean i did the same, in OnUpdate method i check if button/key is pressed and if so i schedule a job
Sounds like maybe you're losing inputs if your system is not updating. If it's reading input your system should probably have the [AlwaysUpdateSystem] attribute
Otherwise it won't catch input if it has no matching queries
(It is rare, but it is annoying)
what does AlwaysUpdateSystem do π€
It forces the system to call OnUpdate every frame, instead of only calling OnUpdate when it has a query match
The query should match every time, I am not deleting any component.. in a few minutes I will send the code of the input system
Rather than just assuming you can see for yourself, if you add [AlwaysUpdateSystem] to your input reading system do the input drops stop?
there shouldnt be a need for alwaysupdatesystem when using systembase
Sure there is, if you're trying to read input every frame inside OnUpdate and your system has any queries in it then you will fail to read input if the query doesn't match because OnUpdate would never be called for that frame
Thanks, it's working
But I think I will switch to the new input system
The new input system is much better in a lot of ways but it's not integrated with dots any more than the old system is fyi
oh my bad, confusing with alwayssynchronizesystem(hmm might have to look at some of my code)
You still have to read input on the main thread and pass it in, the same way as with the old system
Do you know of any plans for DOTS input system?
anyway @wide fiber theres an example of using the new inputsystem with dots https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/d616c1b077c306e6f31b41a3970799e4b132139b/UnityPhysicsSamples/Assets/Common/Scripts/DemoInputGatheringSystem.cs pretty much copied it for my own uses
Nope. I think there's a webinar thing coming up all about the new input system though, maybe we'll hear something there
i think current input system works fine with DOTS π€
it does, but it also is quite limited compared to the new system
I have a situation I'm not sure how to deal with:
You have three jobs: JobA, JobB, JobC.
Now JobA does some calculations and comes to the result true or false.
If the result is true JobB should run, but if it's false JobC should run instead. How would you structure this?
In my head the only way is to output the result in a NativeArray<bool>, and start both JobB and JobC. Then each job checks the result and the one that shouldn't run will early out. (if this seems familiar I asked it in the GDL discord the other day.)
i mean by current input system i meant new system π
old one called input manager, new one called input system so
exactly Peppe
tho you have to make sure JobB and JobC are depending on JobA
i do hate how more and more names are overlapping with all these new packages π
Yes the dependencies I left out to not make the message too long π
merge JobB and JobC in 1 job and use if inside?π€
Yeah in my case the jobs are ForEach jobs working on completely different components so that would probably make it less readable, but it's an option for sure.
what is dots?
performance by defaultπ
@mint iron btw, do you have any brief example for the event system you created ? i am too scrub to figure out stuff on my own
determinism by default
sure, its not brief though, its complicated so that it can be brief later π
looking forward to it - hoping I can use it to replace my current messaging system in the ui system haha π
sure π
kk, well i have a package sort of ready, lemme just check it still works
haha no worries, take your time - I need to wrap up some preliminary stuff on my side before looking into it π
it would be perfect for me because when ships explode i run an explosion effect
oh wait, you're just talking about events in general
for some reason i thought u meant the InputAction mapping to ecs events
right now i run in a weird method, i run trigger job without burst and 'register' the position to MB, and MB creates/retrieves from pool and run the effect in Update method, kinda weird
oh no, it was a question for your event system that you posted today
yeah heres the example source https://github.com/jeffvella/UnityEcsEvents.Example
it shows how to do UI stuff and spawn particle effects, scene loading etc
InputAction mapping to ecs events this is very interesting π
yeah but.. where is the main event system ?
its included in the example in /packages/ or https://github.com/jeffvella/UnityEcsEvents
alright thanks, well i will check it out, it looks complicated, bunch of scripts π
but hopefully i will figure it out
nah its easy π
π
I get an error "Entities.ForEach Lambda expression writes to captured variable", while all I am doing is querying the Contains method of a nativearray. This should not count as a write. Anyone ever had the same problem?
@obtuse swallow Can you show the code?
@mint iron oh cool, I'll also check you event system out
didn't know someone has coded a package already
@mint iron ok - it's very easy to implement lol π
Sure:
var loadedPositionsComps = _loadedSectionsQuery.ToComponentDataArray<SectionPosition>(Allocator.Temp);
var loadedSectionPositions = new NativeArray<int3>(loadedPositionsComps.Select(component => component.value).ToArray(), Allocator.TempJob);
Entities.WithName("LoadSections").ForEach((in RequiredSectionPositions component) =>
{
foreach (var requiredSectionPosition in component.value.Where(requiredSectionPosition => !loadedSectionPositions.Contains(requiredSectionPosition)))
{
// TODO Create Entity for Section
}
}).ScheduleParallel();
it might be because you're using foreach in a burst job - unless something has changed, you can only do that if its a ref struct enumerator. also using linq? definitely can't use that.
loadedPositionsComps needs to be passed to your job code via WithReadOnly(...) or an equivalent. Also I think you might need to use a TempJob allocator instead of a Temp
you cant do any managed(class) stuff in your jobs, if you want to, you have to do WithoutBurst().Run(), which means it will run on main thread and without burst
has anyone ever had a situation like this:
I have a system, when I set a breakpoint before the foreach, the breakpoint is hit. When I set it inside the foreach, the breakpoint is not hit. Nevertheless, the entity debugger shows that the system is run, takes time and matches the right entities against that system
I'm not sure what the situation is with burst and breakpoints, maybe you have to disable burst while doing that kind of debugging
Since it's doing codegen I'm not sure how that works either
Thanks guys, I'll try to rethink my code to get around all that.
burst is disabled
and normally breakpoints inside the foreach work like a charm in this case
even now, in other systems the breakpoint in the foreach works
ah ok, found the mistake
If I want to make a Follower script (an entity that follows another entity), how can I make a field in the inspector where I can put the entity to follow? As far as I know components can't store references
you can store entity id on a component and do a lookup in your system
Ok thanks, I will try this
something like this will work in SystemBase```cs
struct MyComponent : IComponentData
{
public Entity Value;
}
Entities.ForEach((ref MyComponent component)=>
{
Translation translation = GetComponent<Translation>(component.Value);
}).ScheduleParallel();
I think the problem is more how to populate Value of the MyComponent struct
That's generally the problem I had when starting out
I could do some tricks with authoring (I hope) to get the entity by the GameObject (I am using hybrid ECS)
Leader tag component. Query for it. ToEntityArray(). Get index 0. Profit?
What you can do is, after your conversion system runs, have a query that gets the entity you want, and another query that gets the component that needs that entity. Then it's a simple matter of putting the entity into the component
how do i read entity debugger view? can somone provide some input what all the numbers scattered all around means?
i get the chunk and components aspect.
also wondering about orange line
thanks!
does ECB work with IJobChunk ? to use it in parallel it requires jobIndex as one of its parameter , so is chunkIndex a valid input for that ?
yes
Does anyone have a good link for understanding how to work around not being able to call external methods in SystemBase Entites. lambda? For example I was previously using a ijobforeach where I had convenience methods in the struct, now I cannot .Schedule, I must do .WithoutBurst().Run()
I'm assuming - i think going forward we might have to use function pointers? (Not entirely too sure)
Okay, thank you I will take a look
You can use static methods or just create a struct identically to how the IJFE structs worked. There's examples https://forum.unity.com/threads/deprecating-ijobforeach-good-replacement-patterns.846301/
oh cool π
thanks @zenith wyvern
Is there a easy way to reference entities created with convert to entity?
I have a camera created with convert, and a player created with pure ECS.
I have a IComponentData on the camera to reference the entity its following (player).
The only way I know to do this is to add more components just so i can search with them, which doesn't feel like the right solution.
Alright, i searched but it seems to be a problem with the new preview version of the Entities package.
Does anyone is having the same issue as me with Entities package "Preview.8 - 0.8.0"?
Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Scenes.Hybrid\LiveLink\LiveLinkPlayerSystemGroup.cs(32,59): error CS0117: 'SceneSystem' does not contain a definition for 'GetBootStrapPath'
I'm seriously thinking in downgrading the version i'm using, however i went to some reference problems in my cs files.
My project focus is for android only.
@hollow sorrel thank you. I saw this and i was hoping for a native solution.
I"ll try searching for a while, if i can't find any, i'll try modifying the files and then if still with erros, then i will downgrade (unfortunately).
π’ oh well... downgrading...
Seems that everytime i reopen unity, it undo the changes i did described in the link. So it is futile to do it.
Does anyone have any good learning resources they could share for the dots networking stack?
The best/most up to date resources are in the pinned messages in this channel
Oh sorry you said networking specifically. I don't think there's anything aside from the cube sample and the FPS sample right now
Hmm - I'm not sure if anyone had an issue like this before right?
Library/PackageCache/com.unity.properties@0.10.4-preview/Runtime/Unity.Properties/Utility/TypeConversion.cs(51,25): error CS0234: The type or namespace name 'Unsafe' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?)
Seems to only happen when I add in a custom package... π€
hmmm, very odd.
ah that was dumb - I guess my scoped registry was messed up π
May someone help me out?
I'm runing into this message:
error DCICE001: Entities.ForEach Lambda expression uses something from its outer class. This is not supported. Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! β€οΈ
The system:
using Game.Data;
using Unity.Entities;
namespace Game.Generation.Systems {
public class MapGeneratorTerrainSystem : SystemBase {
private Entity _terrainEntity;
protected override void OnStartRunning() {
Entities.ForEach((in PrefabHolderData prefabHolder) => {
_terrainEntity = prefabHolder.TerrainPrefab;
}).Run();
}
protected override void OnUpdate() {
if (_terrainEntity == null)
return;
}
}
}```
*PrefabHolderData file:*
```cs
using Unity.Entities;
namespace Game.Data {
[GenerateAuthoringComponent]
public struct PrefabHolderData : IComponentData {
public Entity TerrainPrefab;
}
}```
Is it really a bug? I don't know what can i do from here to solve this.
If it is really a bug, i'll have to find another way around this problem.
*aahhh what a pain...*π
@zenith wyvern thank you
@glad solar its complaining about that ref to the _terrainEntity; you can't directly ref stuff outside of the local scope.
all you need to change is to make a local Entity _temp;
run the foreach
then assign the _terrainEntity = _temp; at the end
@low tangle love you! π
The error message should be more straight. Thank you so much!

Leader tag component. Query for it. ToEntityArray(). Get index 0. Profit?
@fallow mason (nope, I want multiple entities to follow multiple targets)
I'm using Unity UI Extensions in a regular project for their Polygons. Can I draw lines / Polygons using dots?
I only need to go up to 20 sided polygon, maybe I could just create a mesh for each? is that a thing?
What you can do is, after your conversion system runs, have a query that gets the entity you want, and another query that gets the component that needs that entity. Then it's a simple matter of putting the entity into the component
@bright sentinel How can I get the converted entity of a GameObject?
I have a Gameobject (the target to follow) field in an authoring component, how can I get the entity of the target?
you have to implement IDeclaredPrefabReferences, in it's method you have to add your gameobject to the list(comes from method) and in Convert method you have to do conversionSystem.GetPrimaryEntity(YourGameObject) which gives you the entity of that gameobject
Thanks :D
Really helpful
this will do the same thingπ€ cs [GenerateAuthoringComponent] public struct MyComponent : IComponentData { public Entity EntityToFollow; }
i think Entity fields doesnt show in inspector, they are not serializable π€
this will generate same code as yours π
hoo it does π
With an IJobChunk what's the difference between Schedule & ScheduleParallel?
no difference i guessπ€
struggling to find an appropriate docs page about which I should be using
i guess they will change it in the future to match foreach methods
yea - going with scheduleparallel - seems to be the one used here https://docs.unity3d.com/Packages/com.unity.entities@0.8/manual/chunk_iteration_job.html
π
nice, good find thanks
this will do the same thingπ€
cs [GenerateAuthoringComponent] public struct MyComponent : IComponentData { public Entity EntityToFollow; }
@warped trail I think entities are not serializable, I am using a Gameobject field, not an Entity field
i just tried it, it shows Gameobject field in inspector
so you are not actually putting Entity to inspector, you are putting Gameobject
just try it π
i guess it will automatically convert it to Entity and put the Entity to that component
Ok
How can I get the magnitude of a float3? A lot of mathematics things don't exist in float3
:D
Interesting. So you wouldn't need to put that GO in a subscene or add ConvertToEntity? It will just convert because it was assigned to a field that will convert?
in your case you will get prefab entity
so not a reference to the GO->Entity I put in there, but a copy?
you will get reference to another Entity if it exist in scene
You lost me. Probably because I have not delved into prefab entities just yet.
prefab entity is just an entity with prefab component
if your GO don't exist in scene, then it will be converted to entity and marked as prefab
if GO is in scene then you will get reference to its entity
but it has to be in 1 scene, no cross scene references π
right, I've come across that error doing other things
i guess this is the way to store prefabs for nowπ€
make a buffer of prefabs in 1 entity
and this prefabs are saved in subscenes, so in the end you get 2 copies of 1 object π
huh, seems undesirable
they say they will fix that in the future
do they get picked up by systems? do you need to filter out prefabs if so?
you have to explicitly query for prefab component to see this entities
ah ok. so it filters itself out unless you ask for it specifically
yes
normally, systems doesnt include the entities that has disabled and prefab components, you have to explicity query for them
and when you instantiate it, it automagically removes prefab component
yeah, I was just thinking that prefab sounds like it acts like disabled
alright, good to know
they do something like this in Tinycs public struct PrefabStorage :IComponentData { public Entity RegularSmokePRefab; public Entity MagicSmokePrefab; }
and i guess you can get every entity which was intantiated with this prefab via LinkedEntityGroupπ€
I am converting the camera to an entity (because I don't want to rewrite some components to work as MonoBehaviour).
I want in some systems to get a reference to the camera: should I put a camera tag and make a query in the systems where I need the camera or should I make a static/singleton class that holds the reference?
there is no ECS camera so you have to make convert mode to convert and inject, then you will simply have the game object, i guess making a singleton class is much better
You should also make an authoring component on your camera object that will add "CopyTransformToGameObject" component which is under Unity.Transform namespace, you can add CameraTag component to make queries on ECS side
you can convert cameraπ
i guess it is converted to hybrid component or somethingπ€
You cant convert camera, hence you do convert and inject π€
if you place camera in subscene it is not destroyed π€
i guess this is how thing will be. If object can be converted you get normal entity, if not then you get hybrid entityπ€
i mean i do remember taking my camera out of subscene because it was destroyed
oh, i liedπ
it is not destroyed when you keep subscene openπ
i hate this thing
i should probably get used to do some subscene thingie, it sounds useful for pure entities
they kinda cool, when they work π
I have put the ConvertToEntity script to the camera GameObject, it gets converted to an entity
I don't know what are hybrid entities
forget what i said, i was wrongπ
Is there a simple of ConvertAndInject ?
I've been going through the ECSScamples, but can only find ConvertAndDestroy used
Yeah weird things happen when you run with subscene open. Things move in the game view, but not scene view.
you mean sample ?
Sorry, *sample
@stiff skiff Just means you will also have the gameobject available
I think I understand a little why, but still an odd halfway thing
well so.. basically Unity converts your gameobject to entity then instead of destroying your gameobject it simply doesnt destroy it
But the GameObject is linked the entity right?
yes it is
The monobehaviours that are attached to the gameobject will also be attached to the entity, specifically
So you can query for them
So with the normal flow, you can spawn a "prefab" by converting it in advance, and then spawning it using the pre-converted prefab entity as a source
you can use CopyTransformFromGameObject, if you want to control the game object and want to have entity part of it sync with gameobject, or CopyTransformToGameObject if you want to do the opposite
Is this also possible with the flow where I keep the gameobject?
Context: I want to spawn prefabs that are partially converted to ECS, some things are still monobehaviour and I dont want to move everything over in 1 go
ah, for that i think you need to use HybridComponents
when you convert a gameobject with hybrid component to an entity it will have CompanionLink which is responsible for creating gameobject side when you instantiate that entity
however i couldnt make it work, so π
maybe you will have more luck
Yeah that will be fun to try
I currently have a system where I already have ECS entities, but want to have GameObject spawned for some of them, and link the object
currently not to bad, but I'm trying to get it working the unity's "Transform" system
so that my ecs entity does not need the managed Transform component
The goal is to close the gap between ECS and Monobehaviours a bit more. Without enforcing either flow
That seems to be what they want from HybridComponent. But like Curly said I don't think it's there yet
You can always do the system data way, when you instantiate your entity you put "WaitForGameobjectProcess" then have a system that queries for those entities and runs with WithoutBurst().Run(), in that system you can instantiate gameobjects and do AddComponentObject to entity. Then you can do another WithoutBurst().Run() with querying that Monobehaviour and your entity and do your processing. Once your entity is destroyed system state will stay so you can query it to detect that and destroy your Monobehaviours(or pool them)
I am using this for World UI for my entities
If you didnt understand a thing, you can read about system states from here https://docs.unity3d.com/Packages/com.unity.entities@0.8/manual/system_state_components.html
I can later on share my code on how i do my UI
does anyone have link to srp github ? for some weird reason i cant find it
oh thanks
Is there a easy way to reference entities created with convert to entity?
I have a camera created with convert, and a player created with pure ECS.
I have a IComponentData on the camera to reference the entity its following (player).
The only way I know to do this is to add more components just so i can search with them, which doesn't feel like the right solution.
May someone help me out?
With my struct MapGeneratorData:
using Unity.Entities;
using Game.Utils;
using Unity.Collections.LowLevel.Unsafe;
namespace Game.Generation.Data
{
[GenerateAuthoringComponent]
public struct MapGeneratorData : IComponentData {
public int MapSize;
public int GenerationSeed;
//public int Phase;
public MapGenerationPhase Phase;
//public int Map;
public UnsafeHashMap<UPosition, Entity> Map;
}
}```
I'm getting this message:
> *ArgumentException: Game.Generation.Data.MapGeneratorData contains a field of Unity.Collections.LowLevel.Unsafe.DisposeSentinel, which is neither primitive nor blittable.*
I tried to switch my enum `MapGenerationPhase` to an int and the `UnsafeHashMap` to int as well, but i'm still getting the error.
*For information about `UPosition`*:
```cs
using System;
namespace Game.Utils {
[Serializable]
public struct UPosition: IEquatable<UPosition> {
public int X;
public int Y;
public UPosition(int x, int y) {
X = x;
Y = y;
}
public bool Equals(UPosition other) {
return other.X == X && other.Y == Y;
}
}
}```
> *float2 from mathematics didn't work either if wondering to use it.*
you cant put native arrays to component datas, they are not blittable
If I am not mistaken, IComponentData does not support any write containers ..
Try use BlobAsset: https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/ECSSamples/Assets/Advanced/BlobAsset
What about only with int types? As i said above:
I tried to switch my enum MapGenerationPhase to an int and the UnsafeHashMap to int as well, but i'm still getting the error.
could a feature be built into Discord Boost to add a turbo to a server via SMS?
i don't get any errors with thisπ€·ββοΈ cs [GenerateAuthoringComponent] public struct MapGeneratorData : IComponentData { public int MapSize; public int GenerationSeed; public int Phase; public int Map; }
hmm.... i'll try to restart unity then.
Few months ago i had a problem using namespace with dots. Without any namespace back at the time i could work without any issues. maybe this could be the issue. I'll try some tests here. thanks guys!
The UnsafeHashMap should work in a SharedComponentData but TBH I'd put it elsewhere. UPosition and then the map could be turned into an IComponentData with an entity buffer
this sounds like a job for BlobAsset
SRP 9.0.0-preview.14 landed earlier this week. I would however recommend waiting until the next DOTS packages land (including hybrid renderer 0.4.2) to get latest bugfixes. This version also has working HybridHDRPSamples and HybridURPSamples projects in the DOTS repository for testing Hybrid Renderer V2.
where is this DOTS repository?π
I'm guessing he things it's public repo π
or he just refers to ecs samples repo
also lol for the too bright lighting on hybrid renderer v2: This is fixed now. But I am afraid it just missed the branch off for the next package release.
so, will be broken on next release too
oh, and b5 is outπ
yup
been testing it as it has improvements on DX12 compute shaders
hybrid rendering v2 is now "only" 0.7ms slower in actual build for me when using DX12
DX12 used to run like 30-40 fps in editor with hybrid v2
now I get 180fps
that 0.7ms is still quite a lot, considering the total cpu time on built project is 3.3ms on DX11 and 4.0ms on DX12
but at least it's not the quarter of the perf on DX12 anymore
but lighting it totally broken in urpπ
also getting this on b5 now:
heh, it goes away after I moved directional light and plane mesh out of dots subscene
oh well
wait, does this auto deletion system work in build?π€
what auto deletion?
deleting an allocation that ....
this is for Allocator.TempJob
or is it just some safety system which works only in editor?
I don't know actually, but it shouldn't happen in the first place π
anyway, I try to force myself to not touch dots subscenes again
they've never been anything but trouble for me
I have another project on backburner that could benefit from them
but I'm simply waiting for DOTS to mature before I even go there
basically would want to use it for streaming bigger world in chunks
i update simulation group at low rate, so i get this warnings from physics DebugStream systemπ
@opaque ledge Bit late, thanks for helping out π Your idea is similar to my current approach
it allocates some TempJob things and deallocates it on the next update, but there is more than 5 frames between updates π
i have no idea how people make their job to work on multiple frames π€
so now i'm wondering, what if i will need information in this TempJob and it will be deallocatedπ€
hmmm
it's not the dots subscene, it started it again when I opened the project again
for some reason it didn't spam that after I deleted dots subscene tho
maybe because your framerate dropped? π
210fps in the editor π€
oh
let me try the different physics update
ok, it is the physics update π
probably from debugstream
woo new packages.. lets see
Is there a easy way to reference entities created with convert to entity?
I have a camera created with convert, and a player created with pure ECS.
I have a IComponentData on the camera to reference the entity its following (player).
The only way I know to do this is to add more components just so i can search with them, which doesn't feel like the right solution.
@loud matrix you can put a public variable of type Entity. A new field in the inspector will be available, you can drop in the GameObject that you want to follow, when the GameObject will be converted, the reference will be updated to his entity
* Added the ability to reimport a SubScene via an inspector button, which forces reconversion.π₯³
o 0.9.0 came out?
yupppp
hooo π
not hdrp though
@dull copper where the notes at π
wow bursted ecb playbacks
ya... pretty sweet
GetSingleton<T> supposedly received perf improvements
Hmmm, so if my Systems work in a specific order π€, which is the default order without touching them, will they work in any other order by default?
@formal scaffold its simply out of your hands, you can use UpdateAfter, UpdateBefore, UpdateInGroup attributes to set that order explicitly
@opaque ledge I don't paste HDRP notes here as they are not related to this channel π
* Improved performance of access to singletons through SetSingletonandGetSingleton in SystemBase (peformance is also improved through these methods on EntityQuery). as it was mentioned the other day
umm, i didnt mean HDRP, i meant all DOTS packages π
What have you done to real Olento, who are you imposter π
hmm time to see if things break between the package versions π€
darn.. getting a bunch Library\PackageCache\com.unity.dots.editor@0.4.0-preview\Editor\GUI\Legacy\Controls\RuntimeComponents\RuntimeComponentsDrawer.cs(26,44): error CS0246: The type or namespace name 'EntityContainer' could not be found (are you missing a using directive or an assembly reference?) guess dots editor may not be compatible
yeah same here ):
oh god, should i downgrade π
it's weird... you'd have thought at some point somebody would test a released combination of packages (esp given all the trouble).. *sigh
## [Entities 0.9.0] - 2020-04-08
### Added
* `public void GetCreatedAndDestroyedEntitiesAsync(NativeList<int> state, NativeList<Entity> createdEntities, NativeList<Entity> destroyedEntities)` detects which entities were created and destroyed since the last call to this method.
* Added the ability to reimport a SubScene via an inspector button, which forces reconversion.
* Added `GameObjectConversionSystem.DeclareAssetDependency` which expresses that the conversion result of a GameObject depends on an Asset
* Added `void EntityManager.Instantiate(NativeArray<Entity> srcEntities, NativeArray<Entity> dstEntities)`. It gives explicit control over the set of entities that are instantiated as a set. Entity references on components that are cloned to entities inside the set are remapped to the instantiated entities.
* Added `void EntityManager.CopyEntitiesFrom(EntityManager srcEntityManager, NativeArray<Entity> srcEntities, NativeArray<Entity> outputEntities = default)`. It lets you copy a specific set of entities from one World to another. Entity references on components that are cloned to entities inside the set are remapped to the instantiated entities.
* Added assembly for Mesh Deformation data structures.
### Changed
* Systems are now constructed in two phases. First, ECS creates a new instance of all systems and invokes the constructor. Then, it invokes all `OnCreate` methods. This way, you can now use `World.GetExistingSystem<OtherSystem>()` from inside `OnCreate()`.
* Systems are now destroyed in three phases. First, ECS stops all running systems (i.e. OnStopRunning() is invoked). Then it invokes all `OnDestroy` methods. Finally, ECS destroys all systems. This means you can perform safe and predictable cleanup of systems with cross-references to other systems.
* EntityCommandBuffer Playback now Bursted through function pointers. When there's a mix of unmanaged and managed commands in a single buffer, unmanaged commands will be Bursted. When there are no managed commands, each chain's Playback is fully Bursted.
* `Entities.ForEach` in a `GameObjectConversionSystem` no longer logs a warning if there are multiples of a queried authoring component on a matching GameObject. It now returns the first component instance of the desired type, so conversion systems can optionally call `GetComponents<T>()` in order to handle multiples if desired.
* Declaring a non-Prefab object as a referenced Prefab during conversion now emits a warning
* Improved performance of access to singletons through `SetSingleton` and `GetSingleton` in SystemBase (peformance is also improved through these methods on EntityQuery).
* Updated package `com.unity.properties` to version `1.1.0-preview`.
* Updated package `com.unity.serialization` to version `1.1.0-preview`.
* Updated package `com.unity.platforms` to version `0.2.2-preview.7`.```
### Deprecated
* Deprecated `public T World.CreateSystem<T>(params object[] constructorArguments)`. Please use `World.AddSystem(new MySystem(myParams));` instead.
* Deprecated `LiveLinkBuildImport.GetHash/GetDependencies/GetBundlePath`.
### Removed
* Removed expired API `TypeManager.CreateTypeIndexForComponent<T>()`
* Removed expired API `TypeManager.CreateTypeIndexForSharedComponent<T>()`
* Removed expired API `TypeManager.CreateTypeIndexForBufferElement<T>()`
* Removed expired API `DynamicBuffer.Reserve(int)`
* Removed expired API `World.Active`
### Fixed
* Fix BlobAssetSafetyVerifier to generate a better error message when `readonly` is used with BlobAsset references.
* Fixed incorrect comparison in `EntityChunk.CompareTo()`.
* `SceneManager.IsSceneLoaded` now works for converted entity Scenes and returns whether all sections of an entity Scene have loaded.
* Fixed Exception in conversion code when trying to delete entities that are part of a Prefab.
* Fixed Hybrid Component conversion failing when multiple components were added for the same GameObject.
* Fixed use of component access methods (GetComponent/SetComponent/HasComponent) inside Entities.ForEach with nested captures.
* Fix compilation issue when `ENABLE_SIMPLE_SYSTEM_DEPENDENCIES` is enabled.
### Security
### Known Issues
* System groups do not currently apply to systems running as part of `EntitySceneOptimizations`
such spam
The Entity field doesn't show up in the inspector in a MonoBehaviour script, help
I dont think Entities are serialized by default
## [Collections 0.7.1] - 2020-04-08
### Deprecated
* Deprecated `Length` property from `NativeHashMap`, `UnsafeHashMap`, `NativeMultiHashMap`,
`UnsafeMultiHashMap`, `NativeQueue`, and replaced it with `Count()` to reflect that there
is computation being done.
### Fixed
* Fixed an issue where `FixedListDebugView<T>` only existed for IComparable types, which lead to a crash while debugging other types.
* Removed code that made NativeStream incompatible with Burst.```
alright removing Dots editor for now and at least it compiles.. not going to miss editor much atm anyway
I forget does DOTS Editor allow usage of Subscenes?
## [Burst 1.3.0-preview.9] - 2020-03-30
### Changed
- Improved the compile time performance when doing `UnsafeUtility.ReadArrayElement` or `UnsafeUtility.WriteArrayElement` with large structs.
- Made some compile-time improvements when indirect arguments (those whose types are too big that they have to be passed by reference) that reduced our compile time by 3.61% on average.
### Fixed
- Fixed a bug where storing a `default` to a pointer that was generic would cause an LLVM verifier error.
- Fixed an obscure bug in how struct layouts that had dependencies on each other were resolved.
- Fixed a bug as found by [@iamarugin](https://forum.unity.com/members/iamarugin.737579/) where LLVM would introduce ldexp/ldexpf during optimizations that LLD would not be able to resolve.
- Fixed a bug where the compiler would not promote sub-integer types to integers when doing scalar-by-vector math (like multiplies).```
Or is that entirely part of Entities base package?
What do you guys think of "public void GetCreatedAndDestroyedEntitiesAsync(NativeList<int> state, NativeList<Entity> createdEntities, NativeList<Entity> destroyedEntities)", can we jobify these, especially for registering children to parents since ecb doesnt give us valid id
oh but now nothing renders haha.. guess you need hdrp 0.9
## [Hybrid Rendering 0.4.1] - 2020-04-08
### Added (Hybrid V2)
* DisableRendering tag component for disabling rendering of entities
### Changed
* Improved hybrid.renderer landing document. Lots of new information.
### Fixed
* Fixed shadow mapping issues, especially when using the built-in renderer.
### Misc
* Highlighting additional changes introduced in `0.3.4-preview.24` which were not part of the previous changelogs, see below.
think dots editor is pretty much only the live conversion preview at the bottom of the gameobject? I still have access to livelink etc
oh ok
I dont think Entities are serialized by default
@coarse turtle what do you mean? They are serializable inside IComponentData script, but they aren't inside MonoBehaviour :(
dots editor is the dots subscene entity conversion preview + lets you add convert to entity through checkbox on top of property inspector
talking of which
they didn't update dots editor on this package dump
and it's broken with new entities package
EntityCommandBuffer Playback now Bursted through function pointers π₯
* Added assembly for Mesh Deformation data structures. What does this mean
no dots editor and nothing rendering unless you get the packages off github (at least I assume that'll fix it).. another great well tested release π ... hoping hdrp .9 shortly follows
@wide fiber well I'm not sure if the Entity struct is serializable...? At least I'm not seeing that in the decompiled assembly
yeah its not serializable, you can serialize the world thru serialization namespace most likely, something something entityremapper, never tried
cool thanks @dull copper
@amber flicker what do you mean, hdrp 9.0 is in package manager?π€
@coarse turtle
this is not entity this is gameobject π
It only works inside IComponentData, not inside MonoBehaviour
its not serialized, that happens because Unity creates the authoring automatically, and puts game object instead of entity
Did you take a picture of your monitor
this is not entity this is gameobject π
@warped trail ok sorry, I am stupid.. I was talking about GameObjects that get converted into entities sorry
put Entity field on somewhere, you wont be able to see it on inspector
Yeah
put Entity field on somewhere, you wont be able to see it on inspector
@opaque ledge that's the problem
why do you need Entity field in MB anyway?π€
Dont you dare to bring logic to this π
I just wanted to say, you dont put Entity directly on inspector, you put gameobject and convert it π
Entity
lmao
I was trying to put a reference to the camera inside a Singleton, but I think I will make the query in the systems where I need the camera (with a tag..)
use singleton for MB access, use camera tag for ECS access
Okok
what about creating special system which will provide camera's data to entities?π€
why everyting bloooooooom hdrp π - oh.. nope, new camera has helped.. still unbelievably buggy
what about creating special system which will provide camera's data to entities?π€
@warped trail I was thinking about performances, in that way I could make only a query for frame
Should I use SystemBase for every system?
Yes, other systems will be deprecated
and what do you mean by query for frame?π€
Some Systems need a reference to the camera each frame, so I need to execute a query each frame (I don't want to cache the entity, it could change)
yea
It wasn't yesterday
it is available in package manager
preview.14
Library\PackageCache\com.unity.entities@0.9.0-preview.6\Unity.Scenes.Editor\BuildStepCreateResourceCatalog.cs(18,51): error CS0619: 'BuildStep' is obsolete: 'Replace with BuildStepBase. (RemovedAfter 2020-07-01)'
:/
Oh I see it shows up if you click the "see all version" arrow
I guess since it's preview
@wide fiber i mean that you can create component like NeedCameraPosition and create system which will take camera position and copy it to every entity with NeedCameraPosition component
Well I don't need the camera, but the camera component (in some of the components where I need a reference to the camera)
But I don't think it will be a problem, or at least I hope
I have a very weird error: https://pastebin.com/b8jupxSy
(Code and error)
I don't think you should be using WithDeallocateOnJobCompletion if you're using Run. It doesn't really make sense since there's no job being scheduled
It looks like the error is related to that so try removing it
you can use .Dispose(JobHandle)
There's no job. Just use Dispose
and you there is .CalculateEntityCount() method in EntityQuery π
Yeah, but you can still get it directly from UPM
Just click the little arrow beside it's name in the package list
ah okay i will try to upgrade then
Ok
Do I have this correct? ```cs
// Reset collision from prev. Frame
Entities.ForEach((ref ColAngle colAngle) => {
colAngle.Value = -1;
}).Schedule();
// This ensures above is done first?
Dependency.Complete();
// Check for collision again.
var collisionJob = new CollisionJob() {
normals = normals,
colAngles = colAngles,
ltw = ltw
}.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, Dependency);
collisionJob.Complete();
The first query is done before the second one starts?
yeah since you're forcing the threads to complete before you schedule the second job on the main thread
You should just use Run instead of scheduling a job. Same result but you avoid the overhead
uhh, why not just chain them ?
What do you mean by chain? Anywhere I can read up on Schedule() and ScheduleParallell() and Run()? I have some questions like:
SystemA -> Uses ScheduleParallel()
SystemB -> Uses Run()
Will A run parallel next to B if I don't use complete()?
Whether it will run parallel depends on if there are dependencies between them, and what else the scheduler happens to be doing when System B runs
By chain he means just don't call complete.
Schedule the jobs one after another and let the jobs system do what it was designed to do
from docsWhen you call Entities.ForEach.Run() the job scheduler completes all scheduled jobs that the system depends on before starting the ForEach iteration.
The whole point of the job system is that you shouldn't be worrying about what the scheduler is doing. You only need to worry about your dependencies
By dependencies you mean which system updates which set of components and reducing overlap there, right?
Yes, properly declare your read/writes on your components and the framework will do most of the work for you
@zenith wyvern i confirmed that checking the other day
its also why launching ecs systems is crazy hyperslow
couse it needs to check if all the inputs (component types) are safe to use
Hopefully they can improve some of the crazy overhead from systems managing dependencies internally, but I suppose there's always going to be a price to pay for having all these safety checks in place
Hybrid Renderer v2 seems promising, 250k dynamic entities takes a few ms to render in the editor, that was more than enough to bring it to it's knees before
Still not great but certainly better
250k dynamic entities are no joke
on my own experiments, where i only render instanced cubes, it takes about 2 ms to render 300.000 cubes
I'm going to try adding instanced color data next and see how that goes
entities 0.9 has appeared in the package manager ... still "offline" and unreachable so no changelogs
wonder what they added
@zenith wyvern shouldnt be too much of a perf hit, given the design
the design, as i see it (from the comments and the likes) essentially memcopies the chunk data straight to gpu memory
and then uses it when rendering
- Improved performance of access to singletons through
SetSingletonandGetSingletonin SystemBase (peformance is also improved through these methods on EntityQuery).
this is something i found on the Tiny racing demo that was much slower than what made sense to be
Hmm, I'm not seeing the option for it
@dull copper Thanks! Where did you get those?
@viral sonnet each package has changelog.md at the root of the package
you can find all packages you've installed on your projects library/packagecache
same with local docs
@zenith wyvern you want to change it via components?
oh, so it's downloadable? didn't want to try, hehe
Yeah I found it in the shader graph, the checkbox is on custom properties now
good to know
btw
there's also a new platforms package but it's not compatible with the rest of the new dots packages
## [Platforms 0.3.0] - 2020-04-09
Build pipeline major overhaul: build pipelines are no longer asset based, and instead must be implemented in code by deriving from `BuildPipelineBase` class. Build steps are no longer mandatory but can still be used by deriving from `BuildStepBase`.
### Added
- New class `BuildPipelineBase` which is a class based replacement for `BuildPipeline` assets. Build steps can be used to organize build code, but is not mandatory anymore.
- New class `BuildStepBase` which is an optional replacement for now obsolete `BuildStep`.
- New class `BuildStepCollection` which represent a list of build steps that can be enumerated and executed.
- New class `BuildResult` and `RunResult` that derives from new base class `ResultBase`.
- New class `BuildProcess` which describe the state of an incremental build process.
- New class `RunContext` which holds the context when a pipeline is ran.
- Methods for querying build component values have been added to `ContextBase`.
- Methods for setting build component values are now available on `ContextBase`. Note that those values are only stored in memory; the build configuration asset is unchanged.
- New method `GetComponentOrDefault` on `BuildConfiguration` which returns the component value if found, otherwise a default instance of the component type without modifying the configuration.
- New method `GetComponentTypes` on `BuildConfiguration` which returns the flatten list of all component types from the configuration and its dependencies.
- New method `SetComponent` on `BuildConfiguration` that only takes a type and sets the component value to a default instance of the component type.
- New method `BuildIncremental` on `BuildPipelineBase` which can be used to implement build pipelines that run in background.
### Changed
- Class `BuildContext` now derives from new base class `ContextBase`.
- The `RequiredComponents` and `OptionalComponents` lists previously available on `BuildStep` have been replaced with the merged list `UsedComponents` on `BuildStepBase`.
- Methods `CanBuild` and `CanRun` on `BuildConfiguration` no longer expect an out string parameter, and instead return a `BoolResult` that contains the result and the reason.
### Deprecated
- Class `BuildPipeline` is now obsolete. It has been replaced by `BuildPipelineBase` which is no longer asset based. All build pipeline assets must be converted into a corresponding build pipeline class that derives from `BuildPipelineBase`.
- Class `BuildPipelineResult` is now obsolete. It has been replaced by `BuildResult`.
- Class `BuildStep` and `RunStep` are now obsolete. Class based build pipelines no longer enforce the use of build/run steps. Most interfaces and attributes related to `BuildStep` and `RunStep` are also obsolete.
- Class `BuildStepResult` and `RunStepResult` are now obsolete. They have been replaced by `BuildResult` and `RunResult` respectively.
- Property `BuildPipelineStatus` on `BuildContext` is now obsolete. `BuildPipelineResult` and `BuildStepResult` have been combined into `BuildResult`, removing the need for this intermediate status.
### Removed
- Removed optional mutator parameter on `BuildContext` class.```
I kinda liked the asset based setup myself
What the heck, the asset method was so much better
More inline with how SRP works now too
Weird...
so platforms 0.3 is not supported for entities 0.9 right ?
i guess thats the error i was getting
you're on 0.9 already?
0.2.2 works
Hybrid Renderer still doesn't do great with actual moving entities it seems. When I make my entities rotate the rendering system goes from ~3 ms to ~20ms from having to update renderbounds
Hmmm - damn - I liked those build assets ):
Still with 250k entities
i mean does it really mean anything tho, in reality you would have a culling and wont update out of camera stuff, i mean thats what happened to me at least
Maybe they made the change from an asset to a script to better support CI/CD? π€
I was curious how to do CI/CD with the asset based one at one point in time - but just speculating
Doesn't seem like it does any automatic culling either, unless I'm missing something. Nothing changes if I turn off the camera
yeah it doesnt, you gotta do manually, in changelog it says disablerender component works properly for v2 now
Ahh okay
it helps a lot π
so ecb playback being burstable means sync point will take much less time then ? π€
@zenith wyvern thats def not too good
updating render bounds should be faster than that
but still, try moving 250k objects in unreal XD
It's not that bad actually, I was misreading it. It forces the transform system to complete first so it counts that in the overall system timing. The actual render system jobs take around ~8 ms total for this case
And this is still in the editor
I tried a standalone build and I guess livelink broke it
whats the sync overhead in standalone builds?
as you saw on the pics i sent, 90% of system time is job system checks
is it still that bad on standalone
I'm not sure, I can't profile standalone since it just gives an error about livelink as soon as the player starts and nothing happens
that's what I do π
Funny... all the erros i got, solved by restarting unity.
It's the 5th time i restart unity and the erros is gone. The project runs fine without any change from before restarting it. π
anyone know what version of dots editor works with the latest entities and hybrid renderer?
getting 99 errors for dots editor
@fallow mason check the dependecies.
I had a problem in the past that some packages dependecies conflicts with other packages dependecies. May not be this but check, just in case, y'know.
so we have hybrid renderer v2 now yes? with full URP support!?!?!
i don't know about full URP supportπ
Seems to be working as far as I can see
From reading the thread it seems like the lighting is still messed up
am i the only one with broken light?π€
No, they are aware of it. Fix is coming in next entities version apparently
π’ Hybrid Renderer V2 will have URP lights support before end of the year
rip
lights, who needs them π€
they fixed the lighting issue on HDRP but it's not in this release
i am getting EntityContainer error on 0.2.2 π
DOTS editor isn't compatible
which version of 0.2.2 are you using?π
Dots editor is a tool that show you what components your entity will get after conversion
.. sounds useless then π€
so the plan then would be to use HDRP until the end of the year then revert everything to URP?
well, even HDRP support is iffy atm
altho I dunno if there are other major issues atm than the lighting intensity being off
@wide fiber Thanks for the reply, Unfortunately every other entity is pure ECS, only reason my camera is being converted is I can't find a way to make a pure ECS camera.
is it necessary to set [ReadyOnly]/[WriteOnly] attributes for ArchetypeChunkComponentType in a Job when the method GetArchetypeChunkComponentType<>( isReadyOnly ) already does it in function ?
anyone have ideas on how to fix buildstep related errors after updating to entities 0.9.0?
are you using platforms 0.3 ?
yeah its out
yes. should I not be using platforms 0.3?
tried downgrading to 0.2.2 but ended up with even more errors
yeah i had to downgrade to 0.2.2-7 and remove dots editor package
apperantly something about.. yeah
so I still get the entitiy debugger without dots editor?
look at everyon salivating at the bit
dots editor is just for live conversation helper i think
π
0.3 still doesnt work tho, i think
because it was giving error for entities 0.9
I can confirm that. tried it and 0.3 still broke even without dots editor
Hmm so I find myself adding more and more components to my Player, like Speed, JumpHeight, a bunch of Attributes later on. I get the feeling that as my project is growing, so does the count of components. Is that just the normal way of doing it?
yes
I think thats the way it goes, you want lots of small components so that when you selectively use them, they're not bringing lots of baggage with them that isnt used
but for individual attributes like that, its most common to have them bundled a bit more
like, if you allways use speed and jump height, and there arent cases where you have one but not the other, then have them together
biggest lunacy ive seen was one guy on the Entitas github commenting he had 3000 components
but common games go from few dozen to maybe a hundred or two
Cool thanks for the Input, nice to hear that I'm on the right track, thanks
Just trying to confirm, using .WithBurst() is not necessary unless you are modifying burst options, otherwise this is automatically implied correct?
has anyone come across or created polygons by code in ECS? I don't know which elements to use. Mesh? Mesh filter? All I want to do is draw a square by code
not sure what to google to get me help
if you are just starting with ECS , better to just get hang of basic principles first. if you have done procedural meshes before then , there are native Mesh APIs now afaik to use in Jobs from ECS or even non ECS code.
GetNative*()
are the ones you should be looking at
@finite ibex
drawing square ( quad ) in standard way : https://docs.unity3d.com/Manual/Example-CreatingaBillboardPlane.html
this is not something DOTS specific but for complex procedural meshes obviously you can gain lots of speedup
Is there a way to add the MeshRenderer group as hybrid components also tell them to make a static mesh?
ty @naive parrot! I'm sure something there will guide me
where did EndPresentationEntityCommandBufferSystem go ?! π€
doesnt seem to be present in 0.8
They removed it. I guess you can use BeginInit instead
thats what i have been using. just noticed that. has been gone since 0.3 apparently but docs manual still dont reflect
docs team really not doing a decent job keep the stuff in sync with all the changes.
@winter depot correct, it uses burst by default if you don't specify something that would prevent it (StructuralChanges, WithoutBurst etc)
Thank you @mint iron
why does entity debugger shows weird values for chunk components?
calculations turn out all fine but debugger is definitely not showing those values
has anyone successfully used WithNativeDisableContainerSafetyRestriction on a DynamicBuffer, gotten through GetBufferFromEntity?
I've tried the exact same stuff but with components instead of dynamic buffers, and it works fine, but as soon as I start using DynamicBuffers I get the traditional same type error
I have an array of objects that I want entities to process on main thread, I can either do
- a simple
foreachloop through the array, and for each object in the array I doEntities.ForEach - an EntityQuery to get all the entities, then
Job.WithCodeand loop through the array and entities inside
Which one is better or there is no real difference?
Hard to say without more context. Can you give a little more detail about what you're doing? @lusty otter
So I'm making a scriptable rhythm game and entities with TouchComponent want to process touches.
The array of objects here being the touches.
Because I want to loop these touches in a certain order (order of their time) so it has to be the outer loop, so I can't do Entities.ForEach then loop touches inside.
So your array of touches is being processed by every entity then? Can you do ToComponentDataArray<Touch>(), sort that, then pass it it into a single ForEach of your TouchComponents?
Ah I didn't make it clear enough, I want to have it that way (touches being the outer loop, entities being the inner loop, and everything not in parallel) for logical reasons.
Things like an entity processing the 2nd touch will know that 1st touch has been processed by all entities already, and it can ask them about results of it.
Well, if everything is on the main thread anyways then I guess there's no scheduling overhead to worry about so it shouldn't matter if you're doing a bunch of ForEachs. I would go with whatever is more readable, which it sounds like maybe the first option is
Can I make a System that runs every 100ms (for example) like InvokeRepeating?
I want it to be "Frame rate indipendent", if a frame takes 200 ms, I want it to be called 2 times (like InvokeRepeating)
Ah ok
Without system groups would be better
yes, but it is for systemgroup
Thanks Sark.
So I have to make a different group for every system that has a different timestep
Or just [DisableAutoCreation] on your systems and have a system that runs every frame and manually updates them as needed
I want it to be "Frame rate indipendent", if a frame takes 200ms and the system needs to update every 100ms, I want it to be called 2 times (like InvokeRepeating)
Then yeah it sounds like you want to use FixedRateUtils. It has "EnabledFixedRateWithCatchup" which does exactly that
I could make a system that runs every 2ms and that has a list of all the systems (and their time step) and it updates the correct one based on the time
Then yeah it sounds like you want to use FixedRateUtils. It has "EnabledFixedRateWithCatchup" which does exactly that
@zenith wyvern yeah
Actually, shouldn't the second solution be better?
For first solution, each ForEach would need to query a list of entities and get their components for every outer loop
But second solution just does it once at the start and that's all.
I was assuming there would not be a ton of these touches to process, so I was more worried about readability with my suggestion
If you're worried about performance then yeah option two would definitely scale better
Okay I'll go with that then
I can stomach a bit of not so nice looking code, I guess.
π
@opaque escarp You cant have same type in both ComponentDataFromEntity/BufferFromEntity and ForEach query, you have to remove from ForEach query and query for Entity, and access entity's component/buffer like that
Has anyone actually tried using FixedRateUtils? I was just trying it out and It doesn't seem to work for me at all.
EnableFixedRateSimple seems to do nothing, EnableFixedRateWithCatchUp just causes the editor to lock up as soon as I press play
@opaque ledge You are able to do it with ComponentData provided you use the disable safety restrictions and for restrictions. The patch notes also said that the ability to use them on collections was added at one point, so I assume it not working was a bug and submitted a report
Yeah Sark, Druid tried it on but he said it wasnt working properly, or he was doing something wrong π
@opaque escarp can you post the error ?
It's the error you'd expect, can't do stuff to arrays of the same type, that you'd use the restriction disabling for normally
well when i encoutered that error i always 'convert' to what i said, so i dont know
It looks like EnableFixedRateSimple does affect the Time.ElapsedTime (and probably dt by extension) that gets reported to that system, but the system still gets updated every frame regardless. Bah
well see, pretty sure it's a bug. As you say though, there are ways around it, Thank you
It looks like
EnableFixedRateSimpledoes affect theTime.ElapsedTime(and probably dt by extension) that gets reported to that system, but the system still gets updated every frame regardless. Bah
@zenith wyvern Sorry if the question may be stupid, but at line 10 it gives me the error: https://pastebin.com/W89S5ZCH
Yeah it wants the actual SystemGroup, not the type. So you would have to do something like World.GetOrCreateSystem<Group2MSFixedUpdate>() instead of passing the type
Ok
It wasn't working at all for me though. If it's broken for you too you should add your voice to this thread https://forum.unity.com/threads/fixedrateutils-enablefixedratesimple-sets-deltatime-but-update-rate-is-still-the-same.859072/
because EnableFixedRateWithCatchup is bugged π
this thing is hilarious, as if they don't test things at all
About editor freezing, I have a script interpreter inside bursted jobs and it freezes all the time.
But it runs fine on an actual build.
Luckily I can just comment out a bunch of unused interpreted functions during development, which reduces the size and somehow that prevents editor from freezing.
I guess it's early development so these are to be expected, but I really didn't expect these many issues π
@wide fiber i use this https://pastebin.com/tN6VGs8W
does there exist something for nativearray serialization?
Ok ty
@warped trail
Hello, does this code make sense to you to compute the innerloopBatchCount of a parallel job schedule or I got it wrong?
nope
gotta round up
couse int division doesnt have remainder
check it out, per-batch is 3, 3*4 is 12
total work 13
I am not sure how the innerloopBatchCount is used internally
my assumption is that it shoudl work with any value > 0 regardless the total number of iterations
the code should work out the optimal number of threads to use anyway?
in fact I don't even understand why unity doesn't compute the optimal value itself
I think because of the rounding in your case you could get processorCount + 1 Batches instead of processorCount many
that is what vblanco means
if I understand it correctly
why should it matter anyway
?
let's put the question in another way. if I have a total number of iterations < 16, but I return as iterationsPerBatch 16, this should not matter right? Iteration per batch is just a hint isn't it?
Been looking into slopes for my character controller. When transitioning from walking up a slope to walking down there will always be an error in which the movement of the player is faster than the gravity pushing him down. I researched a few solutions and what it comes down to is a simple cs croll(right, slopeNormal)
But there is still the initial error in which the player lifts off the ground. My solution would be to account for that and alter the players Position accordingly, I could also increase the gravity until I am grounded again.
I read here a while ago that setting the position directly will cause the Physics System to redraw all colliders. I wonder where I can do some reading on that? How would you tackle the problem?
because if it's not I don't understand it
well if they all take approximately the same time and start at the same time, then that would double your full time it takes
it seems that dynamicbuffer can actually allocate outside of the internal capacity in case you use .Add
var adjustedCount = Math.Max(kMinimumCapacity, Math.Max(2 * header->Capacity, count)); // stop pathological performance of ++Capacity allocating every time, tiny Capacities
They always double the capacity when you call add and there is not enough space, this is normal for these kind of data structures, but in this case they don't recheck if they are overshooting the internalcapacity with this
just thought this is interesting to know since I used Add up to know pretty often, but if you want to stay inside the internal capacity you probably need to resize and treat it as an array
What is the easiest way to spawn in cubes with the entity component system ?
in the ecs samples repositories there are a few examples doing exactly that https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/ECSSamples
@stone osprey
Thanks ! Is there a easy way to instantiate and convert a gamobject in code ?
I only saw examples where you need to attach monos to those prefabs...
And those are required in scene already
let's put the question in another way. if I have a total number of iterations < 16, but I return as iterationsPerBatch 16, this should not matter right? Iteration per batch is just a hint isn't it?
@scarlet inlet it only returns 16 if the total iteration per batch is less then 16, not if the total number of iterations is < 16. If the total number if iterations is < 16 it would also return 16
Is there a way to spawn in prefabs and than convert them into entites ?
yes there is a easy command but I don't know it since I never use it
@scarlet inlet it only returns 16 if the total iteration per batch is less then 16, not if the total number of iterations is < 16. If the total number if iterations is < 16 it would also return 16
@junior fjord I know, the question is, does it matter for the parallel schedule?
sorry I don't understand that question
@junior fjord Any idea how to find that class/method for spawning in prefabs as entites easily ?
sorry I don't understand that question
@junior fjord never mind I'll do some experiments. I am still trying to understand why I should suggest the innterbatchcount since Unity should be able to figure out itself
it seems like you instantiate your first entity from a prefab and then just clone that
@junior fjord Hmm.... and how do i instantiate a entity from a prefab in a easy way from code ? I dont want to use any monos etc.
convert your prefab to entity and store this entity somewhere
you only need to create one gameobject and add the convert to entity script or not? But I am really not the expert on that, I haven't done it in ages
you can create entity which will store every prefab in some component
something like thiscs public struct PrefabReferences : IComponentData { public Entity SmokePrefab; public Entity BulletPrefab; }
@scarlet inlet 16 per batch can be low
generally wheh batching a parallel for you want both caps on the low end and the high end
to not launch a thousand tasks
Yeah but what if i want to instantiate that prefab from a script ? How do i convert it to a entity without attaching that convert mono ?
you use DeclareReferencedPrefabs
put this on you Entity storagecs [GenerateAuthoringComponent] public struct PrefabReferences : IComponentData { public Entity SmokePrefab; public Entity BulletPrefab; }
and put your prefabs there
oh, if you clear a dynamicbuffer, it does not revert to its internal storage if it was pointing outside before?
that thing is full of surprises for me π
Thanks ! What if i have about 100 different prefabs ? Isnt there a way to do something like this ? "GameObject test = Instantiate(reference); Entity entity = Conversion(test); )
So i instantiate that damn prefab from code and convert it via code ?
if you want the dynamicbuffer to move back to its internal storage in case it was to large before you have to call clear and trimexcess
So how do i spawn in a prefab from code and convert it into a entity within the same line ?
@stone osprey i don't think that this is recommended wayπ€
i think they plan to remove runtime conversion π€
you can use DynamicBuffer instead of component
Ok well... so i have the following problem... each "Monster" in my game... ( 100 prefabs ) each one having one mesh, material, animations and a healthbar above... all i want is to convert this shit into a entity... that cant be that hard right ? Pure ecs is not possible i guess due to the animations and the healthbar
Before i would have directed you to runtime conversion but they've said unofficially (one devs comment in this channel) that runtime conversion is not supported. That leaves three options, 1) do it anyway and risk it all breaking later. 2) Come up with your own system to make the entities and then slap a Prefab component on them. 3) Add them in a subscene with a converter that attaches a prefab tag, then they'll show up as prefabs when the subscene is loaded. If you want then, you can index them in a hashmap or whatever so that systems can find the one they need.
Thanks ! π So i could either use prefabs for visuals and use the ecs for the data oriented part... the entities would just have a component with a reference to the spawned prefab... or i could write my own implementation ?
do be clear there's no interop between entity prefabs and MB world in this scenario. You setup your MBs like normal as prefabs, but the subscene converts them into pure ECS and the MBs dont exist anymore. (ignoring livelink since it won't work in an instantiated prefab situation)
But you're right in that the normal MB/Mesh/Material/Prefab setup can be configured in the editor to define what things look like.
Alright... is there a other way ? The only reason i choosed prefabs is the attachment of animations and the healthbar... but im not sure if i could draw a healthbar with ecs
not that im ware of, maybe someone else has tried more in that area and can chime in.
We use gameobjects backed by ECS (keeping the gameobjects)
Its not great, but it works
@stiff skiff So ecs for the data structure and gameobjects for visuals like healthbars ?
That, and monobehaviours, yes
Not really, you can use monobehaviours for "simulation" just fine
Just wont be as fast, but often thats not an issue
mono/go work just fine for most thing. unity is all about that for most part.
i personally am using unity's ecs for its architectural benefits rather than performance speedups.
Same
We've used it to get a clearer "loop" by using the playerloop stuff that ECS uses
Alright thanks ! I guess we are going with a mix between ecs and gameobjects π
decoupling logic from data is no brainer in complex projects. ecs does it nicely.
Things are almost all written in monobehaviours, but if we see a performance issue in part of that, we move only that bit over to ECS
Btw... does anyone knows how the hell i set the rotation of a entity ? I wanna set a entity mesh to a rotation of 90 dregrees x axis
Its much easier to work this way without the developers suddenly having to learn a new way of working
Sadly not all of this is smooth, due to the ECS closing off quite a bit of their API. Making it a little hard to bend to my needs
yep , having only performance critical sims part of codebase is the clear candidate for ecs atm , even down the line when DOTS all round has matured more
RotationEulerXyz or similar components @stone osprey
@stone osprey whats the issue? access Rotation component and set value calculated using math lib
we tried value = queternion.RotateX(90); that didnt worked... but we didnt used that math lib either
I'm still bit puzzled about Unitys design on the dots safety checks + unity physics
like, right now if you run physics 50Hz and render 200+ fps, you get warnings that things took too long and it deallocated your tempjobs
running physics at fixed timesteps is how this is designed to run even
so it feels just so... shortsighted
tempjobs are 4 frames long arent they..
apparently yes
because I see this happen π
I'm rendering ~200fps in editor
and see this only when fixed timestep is 0.02 (50Hz)
and if you run physics at 50 hz but your game runs at 300 fps it is kinda problematicπ
basically you'd need to lock the max framerate based on your physics stepping value
never let it go past 4x your physics speed
does it deallocate stuff at runtime?π€
I don't really have an issue with this myself as I want to run physics at least 100Hz, so soft locking the frames to 400fps is not likely going to cause any issues, especially with HDRP where you don't even reach such framerates until you got 2080Ti and empty scene π
I dunno about that either
if it works at build, then it's not a huge issue
but it's not nice that it does that in the editor still
wouldnt 4x of 50hz be 200fps locked ?π€
yes
i update mine at 48hzπ
technically you should always update at lowest speed things still behave well
masterrace aside , whats the end user advantage having that high of frame rate ?
at 24 while testing thingsπ€
other of course having reference benchmark for how fast your simulation can go
you gotta draw the line somewhere anyway
there is monitors with 300+ refresh ratesπ€
those monitors are 1080p
so it helps a bit
pretty sure doing 360 on CSS is nonisssue with current hardware
and those monitors are made for CSS
i guess main idea is to decouple physics from framerate
things should work no matter the framerateπ€
doubt its that straightforward or practical
yeah, that would be the idea case
well, it should be
if your simulation code is decoupled from rendering, you can render at any speed monitor supports
or just how fast the gpu can handle it
is the physics deallocation issues valid for havoc as well?
if it is not, then welcome to jitterlandπ
I don't really know if it's a real issue
but we do get the warning spam in the editor
these slides don't really tell how the queries work though
if the queries work on direct ECS data, then it'll mean a lot of potential gains will be wasted on Havok
but I don't really know how this is structured
(there are gains to be had if you have cache on physics engine even for queries (raycasts, sweeps)
raycasts and queries are not part of havok
then again, Unity specifically said that even Unity Physics is really performant on queries specifically
this sort of design can be pretty good on queries
for unreal i had to create my own physics for some types of queries
as having colliders would be too slow
I know physx can do sh*tloads of short queries and you don't even notice
the problem in places like unreal, is that all the memory for the queries will be cold in cache
vs doing queries from ecs
in ECS, you generally are calculating X amount of objects at once, and having a loop that does little more than spam a fuckton of queries
so all the inner structures are hot in cache, getting massive gains
For any physics features that do not cache state, e.g. raw collision queries, we expect the performance of Unity Physics to be on par with, or outperform, similar functionality from commercially available physics engines.
in oop arch (monobehaviors/unreal), beetween ray and ray, you are doing a ton of other random stuff, on many random objects, so by the time you raycast again, it will be cold in cache
@dull copper unity has a big advantage for something like this. It can keep the acceleration structure for the static entities built
and only build octree/bvh/grid for dynamic entities
and only per-chunk
so you can get some crazy fast rays like that
4k raycast is taking around 8-10 ms for me, that good ? π
I guess it depends on the raycasts too
would need to be some worst case scenario rays
if they are short distance, it's not great
I wanted to create a component which stores a reference to a gameobject which acts as the visual representation for a entity... any idea if i missed something ? public struct GameObjectComponent : ISharedComponentData { public GameObject representation; }
distance is 300 i think, and with proper filters as well
thought u were talking about coronavirus for a second there
Distance is 6 with N95 filters
Well, Unity's units are meters aren't they? So maybe just 2.
well 300 meters of rays is a bit too much xD
and 4k
if they go across the map thats fairly worst-case
why would length of the ray affect the performance ? i mean.. isnt ray just a line, so behind the scenes Unity would just run some basic geometery functions for lines and AABB checks ?
But yeah i will try to lower to 50-100 later on, right now i am not working on it however
because the longer the ray is, the more stuff it has to traverse
on unreal engine RTX ambient occlusion implementation, it becomes straight up a slider of how fast the effect is
there is a 3x-4x delta depending on how long the AO rays are
on short rays (basically like SSAO but higher quality), its pretty cheap, barely more than SSAO, but if you have several meter-long rays, it becomes 2x,3x slower than ssao
hmm π€
most of my queries are like under 1m in world
as a side note, I was wondering (again) why the physics perf is so much worse in the editor (even with all safety checks off)
it was the bloody physics debugger script.. I should have known this as I've stumbled to this few times already in past
it just doesn't scale at all
with 30 dots based vehicles, my game cost like 70ms / frame for cpu in the editor
on actual build it's ~4.5ms
it does make sense, just wish some day we get more performant dots debug draws
it uses OnDrawGizmos
I'm also limiting workers to 1 on my testing atm
but that doesn't affect the physics debugging as it can only run on main thread anyway
hmmm, debug draws themselves can run on jobs on 2020.1 tho
just not bursted
im using their DebugStream to draw my stuff too π
I know the custom solutions, like the one @mint iron made
they use native stream
it's just, it's enough pain to maintain your own code right now
and draw everything in 1 gameobject
then maintain custom physics debugger on top
using havok visual debugger didn't make things any simpler, it practically froze the rendering on the editor fully even on simpler scene
I must use it wrong as it can't be that bad
or maybe it should be used only in actual build etc
actually, I'll just try that now
Entities.ForEach not possible with SharedComponents ? Created a custom SharedComponent and it tells me that this operation is not possible with my component
they allocate nativestreams and then deallocate them in next frame, from here you get your warnings π
you can use sharedComponents with Run
When i remove ref, it works... any idea why my shared data component is not acceptable by reference ?
Run ?
You mean on the system that processes those components ?
Entities.ForEach().Run()
Are you sure ? I cant attach that method call after foreach
the havok visual debugger itself seems to have smooth physics
but rendering stalls to 2fps on build when it's attached π
I must do something very wrong with this
(just tested with IL2CPP build)
they allocate nativestreams and then deallocate them in next frame, from here you get your warnings π
@warped trail oh wow, now I feel stupid again π
well, at least it gives more confidence on the actual physics sim
Is there anyway how i can multithread SharedComponentsData ?
yeah thats why i rotate and re-used NativeStream instead of allocating a new one every frame, but to do that the clear method i wrote still has to do far too much work. I should probably re-write it and make it a package.
so you can't reuse nativestream by default?π€
correct
What the crap does the DOTS Editor package for? The description is infuriatingly vague about what it actually does
it will hold new entity debugger in the future π
Lets say each entity has a gameobject ( visual representation ), how would you make that gameobject follow a entity translation ?
DOTS Editor causes compile errors with Platform and Entities updates. So I can remove DOTS Editor, but I don't know what the crap it actually did in the first place
Is there anyway how i can multithread SharedComponentsData ?
@stone osprey
Nope. SharedComponentData is main thread only.
You can change them using command buffers though. Just be aware that every time you change a SCD it's a structural change
Thanks ! Im doing a hybdrid between gameobject and dots, because each of our monster prefabs comes along with stuff like healthbars etc... :/ hoped theres a way to move gameobjects using jobs
I think that's what HybridComponents will do....I don't know if they're recommended to use yet though
Read about hybrid components in that article, should give you a better idea of how to approach it
Thanks ! π Not sure if im able to convert my prefabs properly... but im gonna take a look at that
AFAIK shows the live entity conversion stuff @low oasis
@low oasis DOTS editor hasn't been updated for the new dots packages, hence the errors
you don't need it
it provides entites live conversion preview if you use DOTS subscene
and has checkbox on top of property inspector so that you can add convert to entity script to them with a single click (or remove it )
official description is: Provides data analysis and visualization tools that are built on top of the ECS architecture.
so convenience functionality for stuff you can do manually (add the script)?
Is this a common issue when converting gameobjects to entitys ? https://prnt.sc/rwtxd4
No idea what component couldnt get converted
@low oasis it's mainly about visualizing the entity conversion
the script adding is just extra convenience tool, yes
good to know. Don't need it then. That description is pretty much useless. Maybe if they added some screenshots of what it actually does right now. π€·
@stone osprey sounds similar to this issue: https://gist.github.com/jeffvella/f844cc4aab5b5a9f308e9c27148f5cdf at least prior to the last version it was because some systems were doing stuff for the Animation package when it converted with a skinned mesh.
@low oasis it's not useless, it would actually be aweseome if we could use it more
Thanks ! π Im gonna take a look at this
basically you can see the entity conversion and componentdata in real time there
without having to use the clunky entity debugger
it's just.. it only works in dots subscenes
Unexpected exception Burst.Compiler.IL.Aot.AotLinkerException: The native link step failed Error while executing command: C:\...PackageCache\com.unity.burst@1.3.0-preview.7\.Runtime\hostwin\lld -flavor link getting this after upgrading, anyone seen it before?
Ok, I've spent a few days headbutting a brick wall with this issue and I can't find an elegant solution.
I have a camera that's being converted to an entity and it has a component that handles what entity it should follow.
Every other entity is being made with pure ECS when the games bootstrap script runs.
I can't find a good way to link these together without adding extra components just to "name" my entities or running through every single shop / camera to find one with a certain variable set. that just feels very wrong on both cases.
The best idea I currently have is to maybe setup events, fire off an event for change camera target to X entity on X camera, but that will still require me to ID the cameras somehow.
Does anyone have any suggestions for how to do this in a half decent way?
@mint iron that is bit old burst already, maybe worth bumping it to preview.9?
hmmm i just added preview9, must be using old package, ill restart. Some sort of warning about what is required to make the upgrade function, would make this process easier you'd think.
they released .9 along with the other new dots packages
yeah, burst requires restart afaik
I usually have to turn off burst, restart and turn it back on to get the cache to not error
otherwise it complains about files in the windows tmp directory
you mean when you upgrade it?
but unclear on how to manually wipe the cache
it should sort itself out on editor restart when you upgrade it
I often just bump the burst version to new directly from the manifest.json so it can load the new package right on startup
upgrading the burst package has, so far, always generated errors about files in the Windows tmp directory, I'm guessing cache
yeah im just grumping that its a bad user experience, if they know it requires a restart, then tell the user about it. I'm sure its hidden in some document somewhere but it needs to be prominent or every single person is going to hit this, wtf is going on stage.
Yeah when you upgrade burst you need to restart the editor, it's a known issue
yeah, I agree it should have some warning
it sometimes works to just restart, but I've found it just works better to turn it off, restart, turn it on π€·
or it did anyway, maybe that has been resolved
one of those processes that you get used to because it works
but may no longer be necessary
sorry @loud matrix i derailed your question: https://discordapp.com/channels/489222168727519232/497874303463850004/698186178285010974
@loud matrix You're trying to have a camera follow an entity that you've created at runtime, is that right?
Yes
The following is easy, but assigning it and being able to change it, not so much
Still trying to parse the problem, you have multiple cameras so you can't figure out how to get a reference to the right one?
At the moment I have a single main camera that's a game object being converted to an entity (as far as I'm aware I can;t make camera with pure ECS)
I need to assign the currently active ship (player controlled) to the cameras follow component at the start of the game, in such a way that it can be easily changed.
The only way i can see to do this is to add a system that loops ships and if it has the "player controlled" variable set to true change the cameras target entity. which wouldn;t be great as it would need to run through every frame on every ship.
The only other way I was thinking to handle it would be with events but I've not fully wrapped my head around them in ECS yet.
I'm thinking I'm probably missing something up by having a variable be what dictates the player controlled ship but as it needs to change I can;t see another way.
So you have something like
struct Ship : IComponentData
{
public bool _playerControlled;
}
Is that right? You definitely want to just have a Player component that marks which entity is your player so you can easily query for that
Then you could do something like
class PlayerFollowSystem : SystemBase
{
var playerEntity = GetSingletonEntity<Player>();
var posFromEntity = GetComponentDataFromEntity<Translation>(true);
// Can't use burst or jobs since it's referencing a monobehaviour
Entities.WithoutBurst().ForEach((Camera cam, ref Rotation rot)=>
{
var playerPos = posFromEntity[playerEntity];
// Go from here
}).Run();
}
Just one way to do it
That will easily handle the case where the player changes at runtime
Ahh right, I have currently been adding the player controll to all entities
so I'd have had to iterate through them to find the one set to active
Yeah you definitely want to just have a player component so you can easily build your player-related systems around that component
The main issue I'm having I think is how to tell a camera when to change entity. I currently have
struct CameraFollowEntity : IComponentData
{
public Entity Value;
}
For deciding what Entity needs to be the target, and when set currently camera just sets its self to their position and rotation with an offset.
So you want to be able to detect when the active ship changes, and update the camera target then, rather than checking it every frame somewhere.
Ideally yeah, as I'm thinking of having multiple cameras trailing multiple ships eventually.
honestly it seems to be a gap in ECS i dont fully understand, the obvious solution to me is some form of event that triggers other logic. I'd love to know what the real recommended DOD mindset solution is. Because to me, just do everything every frame because its super fast anyway is not good enough.
Events were my recent idea, but I only just started looking into them, and I'm so sued to ultra simple JavaScript evets that doing them in Unity is a bit of a mind twister. So I was hoping to find out if it was a viable solution before diving deep.
An event sounds like the right solution
So >_> I'm too dumb to understand this. The "Start" and "End" in RaycastInput refer to a "Start Position" and an "End Position", meaning the "End Position" is NOT relative and an actual Position in World Space. Right?
struct CameraChangeEvent : IComponentData
{
public Entity oldTarget;
public Entity newTarget;
public Entity cameraEntity;
}
Then create a ForEach to handle that component and destroy it after handling
if your entity does not need to know that it is being selected, maybe you can store that information somewhere else?π€
Thanks, I'll have a dive into events further. I remember seeing a code monkey video on the topic a while back.
Just try to keep it simple, it's already a lot of boilerplate as is. You don't even need a new system to handle it, you can just add the foreach to your camera follow system
like special entity with component like this, and you can get its current position via cdfe and you don't have to move real entity from chunk to chunkπ€ cs struct ThisIsSelectedRighNow : IComponentData { public Entity entity; }
One quick question... why does my IDE tells me that "entityQuery.ToComponentDataArray<Translation>();" is not allowed because it must be a reference type ?
Because you have to pass an allocator as it's parameter
Thanks ! That worked ! Is there a similar way for sharedComponentData ?
Tried the same for a sharedComponentData component but thats not allowed
not that I know of - ISCD are stored as indices, so you grab the ISCD as an index and then access that index to grab the data
Any documentation on this ? Couldnt find anything about this :/
https://gametorrahod.com/everything-about-isharedcomponentdata/
I think sargon's blog should still be relevant for info online, you can also look through how EnittyManager.GetSharedComponentData<T>(index) works through the source code
I'd love a blog like that but so that it would get immediately to the point
I can appreciate the time he takes to write those but I really struggle to read them through
ah yea I can relate, I had some trouble reading through entirely for a few his blogs
i just noticed today that JacksonDunstans blog has some more articles i havent seen, worth checking out for advanced topics https://jacksondunstan.com/articles/5494
oh interesting he did a study between switch vs burst function pointers
my project is just flat out crashing the editor on compile π¦
that virtual functions thing is really interesting, i hit a blocker with something similar because of FunctionPointer<T> being managed but his workaround is nice.
I've not dug into any of the burst stuff yet, still much work to be done before I even get to moving stuff to jobs
But its nice to read this before hand
Hi, I just found out about Unity ECS, and I have a simple question. Do I need to inherit from MonoBehaviour?
For your datas, you have to make a struct inherited from IComponentData, for your behaviours make a class that inherits from SystemBase
i highly suggest following CodeMonkey's tutorials
@formal scaffold yes, its not relative, its a position in world space
@stone osprey if you are new to ECS, stay away from shared components π
I am building a weapon system, I want the firepoint of the weapon to be a Gameobject (that will be converted to an entity when the game starts)
Which variable type should I use to get the transform of the firepoint and use it in a system?
@wide fiber I have a similar problem... but in my case i wanna attach a armor piece to the player
use an authoring component and put a Transform field in it, in convert method add a component to entity with float3 that has that transform's position.
could also add a CopyTransformFromGameObject to your gameobject on conversion, then you can use its Translation inside of jobs
use an authoring component and put a Transform field in it, in convert method add a component to entity with float3 that has that transform's position.
@opaque ledge The weapon (and the firepoint) can be rotated, so I can't use a float3 (with some math I could solve this problem but yeah)
Well then you can use a float3 and a quaternion and then calculate the right position/rotation
could also add a
CopyTransformFromGameObjectto your gameobject on conversion, then you can use itsTranslationinside of jobs
@safe lintel the firepoint is child of the weapon that is a child of the player, the player is converted to an entity. The FirePoint will also be converted to an entity (because his parent will become an entity) so I can't add the CopyTransform... component
use conversionSystem.CreateAdditionalEntity(YourConvertedRootGameObject) to make custom entities for gameobjects you are injecting, and then you can add the child transform via dstManager.AddComponentObject(childTransform) + dstManager.AddComponentData(new CopyTransformFromGameObject())
Another question from my side... Im using URP for my materials and shaders... when i instantiate a prefab on my own it shows up the way it should... if i convert my prefab into the ecs, its completly black... any idea why this may happen ?
@stone osprey Don't think URP is supported by Hybrid Renderer V1
Even with v2 lighting isn't working in URP
welcome to the clubπ
Apparently it will be in "before the end of the year"
its like people want to use unity for mobile games or something π
v1 doesnt support ambient light, or lightmapping(it may or may not be completely busted on mobile?) for myself it works but I think its just a coincidence that it does according to what I see on the forums, v2 in its current state doesnt appear to support anything other than 1 directional light π©
Oh damn... thanks :/ Guess i need to use my prefabs then...
you can have ambient light in v1 if you disable srp batcherπ
does that actually work? last time I tried it didnt but it was a while ago and have gotten used to basically shit lighting π
i guess there is some issues there, but at least it works in v1
in v2 they fixed this, by properly disabling this featuresπ
lol
(Which line is the problem, the set component or the instantiate?: https://pastebin.com/GZPZQz0w)
you need .WIthStructuralChange() if you use EntityManager
whats the problem?
or use entity command buffer
@warped trail ok ty
whats the problem?
@safe lintel the error is at the end, after the code
i guess it is better to use ecb now, when it is bursted π€
oh π
we need more tests π
Does SetComponentData also need ECB? π€
