#archived-dots
1 messages ยท Page 255 of 1
Best way to figure out how to build a good mesh renderer in dots is use game object conversion to make it and then copy that info. Your matrix is invalid in LocalToWorld because it needs a 1 in there and your world render bounds is also zeroed out.
So I think unity have cleared my defines when I downgraded version or something^^ Seems it caused my ghost prefabs to fail serialize etc. ๐ฅด
alright, now my entites look like this, but still arent showing up...
looks like you don't have a rendermesh ?
which by the way the renderbounds would have been computed automagically for you if you had I would assume
but don't quote me on that hehe
yes i do lol
RenderMesh.Mesh looks unassigned though
oh, it isnt, it's generated, which is why im confused
Okay,even though I am close, maybe instead of creating new entities from scratch, I should be instantiating prefabs and setting the emeshes? not sure how t odo that though
pardon me folks the ECS workflow hasnt quite clicked in my brain yet
Hello! I have a VFX on a MonoBehavior where I want to send an event to trigger an explosion burst.
My logic is to have a NativeArray where I put the float3 positions within various ForEach-es in various Systems.
Inside a MonoBehavior i go over that NativeArray and use the float3 positions to do the triggers, then I dispose and recreate the NativeArray for the next frame.
My issue is that I cannot access that NativeArray from inside Lambdas because it's trying to access a "this".
I cannot access a Singleton Monobehavior either.
I cannot GetSingleton<VisualEffect> because it's a class
**
Is it possible to make the lambdas access that NativeArray in a legal way?
Or is it possible for my VFX to be triggered from within a lambda to avoid having to cache all the positions?
Or is it possible for a MonoBehavior to access some sort of storage of my explosion float3s ?
**
You can try creating a local reference to your native array.
NativeArray<float3> aliasToClassNativeArray = this.classNativeArray;
Entities.ForEach((...) => {
for (int i = 0; i < aliasToClassNativeArray.Length; i++) {
// Do some logic with aliasToClassNativeArray;
}
}).Run/Schedule/Parallel(); // For ScheduleParallel you may need to make it readonly to avoid contention
I do need to write to it to accumulate my events. and aliasToClassNativeArray will be a copy if struct, or if it's a class it will give me an error
it's a copy of the struct sure
but a NativeArray contains a pointer
you'll be pointing to the same memory address
I try tomorrow that code, I seem to recall the using a local variable workaround and now I understand why, thank you @coarse turtle โค๏ธ
Yeah I cant figure out why I am not able to see my meshes. They are there and are correct at least
your local to world doesn't seem to match your world render bounds
That is intentional, actually, for a complicated reason. Does that cause problems with the rnederer
renderer
Ok uh here is my situation
-I have a level editor, and part of the build process is that everything marked as "scenery" is stitched together into a single mesh for each "cell" (a 256x256 space) to reduce draw calls for static objects
-The stitched mesh is exported
-For each cell the mesh is read from disk and then built and spawned as an entity
The reason that the render bounds have such an offset is that a cell might have like, a rock in the middle of the field and that's it. And so while the spawned mesh is at 0,0,0, that rock mesh is actually over at 100,0,100 or something
but I just realized
since it's all 1 big object that's only going to be 256x256 in breadth (since that's the size of the world chunks) I could just make that my render bounds
Wait. The meshes are there. but they are invisible.
And it's not backface because I moved my camera inside of them and I still see nothing
what is this.
material issue?
No, the material is fine. I even set it to double sided. The mesh has triangles, and even shows up right in this preview, so I dont believe it's my deserialization code.
if you just slap the material onto a basic cube and convert it to entity it shows up fine?
it works fine.
it's just an HDRP/Lit material, nothing fancy
is that mesh gonna be anywhere near the size of the renderbounds you are setting?
Possibly, but unlikely
like maybe, if I were to fill the entire thing with rocks and trees or whatwever
maybe try using Mesh.RecalculateBounds if you are exporting from unity?
Oh I also have code to recalculate bounds, but it didn't do anything
perhaps the problem is not with the bounds then ๐
Yes I figured that part out. But i have no idea what it could possibly be
because the material works, the mesh is deserialized correctly...
does it work without converting to entity?
Well my whole system is made to use ECS, but Iโll try tomorrow.
does anyone know if it's possible to do raycast in jobs? specifically animation rigging constrain jobs
i am trying to get the raycasting info from my animation before the rigging constrains but doing something like
CollisionWorld collisionWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem<BuildPhysicsWorld>().PhysicsWorld.CollisionWorld;
isn't allowed in the constraint :X
what you're doing doesn't look like you're doing it in a job? at least not a job in a system
yup, it's a job for the animation rigging package
sadly i have no idea how the different system groups in ECS are updated relative to unity's core gameloop
my last resort would be extracting raycast info from the animations itself but that feels like going a pretty big round to do simple IK
haha, i was actually thinking about that, but i want to access these 5 fields randomly, and it seems easier to just do unitComponentList[randomUnitIndex]. that's why i think i've decided to just go with dynamic buffers, at least for now
I know this isn't exactly DOTS related, but not many people are familiar with the Unity.Mathematics library outside of here. Does anyone know if an angle passed to math.cos should be degrees or radians? Trying to implement boids in 3d and this solution (https://stackoverflow.com/a/65266247/4565536) mentions that some libraries expect values to be in degrees while most expect radians. Trying to figure out if I need to convert the angle value from degrees to radians or not. The documentation is, of course, no help.
F*** hell can unity not just serialize dicts for the inspector
Off topic sorry, i just like it here
IIRC in radians
let's find out
Library\PackageCache\com.unity.mathematics@1.2.1\Unity.Mathematics\math.cs
/// <summary>Returns the cosine of a float value.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float cos(float x) { return (float)System.Math.Cos(x); }
https://docs.microsoft.com/en-us/dotnet/api/system.math.cos
An angle, measured in radians.
Thanks so much!
public class ShopSystem : ComponentSystem
{
protected override void OnUpdate()
{
Entities.WithAll<ShopComponent>().ForEach((Entity entity, ref ShopComponent shopComponent) =>
{
DynamicBuffer<IntBufferElement> shopUnits = EntityManager.GetBuffer<IntBufferElement>(entity);
for (int i = 0; i < shopUnits.Length; i++)
{
int randomIndex = Random.Range(0, shopUnits.Length);
//EntityManager.CreateEntity(TypeManager.GetType(shopUnits[randomIndex].Value));
Debug.Log(randomIndex);
}
EntityManager.CreateEntity(TypeManager.GetType(shopUnits[0].Value));
EntityManager.CreateEntity(TypeManager.GetType(shopUnits[1].Value));
});
}
}
why does this give me error structural changes when i add the second CreateEntity, but not if i just have the first?
also since i have two element in my buffer, wouldn't Length return 2? so wouldn't my randomIndex be 0, 1, or 2?
oh nevermind
Description
Return a random int within [minInclusive..maxExclusive)
so since it's maxExclusive ig i don't need to do Length - 1
component systems are deprecated with version 0.50. change it to SystemBase. also make sure you use mathematics.random for random value generating. not sure about the error, but it might queue up the changes before creating the entities
damn im using some old stuff... should i also change the entities filter? im using the WithAll instead of WithName
WithName() filters for an entity name, not for components
The problem in your snippet is that the first CreateEntity => structural change invalidates the DynamicBuffer
ah yeah right, tbh, don't use the entity manager at all, rather use ECB's
much less issues with those
alrighty
This one is a misleading trap from the API. It allows you to name your job. ๐
ah yeah right, my bad. i was first thinking about that it names an entity, then that it query's for an entity name, but no, correct, it names the job. never needed it (yet)
why do i have to write System.Random rng = new System.Random();
instead of using System; and the Random? is it cuz it assumes Random is UnityEngine.Random?
yes. but you should use mathematics.random not System.Random / UnityEngine.Random
sorry but... whats that? i don't see any math.random
You can use this shortcut
using Random = Unity.Mathematics.Random;
ohh unity.math icic
thx
how do i get a random uint seed? if im not wrong i think on unix you can use /dev/urandom
but im on windows
Yo! I've been trying to upgrade entities package to 0.50, but I, for the life of me, can't get rid of these errors. Tried to look around for anyone else with the same problem, but couldn't find anything on this, so anyone here know what's going on? I've been trying to remove/reinstall all dots packages, but the wall of errors inevitably returns when I install entities 0.50
there's probably better ways but i'd comment code out, then when errors disappear i would un-comment until i found it
what Unity version are you using
are you on 2020.3.3x LTS?
Cause that error typically on an incorrect version of Unity with Entities 50.
2020.3.17f1
Upgrade to .30+
Is the fix really that simple? ๐
what do u use for random seeds on windows? Mersenne Twister?
Man I feel like an idiot again. Thanks vertx, I'll try that out
how do you get your seed? im on windows and i have WSL so ig i could use /dev/urandom?
you can put in any seed or leave it out. it's just a uint
hmm but would it make sense to read the /dev/urandom file from the linux filesystem for the uint?
but that would always be random
if you want it always random, just don't pass in anything
that's not possible. it gives
ArgumentException: Invalid state 0. Random object has not been properly initialized
Unity.Mathematics.Random.CheckState ()
https://forum.unity.com/threads/runtime-error-on-random.548449/
giving it a seed like var rng = new Random(0x6E624EB7u); does work tho
strange. that is not happening in my systems
https://i.imgur.com/gQzk1wJ.png
im on this and i only got entities, jobs, and burst packages added
using UnityEngine;
using Unity.Entities;
using Random = Unity.Mathematics.Random;
namespace AutoAllStar
{
public partial class ShopSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.WithAll<ShopComponent>().ForEach((Entity entity, ref ShopComponent shopComponent) =>
{
var rng = new Random(0x6E624EB7u);
//var rng = new Random();
}).ScheduleParallel();
}
}
}
new Random((uint)System.DateTime.Now.GetHashCode());
@eager pawn this may interest you
https://github.com/Dreaming381/Latios-Framework/blob/v0.4.5/Documentation~/Core/Rng and RngToolkit.md
thx ill check it out. also maybe you could look at my problem
public partial class ShopSystem : SystemBase
{
private EndSimulationEntityCommandBufferSystem commandBufferSystem;
protected override void OnCreate()
{
this.commandBufferSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
}
protected override void OnUpdate()
{
EntityCommandBuffer.ParallelWriter ecb = this.commandBufferSystem.CreateCommandBuffer().AsParallelWriter();
BufferFromEntity<IntBufferElement> buffer = GetBufferFromEntity<IntBufferElement>(true);
Entities.WithAll<ShopComponent>()
.WithReadOnly(buffer)
.ForEach((Entity entity, int entityInQueryIndex, ref ShopComponent shopComponent) =>
{
DynamicBuffer<IntBufferElement> shopUnits = buffer[entity];
}).ScheduleParallel();
commandBufferSystem.AddJobHandleForProducer(this.Dependency);
}
}
i've tried with a readonly buffer and without it, but for some reason i keep running into errors no matter what i try :((
this line gives the error DynamicBuffer<IntBufferElement> shopUnits = buffer[entity];
System.ArgumentException: A component with type:{0} has not been added to the entity.
This Exception was thrown from a job compiled with Burst, which has limited exception support. Turn off burst (Jobs -> Burst -> Enable Compilation) to inspect full exceptions & stacktraces
that's the error with readonly set to true
It looks like IntBufferElement may not exist on the entity, is there a reason you're not accessing the dynamic buffer as a parameter in your ForEach and opting to use DynamicBufferFromEntity?
just inexperience and following tutorials. ill try the parameter solution.
i think i might have missed a step when creating the buffer?
public class GameManager : MonoBehaviour
{
private void Start()
{
EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.Temp);
EntityManager eventManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = eventManager.CreateEntity(
typeof(ShopComponent)
);
ecb.RemoveComponent<ShopComponent>(entity);
ecb.AddComponent<ShopComponent>(entity);
DynamicBuffer<IntBufferElement> shopBuffer = ecb.AddBuffer<IntBufferElement>(entity);
shopBuffer.Length = 2;
shopBuffer[0] = new IntBufferElement { Value = 0 };
shopBuffer[1] = new IntBufferElement { Value = 1 };
}
}
your ecb is never played back since you're manually constructing it
A commandbuffer is just a storage of commands that needs to be played back at some point in time
All you're doing is constructing a command buffer and never executing it.
HDRP: Added: Added minimal picking support for DOTS 1.0 (on parity with Hybrid Renderer V2).
not sure what this means. In 2021.2b13
@eager pawn you can start by running you code without burst to have a better idea of the actual error
i recoded everything and removed the gamemanager with the monobehaviour. i now got something that's working. ^^
Looks like it's about Graphics Picking. It's a technique in Rendering which provides an alternative to Raycast picking.
Consider trying to select an object a user clicked through the transparent material of a hollow shape. Casting a ray would intersect with the collider shape between camera and aimed object.
So the gist of the technique is to render off-screen each different object with a unique color, hashed from its ID for example. Now when user clicks on viewport, you can pick the pixel color at clicked point coordinates, revert back from color code to ID, and here is your target object, regardless of obstacles in front of the camera.
That's my best guess anyway ๐
sounds like a good guess. Thanks.
Ah found it here https://github.com/Unity-Technologies/Graphics/pull/6071
Looks like they're more concerned about having a bridge with BatchRendererGroup rather than transparent edge-case ๐ค
The basic idea here is to define a new shader for URP/HDRP and use that only when rendering the BatchRendererGroup objects for the picking (renders object instanceIDs in a tiny 4x4 texture, then read it back from CPU).
It does work
if it also works when you hit the converttoentity on that gameobject you just created, you can probably play spot the diff and get it working hopefully :X
Unity's DOTS stream up in a bit (20+ minutes)
That, actually helped. It was on the wrong layer mask. Thank you.
Question: how do I change the name of an entity as it appears in the heirarchy
there's a setname function in entitymanager
ah ok thank you
late as usual
Dunno if CpyAnd is in here, but here is better to chat than Twitch ๐
I use DOTSNET instead of Netcode, because back when those were first releasing, Netcode seemed super focused on making competitive FPS games work and not much else. DOTSNET seemed more flexible. I haven't kept up with Netcode at all since their FPS sample released, so others may be able to chat more about how Netcode is flexible & usable now?
DOTSNET is tricky to learn as a networking rookie, but the dev is super active & helpful. And super flexible for my Minecraft/Astroneers-inspired game.
Finally talking about dots on the stream
"We were a little bit silent about dots" ๐
kinda weird to talk about the basics...
i assume this is aimed at those who dont know what dots is\
feels like marketing rather than q&a
that's what GDC is ๐
a touch rushed tbf, if i didn't know dots i'd be none the wiser based on what he's saying
you'd expect a q&a to be different than showing sizzle reel
gdc's nature has nothing to do with it
ask hard questions in twitch chat - i'm sure after the introduction they'll get into more details
are they collecting questions now?
it's raining questions
ehhh lebaron question
I'm totally expecting it to be jump from 0.5 to 1
"communicate every quarter" and "release next quarter" means "no communication til the next release", right?
with minor fixes to 0.5
already said animations will be 1.0 right?
cries in 1.0
1.0 doesn't usually mean 1.0 with Unity features ๐
so basically - if you make games, that have game stuff, like animation, forget about it until 6 months after 1.0
so much for the 3 year plan :p
6 months sound optimistic
I mean 1.0 was supposed to just be core DOTS all along but everyone expected animation and audio to be part of it ๐
omg so many questions on twitch haha the last 7 hours of interviews there were hardly any questions
that's why i build everything with hybrid (at work). huge pain in the ass but at least we can use some game object stuff that works..
i have a mental image of a thousand DOTS nerds in clown costumes getting out of a little volkswagon ๐
I don't really agree on this current view on DOTS enabling you to run things on lower end devices
unless he's talking about like some future vision
sounds nice for the investors though
if you do something that needs brute force computing, sure it does help but you've then already designed the game to work with some DOTS tech.. but if you have traditional game and port parts of it to DOTS/ETC, you won't see huge gains for it.. can even have negative perf impact in some cases
well he's talking about the ability to gain a lot of performance to run the same content on lower end devices right
I don't think they've said anything so far that we didn't know, right?
when I still evaluated DOTS and just used Unity's own DOTS systems and none of my own, things actually slowed down due to less performant rendering and physics
that's kinda why i'm annoyed about animation missing because it's such a huge bottleneck in unity.. but i think there's other stuff that can benefit a lot from dots performance
it was actually related to what I asked on the twitch chat... I found out that letting job system to run uncapped worker thread amount just caused perf to tank
URP is definitely slower by default than old standard renderer
tbf isn't that something that they are working on atm?
in my experience at least
if I limited the whole job system to run on few threads, it improved DOTS system cost
but limiting the whole job system's worker amount is silly... you'd just want to limit the certain systems there and get huge gains
Was it the ecs that slowed things down or was it just hybrid rendering/dots physics?
now I can only max like 1/4 of my cpu capacity
@devout prairie maybe im still in denial but im still hoping the animation team returns to public releases
i think in a lot of cases limiting to single threaded with burst will give better performance
unless you're using large data/iterations
like theyve made it clear that 1.0 no animation, but I just kinda hope it resumes unofficial/experimental releases soonish that fall outside of the whole "production ready" disclaimer they are pushing around 1.0
man it would be nice if they did, it's such a key thing
According to the animation roadmap, dots is the only thing they're working on. ยฏ_(ใ)_/ยฏ
my issue here is that to get good perf on more traditional game design / content, you'd have to push it back to few threads, where whole DOTS was advertised to go wide on all cores
if i see some of the main animation guys(mecanimdev, adam mechtley, some others i cant recall) say: "yeah not gonna release anything until its actually production ready" then obviously id be crushed
I'm only on 12c / 24t system... I can only imagine how badly this works on 32c system ๐
yeah it could be a year at least in that case before we see anything at all
That's pretty much what they have to do, I think. The same thing happened in the New Input System; Renee hacked together a way to make it work with DOTS, and then it got frozen since they didn't wanna spend time on continuously making it work with random DOTS changes and get the NIS out of preview
I think Unity became super conscious of their current reputation. I fully expect no animation release until it is "production ready"
they are publicly traded after all, they should care about their rep
renee's work was like a personal/hackweek thing afaik, the dots animation team have been working on it full time
not quite the same thing
True, but still.. not exactly having much hope re: animation based on that ๐
so there is a "DOTS new input system" package? is the source code available?
It's a branch on the InputSystem repo on Github: https://github.com/Unity-Technologies/InputSystem/tree/dots-input
Also might need this: https://forum.unity.com/threads/dots-input-prototype-hackweek-2020.926939/#post-7304473
we'll now i know what i'm doing this weekend
Got my hopes up. last commit: Jul 13, 2020 ๐
doesn't matter. good inspiration for my own project ๐
I'll double-check to make sure my old repos that had it all working still work on the new DOTS next week, but yeah... the thing that makes new input work in DOTS might break since it's all about turning those input classes into systems.
i wonder if the attaching tags approach worked out quicker than just having the tags as components on all entities and polling them
im assuming this is dumbed down ๐
doesn't sound performant imo :X
i guess it would be if there's only limited numbers of tags so minimal restructuring stuff
performance probably came from burst rather than ecs
well if you consider the inefficiency of running hundreds of mono's all randomly accessing memory over and over every frame
compared to highly contiguous batches of memory accessed only when needed, it's going to be night and day right
but in practice, is it a difference between 1ms and 0.1ms
or even less
heh 1.0 with 2022 confirmed! (except not at all but seems like thats their optimistic goal)
you can still do that with jobs ยฏ_(ใ)_/ยฏ
i guess it all ads up
putting it in jobs would make more sense ://
but yea maybe they have other stuff that work tgt with it
might just be more convenient i guess
so many questions in chat that'll never get answered even if the stream had infinite time...
The very pointed and emotionally-charged questions will never get answered, like that wall from ashkan
Kinda expected since there's no real communication though ๐คทโโ๏ธ
It's all pent up
yea even tho it has valid points i wanted to know abt
iirc he said 0.51 is like 6 mths away, not sure tho
when in 2022 tho, they are wrapping up 2022.1 now... hopeful it drops earlier in 2022.2alpha
he said 2-3 months for 0.51
๐ฎ
this has been a rather disappointing session honestly. looks like IPO really did a number on unity.
6 months would be brutal. i take the 2-3 months. would love to update 2021 projects
I want 1.0 to drop in alpha as soon as possible.. I have a lot of work to convert my custom hybrid ECS to DOTs and Unity Physics.
wonder if we'll even get 2022.2 alphas....
normally we would have had them for a long time already
lts? no idea, havent followed the betas since dots got locked to 2020 ๐ฆ
I would be really disappointed and surprised if DOTS 1.0 dropped like the day 2022 LTS drops.
I think its more likely it hits the tech stream.
Don't worry, it'll drop just a few days before LTS!
(Please keep in mind I did not specify which LTS)
I refuse to believe it.. because it will screw up my plans ๐
haha
would have been funny if he said it does not use DOTS
sadly we all know in our hearts dots wont be rdy anytime soon
depends on your definition of ready
they are like completely rehauling systems to be multithreaded and cache aware
after years of stuff that dun care abt that
tats true
I am perfectly fine with 1.0 not being 100% pure dots.. I am even ok with it not having some desirable features like audio and animation. The benefits are still there.
their original goal was to build another unity from unity tiny ๐
would already be great to have up to date sample projects without 100 TODOs
same, even after using dots for like almost a year, i still can't get used to doing hierarchical transforms in dots
most of the time my brain is like thinking abt whether i am doing the dependencies right so that things dont get updated one frame late
really curious about the performance impact of the replay system. i guess a racing game produces not that many different kinds of inputs so it's not that high but i guess we'll never know
I don't think it's even that game specific thing... for mobile racing game you probably have more limited amount of inputs but having like double the input values wouldn't change the cost. it's also not something new... people have done this for replay systems for a long time if their sims have been deterministic
done my own with DOTS but not sure if the implementation was that optimal. that's why it would have been interesting to know how theirs performs
I'd guess the main reason why people haven't used this in this manner is because doing deterministic simulation which you can rewind and resimulate using Unity has been really hard
stateless dots physics would help a lot on that
isn't the current approach of dots physics to keep as little state as possible?
- can the Havok physics interact with GameObject physics?
- Can a monobehaviour raycast against Entities colliders and physics?
entities physics don't interact with go physics
guys, anyone used dots netcode, is it good enough to use?
- im trying to create a list of all the units in the game. one idea i have is to read all files in the UnitComponents folder, and add each unit into a dynamic buffer.
or alternatively, maybe i could just manually create the list of units myself using a blobasset and a blobarray which would also make the data immutable? - i want (preferably) a fixed sized mutable datastructure that holds a bunch of randomly selected units, for example, shopUnit[0] might hold a unit[randomIndex], although it's no big deal to use a dynamic buffer for this.
- all the units have a baseAttack and an Ability() where the ability will be something like Debug.Log("unit 1");.. so i was thinking i would have one system per unit type, but the only way i know how do distinguish between Entity unit1 and Entity unit2 is by filtering by component types, which would mean i would need to create a component for each unit too?
i hope im making sense. im inexperienced and i don't have really have a reason to do things in any particular way so im fine with a completely different approach that may be better at accomplishing my goals, thx :))
- it really depends on what exactly unit type means in your game, and how much optimization you want etc
for example if you store unit type in some component and select all entities with that component, then you can check component value to get type you need, its acceptable way
Alright, I will implement something real soon like that. Ig It just seems like it wouldn't be very DRY because I would repeat myself by creating new IComponentData for each unit where the only difference is their name.
Pseueocode:
Unit1 { blobassetreference}
unit 2 {blobassetreference}
unit 3 {blobassetreference}
Blobassetreference {int baseAttack;}
... This seems weird to me, but maybe it's not wrong
Not sure what you mean, im not familiar with dots ECS specifically, IComponentData is basically new component? Why would you need to create it for each unit?
Yes, a new component. I want unit1 system, unit2 system, and unit3 system.
The only way I know how to make different systems is by adding a component tag and filtering.
pseueocode:
Entity.WithAll<Unit1> { Debug.Log("unit 1")}
Entity.WithAll<Unit2> { Debug.Log("unit 2")}
Entity.WithAll<Unit3> { Debug.Log("unit 3")}
if you dont need to store any new data for each unit type, you can just use Unit component and inside it property like int UnitType and get units like that
foreach unit component iterator {
//get component data here
if (unitComponent.UnitType != (your unity type from system)) continue;
//your system code
}
or you can just make component for each unit type, since you making new system for each unit type anyway
or 1 system and 1 component for all unit types with something like switch for conditions and multiple methods (for each unit type) (so you wont iterate for units you dont need)
Hmm okay, maybe I could make things more generic like you suggest
again, pseudocode, but something like this? (i removed the blobasset for now for simplicity)
{
public int baseAttack;
public int unitType;
}
Entities.WithAll<UnitComponent>.ForEach(() => {
if (UnitComponent.unitType == UnitTypeEnum.Sonic) {
// sonic system
UnitComponent.baseAttack = 1;
} else if (UnitComponent.unitType == UnitTypeEnum.Mario) {
// mario system
UnitComponent.baseAttack = 3;
}
})```
^
ye, something like that
yeah okay, i don't know what made me think this wasn't possible to do ๐ค but i like it! thanks, having one system and one component for all generic units make much more sense than doing one for each xDD
although, won't the mario system and sonic system override the data of unitComponent.baseAttack? or perhaps that's only if you use that sharedcomponent thingy
is it like init System? well you working with instance of component for each entity, you cant override anything
if i understand you
dw, im pretty sure im wrong. i was thinking since both entities hold the same component, then changing the component's data would mess things up. it's probably more like they hold different instances of the same component so it won't happen
UnitComponent#1.baseAttack = 1;
UnitComponent#2.baseAttack = 3;
same "object" but different "instances"
yes, components are entities data basically, its dynamic data mostly that you changing for each entity (like position of entity), as well as "static data" that you dont want to be changed, but technically you can (like unitType)
right! this solved a lot of headaches for me and i think things finally are clicking. this was super helpful, thank you :DD
so in 0.5 is there any clarity on hybrid work ie is the game object conversion stuff still the same or anything changed with the whole 'companion' thing
i'm guessing that's more in 1.0 territory
they havent really mentioned anything (and took away AddHybridComponent)
Small question, what unity version does support Spans in C# code ?
unity doesn't support span<T> I believe
Not even ReadOnlySpan ?
Since when ? My 2021 editor says they cant be found ๐ฎ
I'm on 2021.2.10f1
Im using asmdefs and stuff, do i need to add something to them ? ^^
no, you don't, but my 2021.2.10f1 isn't complaining at all
well I think I'm wrong, i dunno.
I'll just shut up lmao XD
I haven't looked into subscenes much, do they provide any benefit when origin shifting large scenes?
I have my own hybrid ecs/jobs system, with a large world coordinate library. In my monobehaviour prototype, I have a render space of 50km (before shifting object renders) and the world space scenes of 2km (for physics colliders) and while origin performance is acceptable, I am looking to convert it to and curious what strategies exist out there to accelerate this kind of overhead.
Can someone tell me how to handle trigger collisions, all tutorials are using JobComponentSystem which is obsolete. Also I couldn't find anything at the documentation either.
Just updated to unity 2021 and got this...
0,0): error error DC3002: Script.Client.ECS.Systems.Reactive.ReactiveSystem`3/AddedJob: generic jobs cannot have their reflection data auto-registered - you must use the assembly-level RegisterGenericJobType attribute to specify which instantiations you need
What does this even mean ? That Reactive Systems job uses a passed generic, thats all... why shouldnt this work anymore ? ( Worked in 2020 )
@tame pelican just replacing JobComponentSystem by SystemBase does not work on hte exemples ?
you have a generic job somewhere that need to be declared for burst to take it into account.
something like [assembly: RegisterGenericJobType(typeof(AbilityCostConsumerSystem<GENERIC>.CostHandlerJob))]
obviously not, in tutorials you create jobhandle which requires inputDeps which you don't get with OnUpdate overrided method of systembase
Thanks !
Another issue...
Library\PackageCache\com.unity.dots.editor@0.10.0-preview\Runtime\Unity.InternalAPIEngineBridge.002\TreeView\TreeView.cs(779,28): error CS1061: 'ListView' does not contain a definition for 'm_ItemHeight' and no accessible extension method 'm_ItemHeight' accepting a first argument of type 'ListView' could be found (are you missing a using directive or an assembly reference?)
Why do i get this error now ?
I'm not sure how to combine that with the physics
do you still have com.unity.dots.editor package in your package.json ? You need to remove it if you have entities 0.50
The official samples were up-to-date to entities 0.17 and physics 0.6
https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/UnityPhysicsSamples/Assets/Demos/2. Setup/2d. Events/2d1. Triggers/Scripts
If you use 0.50 (a PR is on the way to update the samples) or working from an old tutorials, you can always read the changelog from some date in the past to nowadays and apply any upgrade required
Oh... since when ? xD Im gonna try this, thanks
I hate upgrading packages
yeah they merged the editor within entities
they said it in the upgrade guide or forum post, can't remember
make sure you're on 2020.3.30 lts
make sure you are in version 2020.3.30f, and follow upgrade guide
Not until they release 0.51 in q2 of 2022
Read the annoucement in the forum ๐
I just want to know when 1.0 will drop into 2022 tech stream alpha/beta... ๐
I have no interest in developing against 0.51, which will change radically for 1.0.
The editor improvement look nice though, won't they help you meanwhile ?
oh .51 not .50, I misread ^^
My concern is I am in the process of developing my game backend infrastructure. Redoing this work late in my development cycle is a no-go. Editor tools/enhancements are nice to haves for me, nothing more.
Fair
My project depends on 2022 tech, so its really not an option anyway and my release target is 2022 LTS.
Can i use entities with 2022 beta ? xD I bet thats also a no, right ?
The DOTS 0.50 release seems to be mainly target at those who already had DOTS projects. If someone is early in their development cycle today, I have a hard time imagining they would want to start their project in 2020.
not yet... hopefully once 2022.2 alpha/betas drop.
Okay which entities version should i use for 2020 lts ? ^^
0.50 can be used with 2020 right ?
Thanks, but 2020.3.32f should also work right ?
And JobComponentSystem is gone now ? Can i still use it like this :
// Add the added component job
var addedJob = new AddedJob{
ecb = ecbParallel,
entityHandle = GetEntityTypeHandle(),
componentHandle = GetComponentTypeHandle<TComponent>(true),
added = added.AsParallelWriter()
};
addedJob.ScheduleParallel(newEntities, inputDeps).Complete();
?
Dunno what happened between 30 and 32, didn't have a look so can't answer
JobComponentSystem is obsolete now yeah, replace with a SystemBase
Please read the guide, all your concerns and more are raised
But yeah you can schedule a job like you did in SystemBase
Just going to leave this right here
tempting lol
Nice
im quite disappointed it appears the newest game sample isnt based upon dots(like megacity, fpssample etc) ๐
told you
yep, you were right!
I have yet another good reason (in addition to generic blob) to have the entities package as a local package then. Thanks for sharing !
Something i cant find in the migration guide... Cant we use "commandBuffer.DestroyEntity(query)" anymore ? It says its invalid
Ahhh solved
They renamed that, doesnt make sense but they did... cool
Is there a way to check if an entity command buffer is "active" ? Or created ?
er var commandbuffer = system.CreateCommandBuffer() @stone osprey
That creates one... but what if i have one for this frame and i want to check if its still existent ? Hard to explain but i have a system where those are being created automaticly
Have you looked at the IsCreated property?
assumably you have a system that plays them back right? like that timing between creation and playback is where they are valid
So umm, how do i set a dictionary on a entity? Nested dynamic buffers?
Generally you don't and it'd need to be quite large to be worth it
That said I just released a dynamic hash map https://forum.unity.com/threads/dynamichashmap.1256154/
Is this restricted to the normie types like int, float etc, or can I use entity and stuff too?
Anything unmanaged
Is it mutable?
Yes
The only thing to really note is that if you're storing Entity it won't remap if you set it up in a subscene so you need to populate it at runtime instead
That's cool, thanks for creating this. I'm a bit worried your package might break in the future, but you seem very active with dots
It's unlikely to break unless unity deleted dynamic buffers
Only other real alternative is to use unsafe hash map and deal with having to manage the memory yourself
im creating Meshes at run time and want to storage texture in NativeHashMap, but its require blittable type. So can i store texture in BlobAssetReference and the Blob asset store as value in NativeHashMap?
Does your texture storage need to be on an Entity?
Seems like it should just be held in the system that's applying it
nope, im just have static class with this NativeHashMap. Im wondering is it a nice decision store texture as BlobAssetReference ?
I am being on 2020 LTS just because it's LTS. Is 2022 stable enough to switch for this or would it be better to wait for Unity official 2021 support
I'm not using that just pointing out someone else's work
@tranquil jay unless theres something specific you need, id just stay on 2020.
Eh no thanks
what is the best way to get a reference to a different system from inside a system? OnCreate doesn't seem to work because the other system isn't created yet, so OnStartRunning?
Use on create
And use getorcreateexistingsystem
As the name suggests it will create the system if it doesn't exist yet
I need the Decal upgrade of URP which is 11+, and it stops at 10 in 2020
sorry for being dumb but how did you intend me to use this? I tried adding it in the package manager using git url, but it didn't work, at the moment i just extracted your files into my assets folder, but i get errors like: 'UnsafeHashMapData' is inaccessible due to its protection level [Assembly-CSharp]csharp(CS0122)
is this cause im using a different version of collections or something?
at this point i almost feel like doing
units = [unit1, unit2, unit3, unit4, unit5, unit6, unit7, unit8, unit9];```
but it's probably better to do [EntityOne, EntityTwo, EntityThree] for the first dimension, and then give each entity a dynamic buffer for the second dimension?
alternatively maybe nested UnsafeList
Wait I could just use unsafehashmap?
Unity devs please give us a native Materiallist that can only be written during start and awake, so we can point to those materials
you sure you want that? why not just apply the material to the mesh renderer in the editor?
Was writing about it yesterday in the advanced section. Unity instantiates a new material when switching materials, they even wrote it on the material documentation.
Lets say you select 30 units in an rts and instead of switching a boolean in the shader (which can be costly depending on how big the shader is and how many different shader those 30 units have) you could just point to the exact same highlightmaterial (that is readonly).. which then can easily be batched also.
but material is part of a SharedComponentData iirc, so just point to that?
gotta try it out thanks
Hi. Not sure if itโs the right channel, but what could be the reason the job system is limited to 1 worker thread on a headless build on Linux? I tried launching with -job-worker-count 2 and it just logs JobSystem: Invalid job-worker-count value 2 must be between 0->1 right at the start. Any hint on how I can find out more where this limit comes from? (2020.3.30)
Hi, i have a question about shared component data :
Can i treat it like static fields ? so if Entity a changes the shared component, the change will also be visible for Entity b (in its shared component) ?
If not do you have any reccomendation how i can achieve something like this ? (like a buffer that can be accessed by all entities)
@vocal wing how many cores/threads on the system?
that's exactly what sharedcomponentdata does
perfect thanks
but you can't use it with scheduleparallel()
It's 2/2 running on a c5.large instance using amazon linux if that helps.
hm I guess I would double check the vm definitely has access to 4 threads? otherwise I guess its not normal
oh nevermind, I missinterpreted it. it's actually 1cpu, they just call it vCPU, so I guess you're right. i'll try it with more cores to see how it behaves.
is dots easy now?
Any idea why i get this shitty error ?
What do they even mean with reflection data ? I think i do not use reflection anywhere
How to do dots?
No idea honestly
I just try to run my job like this
// Add the added component job
var addedJob = new AddedJob{
ecb = ecbParallel,
entityHandle = GetEntityTypeHandle(),
componentHandle = GetComponentTypeHandle<TComponent>(true),
added = added.AsParallelWriter()
};
addedJob.ScheduleParallel(newEntities, Dependency).Complete();
Any one having an idea why i get the error above ?
@ionic sierra hasnt really changed in terms of ease of use from before 0.50 to current.
ok.
anyone know how to instantiate soemthign in dots?
EntityManager.CreateEntity
take a look at https://github.com/Unity-Technologies/EntityComponentSystemSamples @ionic sierra
pinned messages has links to docs
dots uses reflection
for some things
Thanks... do you have any idea how i can solve the issue above ? My code looks like this :
protected override void OnUpdate() {
var ecb = atFrameStartBuffer.CreateCommandBuffer();
var ecbParallel = atFrameStartBuffer.CreateCommandBuffer().AsParallelWriter();
var addedEntityCount = newEntities.CalculateEntityCount();
var removedEntityCound = entitiesWithStateOnly.CalculateEntityCount();
var added = new NativeList<Transmution>(addedEntityCount, Allocator.TempJob);
var removed = new NativeList<Transmution>(removedEntityCound, Allocator.TempJob);
// Add the added component job
var addedJob = new AddedJob{
ecb = ecbParallel,
entityHandle = GetEntityTypeHandle(),
componentHandle = GetComponentTypeHandle<TComponent>(true),
added = added.AsParallelWriter()
};
addedJob.ScheduleParallel(newEntities, Dependency).Complete(); // ERROR HERE
}
Once i try to schedule the job it throws that weird error
don't think it has anything to do with your code
Oh well... thats actually worse... so do you think i have the wrong package versions ?
Thats a system i wrote myself... the code above is copied from it, the last line is the line where the error happens ^^ The line where i try to schedule added job
what's newentities?
a query it looks like
Yep just a query... newEntities selects all newly created entities ^^
I also cant find any other sources on that error... no forum posts or similar stuff sadly
But this piece of code ( from unity itself ) causes it...
Looks like T is my "AddedJob"... and the check reflection method simply checks for a null pointer
But i have no idea why its null and throws that issue
my best guess would be something went wrong during codegen but I'm not sure
Is there a way to trigger the codegen again ?
try restarting unity
I'm stuck rip
Did... but the error persists :/
I hate such errors... what else would you suggest ?
Delete Library folder to let Unity rebuild it ?
You mean the whole package folder ?
Nope, the Library folder
If you can't delete lld.exe try restarting ur pc.. That's what I had to do to delete library folder
yes, you were right. with an actual 4 thread instance I get 3 workers. thanks. ๐
I have several errors in the entities 0.50 package...
Like 110
At some points there even errors like "List" ambigious calls or however you write that word
Any idea why this is happening ?
Looks like there no posts about that issue in the forum... sooo im kinda stuck with it
Especially the subpackage editor is full of errors
Those are my packages...
Anyone having an idea ?
did you just upgrade to 0.50 to try to fix your previous error?
I upgraded yesterday ^^ and i just rebuild the library which results in this beautifull errors above
i would comment out that one job/system that seemed to give you errors
I will... but currently i have all those issues above ^^ The ones in the entities package itself
occasionally I get like 15 errors in entities package when one non entities package thing is broken, some odd new quirk of the codegen i guess
So this is no big deal ? Does it even compile with errors in it ?
not until I fixed my own shit
regenerate the project files
Still need help with multidimensional datastructures on entities. I'm aware of a couple solutions, but idk if they're any good
Or if my design is even good in the first place but I think so
also: what ide are you using?
So i still have like 130 errors inside that damn entities package and i still get the damn jobs error which makes no fucking sense... i hate it, i think its easier to go back to 0.17... or does anyone know how i can resolve all that weird errors ?
I already rebuild library
Wheres that one dots god that always has a solution ?
Maybe I shouldn't even do this in ecs and just make it in non-dots code
When i try to clean and build my solution... this happens
Entities cant even find collection stuff like UnsafeList or NativeList
"Type or Namespace not found"
What the heck am i doing wrong ?
regenerate your project files
How ?
Actually never did this before ^^
I recently deleted the library folder... if thats what you mean
edit -> preferences -> regenerate files
Thanks ๐ I just clicked it... anything else to do ?
Well somehow this didnt worked, the exact same errors
Did anyone got entities 0.50 to work ? If so... could you please post your package manifest ?
Thanks ! Do you use 2020 lts ?
yes
Great ^^ And do you get any errors inside your IDE regarding the damn entity packages ? My rider ide told me there like 138 errors inside Unity.Entitites
no, but i would get similar types of errors every day cuz my code is wrong lol. i have no errors as of now tho
are there still the 'type not found' errors
Yes there are... i will now just take @eager pawn package manifest and rebuild the lib... i hope this fixes this damn issue
oh btw my project is unity 2d, no idea if that has an affect on package manifest
We will see ^^
Should NOT do that honestly
Why ? ๐ฎ
well it will remove your packages and put the ones in the list
2 different projects are... different projects
Yes which is great because mine do not work... i get errors like crazy from entities 0.50 because it cant find certain stuff xD
Errors like those
Its german, but basically "Type or Namespace not found"
it won't rebuild entities 0.50 because you use it
but it will remove any package you have installed and @eager pawn did not
- install the 2d packages you don't care about if your project is not 2d
and so on
Alright how should i ever solve those damn errors above ? ^^
Do you use assemblies ? Maybe assembly references broke when you upgraded ๐คทโโ๏ธ
Yes i use asmdefs... but how would i fix this ? The errors are inside the entities package... my code is fine
Like entities editor cant find certain classes... entities itself doesnt even know what an unsafe or native list is during build and such stuff
can you make a new project and import all your assets from your existing project?
Oh well this will take hours :/
why? just export all to a unitypackage, then import them
Well i could try this ^^
Besides that... is it possible that entities 0.50 only works with 2020.3.30 and not with 2020.3.32f ?
Both are lts versions
nah, works with 30+
Alright... so this cant be the problem
So i deleted all packages and resolved them again... same issues
EditorWindowBridge... where is this shit even from ?
Can you paste your packages.json?
there it is ๐
Remove platforms package
Gonna try this, thanks ! What is this even for ?
Wait actually you need to upgrade it to 0.50 same preview version as entities
Confused it with the dots editor
Which got merged into entities
Alrightttt, putting it back into the packages ^^ one moment
Well it cant find the platforms package anymore... damn
Ah looks like its hidden
It should be the exact same preview version as entities
So just modifying it by text should do the trick
If I'm not wrong, adding com.unity.platforms in the package manager should give u the newest version automatically
That too
Alrighttt soooo
The platforms version should be fine now, right ? Its exact the same like that from entities
Oh wait
it cant be found
So i have installed it now... "com.unity.platforms" version 0.50 preview 4
Lets see how it goes
WEllllllll
Same issue...
My updated package manifest looks like this now...
Sooo i had some progress here... It now tells me the following
It cant find a "UnityIAPIEditorBride.dll"
Which may cause that issue above
Does anyone know what that is and where i can get this from ?
I regenerated the project sources and this issue is gone now
Finally
So back to previous issues...
protected override void OnUpdate() {
....
// Add the added component job
var addedJob = new AddedJob{
ecb = ecbParallel,
entityHandle = GetEntityTypeHandle(),
componentHandle = GetComponentTypeHandle<TComponent>(true),
added = added.AsParallelWriter()
};
addedJob.ScheduleParallel(newEntities, Dependency).Complete(); // Error, Reflection Data was not set up by initialize() call ??
}
public struct AddedJob : ...{}
Does anyone have an idea why this wont work in entities 0.50 ? Its a schedule & job related error....
no. what issue?
what about separating schedule and complete?
Tried that, same error :/
AddedJob implements which kind of job ?
IJobChunk ^^
OK it's deprecated but I don't know if obsolete yet or if you can still use it
What should we use instead ?
My editor says its still fine and not marked with obsolete or deprecated ^^
Hmmm... so the replacement for JobChunk is JobBatch basically ?
added is a Native container ? you instanciated it ? Sorry I'm just throwing ideas
IJobEntityBatch yeah
was already advised on 0.17
Yes like this var added = new NativeList<Transmution>(addedEntityCount, Allocator.TempJob); it looks like that the damn was not initialized is a direct job issue, i will try to replace it real quick with entity batch
yeah actually you would have had a different error if you didnt instanciated the container, my bad
Well i replaced it real quick... but the error stays ๐ฆ :
This little piece of code causes it in the schedule method
T is the Job struct
The job is nested in an class because it makes use of some generic stuff... is this probably the issue ?
whats TComponent?
The Generic i was talking about ^^ Its a generic job which worked pretty fine... its basically nested like this :
public class GenericSystem<T>...{
public struct AddedJob{ // Works with component T }
}
'which worked pretty fine' in 0.17?
Yep it did ^^
Looks like that nested struct is really the problem, scheduling jobs outside the system works fine
Please tell me theres a nice solution to bypass this problem...
it's a problem of the new codegen which only works on the outer most declaration and forgets generics and attributes
You can try using this in your on create
JobEntityBatchExtensions.EarlyJobInit<YourJob>()
No idea if burst will catch your job tho
I want a dictionary/map on a component. I could explain in further detail what game I'm actually trying to make if that helps? Maybe my entire approach is wrong.
You are my hero... it works, thank you so much !
@stone osprey was that error being called during playmode or actually preventing a compile?
Do you not have a : restriction on this type?
@rotund token what do you mean by restriction?
ah
Do you need to change the dictionary at runtime? If not, there is an implementation of a BlobHashMap that has been shared here and on the forums. If you do need to change it at runtime, then the best solution probably depends on the size of the dictionary. If its a small, I would just use a DynamicBuffer and iterate the entire list to find the matching element.
Or use this from @rotund token : https://forum.unity.com/threads/dynamichashmap.1256154/
Tertle code ain't working for me, although it's just a few accessibility errors so ig it shouldn't be too hard to rewrite stuff. Not sure if there's a version mismatch or something that's causing it ๐ค
But yeah, a blobhashmap and a dynamichashmap is exactly what I want. I in the blob, I want exactly 5 unit tiers with each tier holding units. Later on, you will be able to customize each tier (but not the amount of tiers), so I could put some of the tier 2 units from the blob into tier 2 of the dynamichashmap
Hmm, I would probably need to know more about your use case, but I'm wondering if you even need the hashmap. Can you just have tag components for each tier and then use a query to grab the units for a given tier?
When the game starts, a datastructure with all units will be put inside it, as well as their associated tier. This can be a fixed length and Immutable.
If you choose to customize a tier, let's say tier2 (similar to customizing a card deck) you can copy a bunch of t2 units into the dynamic buffer, obviously this has to be mutable. I don't think a single dimensional array will work, but if I had two I could do something like, pseudocode:
unitTiers = [1,1,2,2,3]
units = [unit1, unit2, unit3, unit4, unit5]
In this example, unit5 would be the only tier 3 unit.
Since I have 5 tiers, you're suggesting maybe I could 5 entities, the first with tier1conponent, the second with tier2component, etc? Then each entity holds a dynamic buffer? I think that works too.
With the dynamic approach, each element would store a reference to the unit and the tier it is in. Basically, just squish your two arrays together. So it would be something like:
struct TieredUnit : IBufferElementData {
public Entity Unit;
public int Tier;
}
And the idea with tagging is that you never need to store the list of units by tier. Instead, the tier is stored on each unit entity as a tag. Then you can query for all entities that have the Tier2Tag.
Ohhh, I didn't even consider I could do it that way, I will try it first thing when I wake up tomorrow :DD
@blur
You probably don't need a map structure since you seem to have a fixed immutable dimension. If you now you have 5 tiers and then you want to have any number of unit of any tier, a simple implementation would be to have one buffer per tier so 5 in total.
For the non mutable structure you could do the same and have a blob asset with one blob array per tier.
Of course this is bad if you want to have a 6th tier at some point...
During play... But its solved now :)
However... After upgrading to entities 0.50 my whole simulation group is pretty slow now... looks like theres something weird going on
Btw... is it now more performant to tag entities with empty components in entities 0.50 ? In previous versions it was quite expensive due to heavy copy operations from one archetype into another and similar stuff
I don't think anything changed there. But I'm also not using structural changes and I haven't done a specific test to compare 0.17 to 0.50.
from what I've seen in my own project and report from others. There are no performance differences between 0.17 and 0.50
Ah could you let me know what's wrong? I didn't test pulling it out of my library but I did have a quick check that it wasn't depending on anything else of mine
Does it depend on something internal from unity?
yeah, i think internal unity things may have changed, for example, CollectionHelper does not have a CheckIsUnmanaged method
https://i.imgur.com/4YtVJLA.png
im new to c# so idk exactly what internal means, but UnsafeHashMapData is an internal struct, maybe it was public in a different version? "'UnsafeHashMapData' is inaccessible due to its protection level"
https://i.imgur.com/Xt07cZK.png
and finally, the "it" variable never gets assigned to a value
https://i.imgur.com/q979ZI8.png
i added your code by extracting all files, including the license and stuff, and put them in a brand new 2020 LTS 31f project
https://i.imgur.com/EfxBNsb.png
that's the manifest for the brand new project
@eager pawn internal is an access modifier that basically means "restrict usage to files within the same assembly only". Read more here for example https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers
So yeah you can't really use internal stuff unless you recode it yourself
you could also add [InternalsVisibleTo()] to the assembly
Damn 2020 lts performs kinda bad... sometimes the editor runs at 15 fps without anything going on... even on empty scenes.
Can the ECB buffer component object operations ?
Cant find any method to buffer a object assignment
wdym by object assignment?
Doesnt matter anymore, solved it ^^
Besides that... can i run a "IJobEntityBatch" directly on the main ( RunWithoutJobs )
This was possible with IJobChunks
But the method is gone for IJobEntityBatches...
Oh and can i run jobs with passed delegates in it ? It worked in the past... now i get an error that job structs may only contain references ๐ฆ
I wanna run the jobs on the main so it actually doesnt matter
IJobEntityBatchStruct { }.Run(someQuery) if you want to run it on the main thread.
Thanks ๐ And what if i wanna pass a delegate to the job ( I use it as some sort of main thread callback )...
It currently throws the following exception :
Which is true for scheduled jobs and such... but it doesnt matter if it executes on the main normally
I imagine BurstCompile isn't an attribute on the struct right?
I think there was an attribute you can put onto a parameter
one second let me test it out real quick...
Alright thanks ^^
nevermind there wasn't an attribute
Doing RunWithoutJobs on jobs implementing IJobChunk didn't go through the job scheduler which is why it was allowed
If I remember correctly you can use GCHandle to pass managed types to jobs just fine
Does this work on delegates ? If so how ?
Pinning ?
Damn why did they removed that RunWithoutJobs...
You can try GetFunctionPointerForDelegate
I've only used it to pass C# functions into C++
I just wonder if that works when the delegate was modified in between with "+=" and "-=" operations... or if it requires a new function pointer after each modification
You can also change members of pinned objects so I would think so, but never tried it myself
Alright that sounds good, i will just try it and see how it goes ^^
Still sad that they removed that feature
Actually with this way, I guess there's no native c# way to invoke the IntPtr? ๐ค
I think you have to convert it back to a delegate to invoke it
And i bet this will not work becauseeeee its a managed type inside a job again
Oh boy, i hate it
Taking bets if it works or not
Once you are in the execute method you can do whatever with managed types
As long as you aren't using burst
Anyone else having issues with GenerateAuthoringComponent and IBufferElementData?
Great :> its not marged with brust so i guess it will work
Seems like it works with anything but Entity field. ๐ค
no? this works for me
[GenerateAuthoringComponent]
public struct UnitBufferElement : IBufferElementData
{
public Unit Value;
}
this is illegal cuz Unit is a reference type?
public struct TiersBlobAsset
{
public BlobArray<Unit> tierOne;
public BlobArray<Unit> tierTwo;
public BlobArray<Unit> tierThree;
public BlobArray<Unit> tierFour;
public BlobArray<Unit> tierFive;
}```
instead, i should do BlobArray<int> and then "map" each unit to an id?
iirc it will work in the editor but fail to build for IL2CPP
No matter what you do you cannot have a managed type in a blob
Just store the readonly data you want to have available directly inside the blob
ok, ig ill just use the UnitBufferElement then, and not the blobarray
What's the status of terrains in DOTs
Not even mentioned on the roadmap. So dead as a doornail.
So what is the current way to deal with gameobject based terrains. Render them as gameobjects , but manually extract their collider and convert to Unity Physics?
yeah I think that is how you deal with terrain physics now
May I amuse you with my latest article: https://coffeebraingames.wordpress.com/2022/03/27/why-job-structs-are-better-than-entities-foreach/
Hi, I'm new to DOTS, but im looking in to using it for the physics of my game, and was wondering if there is an equivalent to the built in unity Physics.Simulate function that I can use to manually progress the simulation forward? I haven't been able to find much relating to this online
Hi, how can i get pointer of NativeHashMap? I saw special utility class NativeArrayUnsafeUtility, but it is for Native array
You can create an entire ecs World to host your physics clone entities, then call the update method of the FixedStepSimulationSystemGroup as often as you like. You could also mess with the fixed timestep in the RateManager component ( don't remember how it's called )
Not a perfect answer but hope that helps
Also check the official samples, they have a pool game where they predict the balls movements taking future collision into account and such. I guess that's exactly what you want
perfect, thank you!
Can you schedule/parallelSchedule jobs which are NOT marked as burst compile ?
And can you acess managed stuff in there ?
Entities.WithoutBurst().ForEach()
I think you need to be on main thread to access managed components though? It will quickly give you an error though so just try schedule first and watch the errors ๐
@stone osprey
Thanks ^^
Something different... im still trying to run my jobs on the main thread, looks like i cant make use of the job.Run method because i can not convert my delegate into a pointer ( its a generic delegate and c# dont really like them )...
So my next guess i could just call the .Execute method. But that one requires a ArcheTypeChunk. How do i get the ArcheTypeChunk of a certain query ?
I wonder how to implement a grid in ECS, I'm not sure how to put that in component , and does it even need to be a component. The point is to access the element with coordinate/index.
Also would it be faster to access to non changeable grid stored in blobasset , rather than accessing the grid using nativearray or dynamicbuffer or whatever it takes?
What kind of grid
Did you try the GCHandle approach?
By the way, just found this while looking at some code JobEntityBatchExtensions.RunWithoutJobs
This should work like the IJobChunk alternative
Grid of structs with unmanaged types, which will have size almost never changed, but having data in it change every few seconds. Used for pathfinding.
Gotcha
You can store them in a BVH and query by AABB
Unity physics exposes one
That's how I'm currently building out my grid system
I'm afraid I don't understand you, can you clarify it more?
You can use the object produced by https://docs.unity3d.com/Packages/com.unity.physics@0.0/api/Unity.Physics.BoundingVolumeHierarchy.Builder.html
To query for blocks on a grid defined by AABBs
If all the blocks are the same size this is overkill and you can probably just use a map
Pretty sure that point of the grid is that the every block is the same size.
(I was referring to solution for game of bomber-man type)
Some grids may have blocks that are all the same size
Sometimes you might want to have blocks that span multiple cells
You are my hero... again xD
Why do they hide those methods always ?
Dunno, found it while looking at some codegen lol
Thanks a lot ^^
@worthy rampart I was referring to grid where you access elements by coordinate directly.
Array of arrays or a map
Depends on if it's fixed size
Or expandable/sparse
If it's fixed size you can also do a single array
With 2d indexing
can i create a blob from a system's OnCreate and later get it's data from within another systems OnUpdate, but only after the data has been set?
nvm, 2 systems can communicate if you put both their components on the same entity :))
Is dots supposed to work on release ? I somehow get my app ( Entities 0.50 ) to run on my phone in development mode... but not in release.
And i actually only use dots, no other fancy frameworks or packages.
why do the child gameobjects not get converted when I use convert and inject gameworld . i cannot use convert and destroy because i am using animator component to drive animation. Please help. using unity.entities 0.50
With working i mean, release crashes while development build does not
Anyone ever had a similar problem where their dots build crashes on release but ran fine on development mode ?
Crashes directly after the unity logo, Any help would be great
maybe too much code stripping
Thanks :) thats possible... It said something about segmentation fault due to a dereferenced pointer
Is there a way to reduce the stripping ?
in the project settings
I have a question since there is no answer I can find easily: Can you use DOTS Physics in Unity version 2021? or is it unavailable?
It is available, but not yet officially supported. So if you encounter compatibility issues between packages versions, you're on your own to fix them (I'm sure people tried already and the community shares a lot of fixes on the forums)
Support for entities 0.50 is supposed to come soonโข๏ธ though.
See this forum post for more details on what to expect and when https://forum.unity.com/threads/dots-development-status-and-next-milestones-march-2022.1253355/
In our previous forum post, we explained we need to go through 3 steps to get to 1.0:
- Reach compatibility with 2020 LTS: this is what is achieved today with the release of experimental Entities 0.50 and its compatible packages. Entities 0.50 is a breaking change from Entities 0.17.
- Reach compatibility with 2021 LTS: we are preparing a minor update to Entities, experimental Entities 0.51, that will make Entities and its compatible packages usable on both Unity 2020 LTS and Unity 2021 LTS projects. This update is currently scheduled for Q2 2022. More details will be shared as we approach its release.
- Reach compatibility with 2022 Tech Stream: the version Entities 1.0 and its compatible packages represent the ECS foundation supported for production for the entirety of the 2022 release cycle. Entities 1.0 will be a breaking change from Entities 0.51.
If you stay on entities 0.17 and physics 0.6, it works for sure. Again if you encounter compatibility errors from packages, there's some fixes explained on the forums
Thanks so much for this! I will begin to look into it.
๐ have fun !
Quick question about dots
My whole game is running without dots yet ( Iโm building a RTS game similar to mount&blade )
But now Iโm getting to the point to add AI and Iโll need a lot of them later on with good performance.
Can dots help me out with that? The AI would have animations and some logic for shooting and pathfinding.
Is dots capable for that? And is it different to normal unity system?
are colliders in DOTS supposed to respect a NonUniformScale?
(I know some like Sphere can't)
Hey any up-to-date tutorial for DOTS?
Most tutorials are from 2019 and I can't be sure if they're obsolete

TurboMakesGames on YT
the doc pages are your best bet for being up to date
I wouldn't say DOTS is particularly tutorial friendly
lots of good snippets on the forums
Yeah over the past few years only a few things that were extremely well-document that I was able to learn from docs
Most of the time docs can only be used as a reference, not a getting-started guide or tutorial

also good for getting started
lots of isolated examples of using various parts of DOTS
@worthy rampart only translation and rotation, no other transform components
when i do var blah = myNativeArray;
changes to blah will also change myNativeArray right cuz it references the same memory address
ig it would't have a Copy() method if it didn't
Lol... i just had a similar question or more like issue.
One component stores a "UnsafeList" inside of it... i modify that list, but dont set the component new. Did the list update or did it not ?
It did not, sadly... dont really understand why. I mean even if i only own a copy of that component with the list, the list still should reference the same memory adress like before. Somehow it did not, it required a ".Set" new operation
I assume nativelist behaves the same. However i still dont understand why. That behaviour doesnt make that much sense
This is sad. Thank you
Ive done some more digging and it looks like at conversion time scale is respected
If you are converting from a gameobject
I dunno genar, but I hope you solved it.
Can I use ptr for unmanaged code? I mean I could try, but idk how to enable unsafe code, I already ticked the allow unsafe in unity settings
I need a mcs.rsp or something?
no, should work already then. if you're inside an asmdef you need to tick it there as well
MAYBE its cuz im using vs code instead of vs hmm
the error pops up in the editor and not unity itself
regenerate your csproj & sln files
aye! thanks! :DD
Hey, I am not sure this is the right place to ask that question but... What is the burst compiler + job system place in the game architecture? Does it replace only the asynchronous code? Is it just 'better' and 'modern' replacement for coroutines or am I missing something?
Job System is primarily aimed at multithreading code. It's not a replacement to Async-code nor Coroutines.
Then Burst acts as an extra layer on top that optimizes your jobs very carefully for maximum performance
Is game object conversion something that only happens in editor?
If you're using a Subscene yeah, there is also a runtime version but it's going to be phased out afaik
You shouldn't want to, it's pretty slow and expensive compared to pre-converting them
If you're thinking abour Prefabs then the conversion process is smart enough to also convert Prefabs to "Entity Prefabs". Assuming you're referencing them in your conversion script.
thanks ๐
So pointers are not allowed in a unmanaged component, right? Then an entity couldn't hold a pointer? Hmm so why would I want to use something like an array of pointers with ecs?
Entities can hold actual pointers
Oh.. How?
Not object references
Literal unsafe pointers
But you need to know what you're doing
Or you're likely to mess up
But would the component not be considered as managed if I did that?
Kinda like putting a blobassetref on it also makes it managed
My guess is whatever you're trying to do is possible without a pointer
Unless you are integrating unmanaged code
You've not given any info on what you're trying to do with the pointer so it's hard to suggest anything else
I was thinking of nested arrays/dictionaries and wondered if I should learn how to use pointers, maybe they will help me with making a datastructure.
I checked the docs and it said a buffer element is a native container which would make it managed, right? So references and pointers would be allowed? If so, couldn't the buffer element hold a pointer to an array or something, or maybe that'd be useless.. Idek dude sorry ๐ ๐
Nvm I must have misread, it's unmanaged
It doesn't sound like you've got the experience to do pointers correctly. If I were you I'd save myself the headache and figure out a way to solve your problems without them
I made my first pointer today so yea
Pretty much a pro now ๐
No matter how I look at it I get O(n) when it could have been like half the list, or O(n^2) cuz of a nested foreach, or some other jank I dislike. Or Its superhard to generalize it and I need to repeat myself or w/e sadge
Hi i have a question : Is there a way to model a Dictionary<key, List<value>> that can be used by the job system ? i tried implementing my own and working with NativeHashmap<key, NativeArray<Value>> but there he says it is not blittable. Is there a workaround or am i forced to use flattened 2d arrays
NativeMultiHashMap
thanks that works fine
Hey all, so I'm just checking out DOTS for the first time. I've installed 0.50 and it's now up and running.
Given 0.50 just came out - can anyone recommend a tutorial that isn't too outdated (0.17 I guess)? My plan is to have the changelog open so I can reference it when things don't work, and go from there.
Or have things changed so much that I should just read the unity docs straight away instead?
im quite new to dots aswell and this dude helped alot. https://www.youtube.com/c/TurboMakesGames/videos
since i am new i can not say a lot about changes but my feeling when learning was that i did not stumble across outdated stuff.
Turbo Makes Games is all about helping you make games quickly and effectively.
Game development is tough and it can take a long time to make a great game. But it doesn't have to be that way. Throughout development from pre-production planning to post-launch support there are many ways optimize your processes. Implementing these changes in your ...
@misty wharf thanks for the tip. I'm using this one atm - it's working great for me so far. https://www.youtube.com/channel/UCWERX3S8tEGqNeLuQGCcJmw
Welcome to GameAcademy.school. Here we cover all things about Game Development, focusing on Unity and C#.
Check out the official Web site:
http://gameacademy.school
Many of the videos on this channels are snippets or supplements for our premium courses on Udemy. These links have discount codes included:
https://gameacademy.school/portfolio/
Any one of you got a tip for me ?
My setup is this : I have multiple entities that move dependant on other entities on a graph. So i need to find and reference them inside of my system. Without dots (just with the jobsystem, threads or on main thread) i used a dictionary that maps the entity ids to a graph edge so i can look up where each is on my graph.
In dots i thought that i could use a shared component for this, but inside of the system logic i can only call it by value, not by reference. so if an entity updates its dictionary position the change just happens locally. Do you have an idea how to solve this ? Do i need to use reference types inside of the shared component or is there a good dots specific solution ?
have someone good article/tutorial on unsafe/unmanaged?
I see that many answers talks about pointers and such but I have not work with them for a long time
Did anyone else encounter this problem while updating to Entities 0.50?
(0,0): error Mono.Cecil.ResolutionException: Failed to resolve Tomlyn.Syntax.SyntaxList1<Tomlyn.Syntax.TableSyntaxBase>
I'm interested in this question too. I want to use graphs in dots ^-^
If you want to reference entities, why not just store the entities?
probably best to just find a really good C tutorial to get comfortable with the concept
ugh thanks unity for this extra helpful error
`Microsoft (R) Visual C# Compiler version 3.8.0-dev.20527.1 (53dc6556)
Copyright (C) Microsoft Corporation. All rights reserved.
error SGJE0003: The parameter 'index' of type int will be ignored.`
I've seen that before
in a thread
I knew I had seen it recently
Chances are that you are missing an [EntityInQueryIndex] on an integer parameter to the Execute method of an IJobEntity.
Look at point 6 of "Replace IJobForEach with IJobEntity" in the upgrade guide:
https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/upgrade-guide.html#ijobentity
^ quote from Unity Dev in the thread
yeah that was it thanks
hope they improve the error handling, I almost nuked the library when a few restarts didnt clear it up
All i get is a CRASH.
Im trying to build my game in the "release" mode... the development build works fine ( Platform is android, Unity 2020 lts )
When i build and start my "release" build... it crashes with this nice exception.
Does anyone have an idea what the heck this error means... what it might cause ? I assume its dots related... because thats all i use in my game :/
Using entities 0.50 with the jobs 0.50 and burst 1.7
Stripping is disabled...
Im out of ideas what this shit might cause
how are you building your project? from the build settings?
Yes from the build settings, if you want i can screenshot them real quick, one moment ^^
The player settings will take one more sec
you CANNOT use the build settings to build a DOTS game. you have to create a build configuration asset
Oh... since when ? ๐ฎ
since 0.50 It tells you in the guide
Damn i guess i havent noticed that... that explains that issue ^^
Thanks, im gonna check the guide again real quick
got it working?
Yep it works now, thanks ^^ Damn such a stupid mistake.
I just wonder that it worked in development build without such an build configuration file
development builds are always compiled way differently than release builds
in any software project
That explains it, i wonder if the release version is also faster now ๐ฎ sadly i dont have an inbuild fps widget
it should be. but maybe not super noticible
it definitely won't run worse
It is faster ^^ atleast it feels way smoother now, the movement of my units, the map scrolling, spawning doesnt lag anymore. I guess it also makes full use of burst now ( i assume the dev build did not, atleast it feels like ).
I wonder if the rendering mode set to "multithreading" increases the performance even more
we still build fine without build configuration
you only need it if you have subscenes (or no custom boostrap)
basically same rules as 0.17
and our project is too old for subscenes ๐ข
(but yeah you should definitely use build configurations anyway)
Anyone have any difficulty in creating rigidbodies from code since 0.50? I've already added the PhysicsWorldIndex, cant seem to get anything to actually interact though its supposedly part of the relevant entity queries
I've been instantiating prefab ents without issue
I haven't tried building the full set of physics components by hand tho
Ive just been instantiating and adjusting some
turns out it was my use of adding a PhysicsGravityFactor, though I thought it would just get ignored
for a kinematic body
I dunno, still feels different, having to rework a lot of stuff that "just worked" prior
why i've been advocating for a long time not to create runtime entities
they could completely rework components in a future version
cant avoid it if you want to integrate mecanim(shudder) and entities
basically rewriting my old mecanim with Unity.Physics ragdoll workflow which kinda broke with 0.50. was hoping to ditch it but I guess gotta embrace it
What do you mean
Don't try creating new types of entities at run time?
I fail to see how you can possibly get away with never creating entities at runtime
i never create entities at runtime (except if they have a single component of my own for very specific purposes)
i create entity prefabs via conversion
and instantiate them
so required components are setup via authoring
Ok
I was reading create as instantiate
That's also the method I've been doing
There's too much logic baked into their conversion
yeah sorry create could definitely be a confusing term, just basing it off the name of ecb/em
That's very annoying to replicate
It's much easier to make some Game Objects to convert
Is there a way to "name" a lambda job (Job.WithCode or Entities.ForEach) inside of a system onUpdate? On the burst inspector or the profiler all it says is SystemName.SystemName_LamdaJob_#NUMBER_Job Which really isn't helpful...
Also is there a reason an Entitles.Foreach with ScheduleParallel() is only running on a single job thread?
//Lines is a Native array<int4>
lines.ResizeUninitialized(query.CalculateEntityCount());
lines.Clear();
var localLines = lines.AsParallelWriter();
Entities.WithAll<SharedTeamComponent>()
.ForEach((in Translation translation) =>
{
//Do a bunch of work
localLines.AddNoResize(new int4(eX, eZ, pos.x, pos.y));
})
.ScheduleParallel();
Afaik itโs โWithName(โnameโ)โ @boreal forge
Yes!!! perfect thank you ๐
I can't find any documentation for hybrid components in the 0.50 docs, am I blind?
what are you looking for in particular?
well i should say, hybrid components dont exist in 0.50 outside of internal unity use
Ah ok, I was just wondering if there was a way to query for UnityEngine components without creating a wrapper IComponentData managed component.
In the entity inspector you can see that the UnityEngine components are converted to managed components automatically but it maybe this is purely internal?
Ok, turns out you can access them, its just a little clunky since they are not IComponentData so you need to use EntityQuery a lot and miss out on a bunch of the nice build in query stuff like GetSingleton.
I wonder for DOTS physics when moving a physics body . can I just simple use Translation (inside the "FixedStepSimulationSystemGroup") or is there a different way?
Also is there a way to lock one movement axis, and disable velocity, i.e. to move bodies manually but still to prevent them going through obstacles?
if you use AddComponentObject you can just query them in Entities.ForEach (WithoutBurst and Run of course)
i've got a problem with upgrading some other code. since the animation package is not supported now, how can i store / evaluate an animation curve? i've used AnimationCurveBlob and AnimationCurveEvaluator until now
๐ญ
I have minimal knowledge about c/c++ but I don't know how to apply it in c# environment
syntax is pretty much exactly the same. you just have to put unsafe in a few places
This was my last day at Unity. 3 years and lots of fond memories :)
I will join a small Finnish company called HypeHype. They are developing a mobile game creation platform.
I will be building a brand new high performance Vulkan/Metal renderer for them.
251
(for those who don't know, he was lead of dots hybrid rendering team)
can i create a nativehashmap that holds another native container, like native array?
yes but the inner list has to be unsafe
so, no? it has to be NativeHashMap<int, UnsafeList<Unit>>
where unit is a uhh what do u call it, blittable struct? unmanaged struct
With Entities 0.50 reading from a ComponentDataArray seems to create a dependency problem:
var translations = query.ToComponentDataArray<Translation>(Allocator.TempJob);
I thought using WithReadOnly(translations)would be the right way to declare reading dependency for automatic dependency management. If thats not the case how do I declare the read dependency on translations?
@dull copper hmm good for him to move on to what he wants to do but a bit worrying the lead of the still in progress hybrid renderer is leaving
for the most part you just don't
it's mostly useful for interfacing with unmanaged code where everything is going through a C FFI
in an unsafe {} block you can pretty much do any pointer nonsense you'd want to
Interestingly changing the ToComponentDataArray to be Async and manually adding the dependency of this call fixes the dependency problem. This can not be the only option though can it? ๐ค
I have switched to using RenderMeshDescriptions with URP/Hybrid renderer and I am using "Universal Render Pipeline/Unlit" shader since that is the only shader that I can get to run without SRP batcher errors popping up. I have everything rendering, but it appears as if its not recognizing Alpha at all. Like every single texture has streaks of color where it should be transparent. Anyone able to point me in the right direction? *This is 2D btw
@safe lintel https://forum.unity.com/threads/released-nimgui-a-1-draw-call-immediate-mode-gui-for-unity.1171601/#post-8006861 I released my asset for a 1 drawcall ui with Entities ๐ฅณ
Does it work with VR?
no I haven't had the time to tune the shader to work with VR
okay, fair enough ๐
I can probably put in my task queue
I love me a one draw call thing
nah, don't worry about it. VR seems to be dying slowly anyways.
@haughty rampart yeah saw that earlier, still doesnt clear up the issue of can it be released as experimental ๐
btw, with 1.0 it is actually possible to hold native containers inside other native containers since unity will get rid of dispose sentinel. but they said that it won't be allowed to schedule a job that has nested native containers. (hopefully that's temporary though)
there's a post that states that they will release experimental packages of animation, etc... after entities 1.0 before a 1.0 release of the respective packages. but still.....no more experimental packages before 1.0
i've got an issue with 0.50 currently. some code of mine throws 'object reference not set to an instance of an object' errors from a burst job. the problem is, if i disable burst compilation (to get stacktraces) it does not throw any errors at all. any idea how to debug this?
can you comment it out line by line to find the offending statement? though dont think ive encountered that
When that happened for me i pretty much just disabled systems until I nailed down the system that was handling it - it wasn't the most efficient. ๐ค
i only have one system, but i can't really comment out line by line because most lines are dependent on the line just before it
and it's also strange. when enabling synchronous compilation it does not throw an error either
but i'll see what i can do
still not very familiar with hybrid renderer, but I imagine the shader is an unlit transparent shader right?
Well its the default URP/Unlit that I was able to get to build without error, I assume I need a sprite shader for this to work, but none of them are compatible. I found a forum post that kind of mentions what to do from a unity team member. You need a subshader with #pragma target 4.5 The subshader needs to use #pragma multi_compile _ DOTS_INSTANCING_ON The shader needs to specify DOTS instanced property definitions for any properties that will be read from entity data, e.g. transform matrices. This is typically done by #including some shared headers. You can look at the example shader in the Hybrid Renderer package for a simple example, or URP/Lit and URP/Unlit for a full fledged example. I absolutely have no clue how to work with shaders so I guess its time to get my hands dirty and waste a week
Actually not sure its worth it though, may just go back to manually rendering with Graphics.Drawmesh
from the post it sounds like adding in #pragma multi_compile _DOTS_INSTANCING_ON as a define in the .shader file. I haven't looked into exactly what DOTS_INSTANCING_ON requires for it to work properly but I imagine the URP shader source would have a struct that defines the data needed for everything to render
I was able to sort it out by pre-creating a dummy material with the default unlit shader and switching from "Opaque" to "Transparent", then copying that instead of creating one in code. I am not sure how to tap into that property from code, so thats the solution for now.
is there some way for me to get all buffers of a specific type
and do stuff on them in parallel
nvm
disable safety is my friend
Is it possible to use hybrid render V1 in ecs 0.50 version?
I think only V2 now
And ECS 0.50 obligatorily require Hybrid render 0.50 too?
you can only use the new 0.50 renderer which means no old rendering only SRPs
btw tertle did you ever figure out a permanent solution to UIDocument or are we still "re-importing" every time?
reimporting atm
i'm actually testing if i can run entities on 2021 atm with some modifications
2022 works fine if you don't use hybrid renderer
(with Extrys modifications)
but 2022 has some giant graphic changes so that's expected
2021 doesn't have these changes so i think i'll be able to get that to run but we'll see
testing right atm
dots
it is very sad because we use Augmented Reality and as I know hybrid render v2 requare vulkan and it's not supported by AR
nope no luck, 2021 hasn't backported the new jobsutility api from 2022 yet
so you can run entities on 2020.3.30+ or 2022 beta but not 2021
but you can only run hybrid rendering on 2020.3.30+
I am stumped on what RenderMeshDescriptons "LayerMask" and "Layer" actually do at this moment. Have they not been implemented yet or is it a feature that doesn't work on 2d?
Back to using Z for depth
@rotund token you mentioned a short while ago you serialize everything to one nativearray, could you explain a little more how that works? trying to visualize this but Im failing
for saving?
yeah
can't share too much code because it was written for work, but basically each type of entity we want to save has it's own container type
where T : unmanaged, ISave<T> {
Entity GetEntity();
void Serialize(StreamWriter writer);
void Deserialize(ref StreamReader reader);
}```
where StreamWriter just writes to a NativeList<byte>
these lists are then just combined together into a single nativearray
and written to disk
how do all the different container types fit into the one nativearray though?
thats the part that confuses me
var (result, count) = save.Value;
var meta = new SaveMeta {
SaveType = save.Key,
SaveVersion = _saveSystems[save.Key].LatestVersion,
SaveCount = count.Value,
SaveLength = result.Length,
};
saveFile.AddRange(&meta, UnsafeUtility.SizeOf<SaveMeta>());
saveFile.AddRange(result.GetUnsafeReadOnlyPtr(), result.Length);
result.Dispose();
count.Dispose();
}```
where saving is just NativeList<byte> data and NativeReference<int> count
write a tiny amount of meta data about each chunk of memory, then write the data
save version is important so when we can deserialize we can migrate to new formats/etc when we add new stuff in future
but this is versioned per entity type
appreciate it, thanks. some new concepts I guess I gotta process ๐ง
i think saving has always been a troubling problem for game dev
that is really not discussed nearly enough
yeah, i was disappointed serializeworld being made internal/ streambinarywriter. would have traded inflexibility for ease of use and not have to muck about with yet another thing to work on
the problem is you can't really use serializeworld for saving
unless you never want to update your game
you change 1 component in the future and all existing saves break
we tried this for a year+
writing auto migration with mock components etc and all sorts of memory hacks
it was a complete nightmare to maintain
while it took me a month to rewrite our saving it was definitely worth the time
it's saved so much time since and is very easy to maintain
is there a faster way to convert a regular Transform array to a Transformaccessarray (unity dots) than looping trough each element.
edit: well I can just use the constructor for it... I am so stupid.....
= new TransformAccessArray(RegularArray[])
like a memcopy or something like that
definitely not a memcpy
but you can cache the transformaccessors
I currently have a prepared (serialized) Transform array that then gets copied at the start of the game into a transformaccessarray and never disposed (because the game works like that)
does anyone know the fastest way to process entities for all values of a shared component filter?
I'm currently doing a regular foreach over the all unique shared component data
and dispatching a job for each of them
Are the shared compontents added dynamicly and change a lot during the game?
I'm wondering if something like a parallelfor would be better
they'll get created and destroyed with some frequency
but once one gets created it's value never changes
I have like a precalculated array that holds all possible shared stuff (hashset then converted to array) and all the entities and gameobjects get is the index of the array, in a Byte.
Maybe you could do something like that too?
So instead of iterrating over get component you can then iterate over the Byte, ushort or int number (or numbers if they have multiple).
how to solve this issue? what s causing this problem. character is falling down on its own. iam using dots entities 0.50. i am using dynamic physicsbody. also how can i find out if the player is grounded. code snippet will be helpful.
Does new instanced RenderMesh component save reference to same parent mesh after instantiating from Prefab Entity ?
As far as i know the RenderMesh component holds the data for the mesh, i.e the mesh and no the reference to the mesh renderer. if you use convert and inject gameobject the entity will also hold the reference to the mesh render along with a render mesh.
Seems like the behaviour of ConvertGameObjectHierarchy changed with Entities 0.50. Converting a prefab pollutes the active scene with its Companion gameobjects. Instantiating these prefab entities does not but the ComponentObjects (VFX in this case) are only visible in Game view? ๐ค Anybody also encountered/resolved this? Conversion in subscenes works as expected. I guess it has sth to do with conversion flags
A common way to do isGrounded is just a simple raycast down from say the hip position, with ray length just longer than the distance to the feet, and if it returns a hit for your ground mask layer then golden.
Regards the character tipping over, with normal unity physics you'd typically lock the axis right, not sure if there's a constraint for Unity.Physics or a field inside the rigidbody component which does the same.
tbh not sure if that utility will be around in 1.0
Thing is there is still no alternative for loading prefabs. Would be great to convert them during edit time like scenes but it does not seem possible
do you mean prefabs that contain hybrid components?
Yes I have a custom tile map format that gets populated with entities from prefabs
I also found that the same VFX game objects will be created when pressing play while a subscene is in edit mode
Not sure if this is intended
This video covers the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It also addresses a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with...
unlisted, how did you find it?