#archived-dots

1 messages ยท Page 190 of 1

slim nebula
slim nebula
#

what animation package/classes should I be using with dots/ecs?

#

DOTSSample seems to have this "Animation" package, but it's not listed to download in my 2020 unity

#

not sure why this isn't listed in my package manager...

#

I seem to have a com.unity.animation@0.2.16-preview.5 folder...

#

I dunno what im doin ยฏ_(ใƒ„)_/ยฏ

#

halp

#

ok so "Animation" is pinned but... I dunno why I dont' seee it in my package manager

#

AHA show dependencies

#

nope that didn't do it

#

that's dumb

#

I don't think the github exists anymore?

#

I dunno how to get this package ๐Ÿ˜ฆ

deft stump
#

@slim nebula yeah most experimental packages are really hidden and can only be added via pm.
just open pm > add pacage from git url > paste in com.unity.animation.

#

here's the full list of stuff that is now hidden from pm

slim nebula
#

oh

deft stump
slim nebula
#

that's a git url ok

#

thanks

stiff skiff
#

Whats the chances of that entities.17 to be released this year?

gusty comet
#

Lighting appears to flicker on/off randomly. Does this in game, in scene, and in builds

slim nebula
#

just add a seizure warning to your game startup (cyberpunk meme, sorry I couldn't resist)

#

is there any way to obtain the old package versions required by DOTSSample?

#

it seems to download the package source files as random junk (xml, binary data, anything but source)

gusty comet
#

So I take it this is not happening in your 2020.2? (assuming you're using that version)

slim nebula
#

no sorry that was a new question, not in relation to yours sorry

#

I'm not quite far enough to be doing lighting and stuff sorry

gusty comet
#

NP - I posted it on the answerhub - I am not seeing any record of this happening to anyone else so it may just be my hardware. Especially consdiering its happening in .2 but not .1

slim nebula
#

hmm I might try this answer hub

gusty comet
#

yea

slim nebula
#

๐Ÿคž

#

whoa 154 people are following my question already!

gusty comet
#

I imagine some people just have certain categories set to automatically follow so they get notifications when they're posted

gusty comet
#

Is there a list somewhere that shows which gameobject components are compatible with convert to entity?

deft stump
#

@slim nebula yo, I'm getting the same warnings as you on Unity not disposing stuff

slim nebula
#

ye

#

just uh

#

ur frames are too fast

#

add more work, and the jobs can finish within 4 frames

deft stump
#

it's internal

#

unity is doing it. not me

slim nebula
#

it's not a "real" problem. yeah

#

like it makes a job, then 5-10 frames go by cause ur not doin any work. your fps is prolly 400+

#

I limited mine to 240 FPS and it fixed it

deft stump
#

i'm on 80

#

It's 80 fps for christs sake

slim nebula
#

hmm I donno then

#
using System;
using System.Threading;
using Unity.Entities;
using UnityEngine;

class TargetFramerateSystem : ComponentSystem
{
    /// <summary>
    /// Singleton component to initiate the connection after initial startup systems are created
    /// </summary>
    private struct InitGameComponent : IComponentData { }

    /// <summary>
    /// Called when the system is created
    /// </summary>
    protected override void OnCreate()
    {
        // Create singleton
        EntityManager.CreateEntity(typeof(InitGameComponent));

        // Require singleton for update so system only runs once
        RequireSingletonForUpdate<InitGameComponent>();
    }

    /// <summary>
    /// Called every frame
    /// </summary>
    protected override void OnUpdate()
    {
        //// Destroy singleton to prevent system from running again, since this system was created with RequireSingletonForUpdate above.
        EntityManager.DestroyEntity(GetSingletonEntity<InitGameComponent>());

        Application.targetFrameRate = 240;
    }
}
#

I just added this and it's fixed for me

#

I dunno

#

it's a well of despair problem

#

u get like a bunch of frames quick

#

then it stalls

#

then more frames quick

#

repeat

#

need to reduce that fps spike I think and it should fix

#

for the internal stuff at least

deft stump
#

I think it happens when I switch between scenes

slim nebula
#

ah, if it's just a couple then it's fine

#

mine were happening like constantly. causing GC spikes from the log messages

#

a few jobs takin a bit longer isn't the end of the world

#

it's only a problem if it's happening regularly

#

as it affects performance at the time it happens

deft stump
#

well it did stop after 72 warnings

#

:lul:

slim nebula
#

72 lol

#

๐Ÿ˜ฆ

coarse turtle
#

Looks like you just need to add the skinning node to your HDRP shader?

#

iirc that's how the Basic_Vertex_Skinning shader graph looks like

#

you just need to copy it and add basic albedo/color properties

dull copper
#

@slim nebula are you using dots?

slim nebula
#

yes

#

I switched to the render graph and found a hdrp lit graph on github

dull copper
#

well, you could tell that in the forum post

slim nebula
#

seems to work

#

the shader doesn't support it out of the box. need to make a graph to support vertex animation. I didn't know that

#

I guess I could reply and say it's solved

#

thanks

sand bronze
#

@deft stump (I love your name)

fair stirrup
#

I've just started with DOTS, Jobs and looking at meshing examples. From what i understand is i can't use burst with using shared mesh data RenderMesh. Does that mean i effectively need two systems in ECS to do meshing?

#

I'm looking to burst the vertex calcs then combine them into a mesh but i don't see how this could be eaily done using ECS (SystemBase)?

zenith wyvern
#

You don't necessarily need two systems. You can process your mesh data (native arrays or MeshDataArray) inside a bursted job. You assign that job to a jobhandle and check jobHandle.isComplete every frame. Once it's complete you then copy your mesh data into the mesh in a main thread non-bursted job

fair stirrup
#

@zenith wyvern This sounds like a job not part of the Component System? (SystemBase)

zenith wyvern
#

Both jobs can run in the same system. If you want your mesh processed and updated in the same frame then yeah you would want two systems, probably one that runs in InitGroup and one that runs in PresentationGroup

fair stirrup
#

All job examples I've seen exist outside of Systems.

#

I think this is why I'm getting confused.

fair stirrup
zenith wyvern
fair stirrup
#

Ah your right 16 is the latest x.x

#

@zenith wyvern Up to this point i've been watching old YT videos to get started obviously lots have been quickly outdated.

#

Don't think I've seen a single one mention System attributes lol. But this gets me on the right track.

slim nebula
#

everything has such similar names... is "Animator Controller" part of com.unity.animation?

slim nebula
#

oh wow. kinematica looks awesome

#

hopefully the package versions required by the demo are still downloadable from the package manager...

fair stirrup
#

@zenith wyvern verticesList is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing, attempting to use NativeList (to process mesh data). I can't seem to find a reason why this doesn't work vs a native array?

#

NativeList<float3> verticesList = new NativeList<float3>(Allocator.TempJob);

slim nebula
#

I think a list is meant more for dynamic purposes. since it can be resized, any job accessing it could be a race condition

spark glade
#

Having a couple crashes on Android, so I decided to build a release build with force debug information enabled. Now I'm seeing a bunch of:
```The method Void _mono_to_burst_Hash64Long(Byte*, Byte*, Int64, Byte*, UInt64 ByRef) must have MonoPInvokeCallback attribute to be compatible with IL2CPP!
Unity.Burst.BurstCompiler:Compile(T, Boolean)
Unity.Collections.xxHash3:.cctor()
Unity.Physics.Authoring.HashUtility:Initialize()
Unity.Entities.ComponentSystemBase:CreateInstance(World)
Unity.Entities.World:AddSystem_OnCreate_Internal(ComponentSystemBase)
Unity.Entities.World:CreateSystemInternal(Type)
Unity.Entities.GameObjectConversionUtility:AddSystemAndLogException(World, ComponentSystemGroup, Type)
Unity.Entities.GameObjectConversionUtility:AddConversionSystems(World, IEnumerable`1, Boolean)
Unity.Entities.GameObjectConversionUtility:CreateConversionWorld(GameObjectConversionSettings)
Unity.Entities.ConvertToEntitySystem:Convert()
Unity.Entities.ComponentSystem:Update()
Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
Unity.Entities.ComponentSystem:Update()
UnityEngine.LowLevel.UpdateFunction:Invoke()

#

(Burst 1.4.3 physics 0.5.1-preview.2)

#

The bug with no debug information just happens after like 10 minutes of gameplay and not "on start" like this error ๐Ÿค”

#

Anyone spontaneously knows what's causing this?

gusty comet
#

How is this valid syntax?

Obviously float float; is not valid, why is this?

#

[ReadOnly] public PhysicsWorld PhysicsWorld;

coarse turtle
#

PhysicsWorld is not a C# keyword

#

generally, you can't use C# keywords as variable names

#
float @float; <- this would be valid tho
zenith wyvern
#

@zenith wyvern verticesList is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing, attempting to use NativeList (to process mesh data). I can't seem to find a reason why this doesn't work vs a native array?
@fair stirrup

I would need more context to see what's going wrong. It looks like you're trying to write to a nativlist in a multithreaded job. You'd need to use ParallelWriter for that

#

For IJobParallelFor you need to use NativeDisablePatallelSafetyRestrictions to disable parallel safety checks on the container if you're writing outside the given index - as long as you're sure you're not overlapping indices

sleek chasm
#

anyone know a good NetCode tutorial?

deft stump
#

DOTS netcode? I believe tutorial on those are sparse

#

the pain of early tech

sleek chasm
#

I'm starting to make a youtube series where i literally just look at the github repo on examples and read documentation and talk about it

#

Feel like no one knows what's going on with NetCode and I'm not exception

deft stump
#

okay

#

is this a bug?

#

a ijobparallel for takes 0.21ms to finish it's job

#

but the wait takes 5.46

dull copper
#

look at the collision modules on top (right under the part you highlighted on red)

#

it's basically waiting for those

deft stump
#

so it also waits for internal jobs to complete

lost umbra
#

Is there a way to constrain rotation in Unity.Physics? seems that if I convert a game object to an entity it ignores Rigidbody constraint / Rotation Conostraint GO components

odd cipher
#

@lost umbra the working but somewhat cheaty thing I do to do that is just set the entities rotation to zero every update. Though that constrains all rotation

north bay
deft stump
#

so not only we don't have enable/disable but 0.17 has been pushed back.

cruel 2020

#

:pepehands:

olive kite
#

When an entity is created by command buffer in a system job, does it return a value of -1 when following in debug mode? I am getting an "Entity does not exist in command buffer" error, but since it is created later when the command buffer completes then it would make sense to me that it isn't created yet. https://i.gyazo.com/262f9c158ae3b861f4f2d93731bd32b1.gif

amber flicker
#

ecb instantiate returns a temporary entity id which is negative - they then later get remapped - it returns a temp id so you can do more manipulation of that entity with the same ecb.

olive kite
#

ok thanks

#

Is there a way to run a system after the -end fixed step simulation entity command buffer system- in the fixed step simulation system? I have a system that removes entities at the end of the fixed simulation group and that is the only place I destroy entities but still getting entities do not exist errors from command buffer

olive kite
#

oh duh, latesimulation group update is fixed too

#

I really like how it is split between simulation and presentation

stiff skiff
#

And their "secret" DOTS slack channel doesn't count

stone osprey
#

So im having another architectural dots issue... this time a combat system... my game is some sort of top down point and click game. The player/mob is its own entity with components... and the items aswell. Therefore i have a player entity which has a inventory component where i reference a equiped item-entity. My biggest problem here is to come along a good "damage dealer" system. The item entity ( weapon ) should be used for getting the attack speed and damage... but the player entity itself gets marked for executing an attack... my biggest flaw here is that the weapon and the player are two entities, not one. Any ideas or tipps for a flexible system that throws damage events ? It should be flexible enough to either take the damage from a referenced entity or from the entity itself ( Player's weapon, Area that damages ... ). Kinda stuck here because i cant find any good sources on how other games implement this :/ So im glad for any help

deft stump
#

@stone osprey
maybe have another system that sits in between the player and the weapon.

when the player recieves / reads that it's time to attack.
it sends it to the weapon (through the system I mentioned),
and do magic or whatever

north bay
amber flicker
#

What communication? ๐Ÿ˜…

stone osprey
#

@deft stump Thanks ! Thats a good idea ๐Ÿ™‚ Even if its some extra work... Probably this is also a good use for events, like "player_attack" and then the weapon looks if its equiped and sends the damage event

#

Thats the only flaw so far in an ecs... relations between entities

amber flicker
#

It can be a bit verbose.. and removing rand access from hot paths can be a challenge but generally, CDFE/GetComponent etc works pretty well I find. My sense is you're maybe working on a system that is more complicated than intuition may lead you to believe. Having fire on the ground that does damage over time, that is maybe done by a member of your party but doesn't injure you (even though it wasn't caused by you) that will transform when an area ice spell is cast over it, with poison also there doing damage over time and then someone using a reflect spell... I'm obviously taking this to a bit of an extreme but just wanted to make the point that this comes up a lot and I think its useful to add constraints where possible and not build a system from the get go to do everything.

#

i.e. maybe there isn't such a thing as environmental damage or else its handled separately. Perhaps a weapon only changes your characters single 'attack' modifier and that's it. Not necessarily what you want, just some thoughts.

stone osprey
#

Thanks ! Probably im just to scared of having too much systems... I currently have over 70 different Entities.ForEach loops for different compositions... Most of them are running event based :/

amber flicker
#

I'm inherently generally wary of an event based approach in ecs.. it feels quite object-oriented to me.

low tangle
#

Theres no reason to avoid something because it's like oop. But you should be weary of using the same hammer everywhere. You might be making things more complex and harder on yourself

#

Don't be afraid of lots of systems, condense when you can later on. Systems and the foreach in them are the encoding of the logic in your game. That complexity had to be somewhere for it to behave how you want. One of the pluses of ecs is the fact it's all easy to find and manage where it is. On the other hand ecs does make some things take more lines to do, but I personally find the complexity per line way way lower, so in the end it has been helpful in core areas of the code.

vagrant surge
#

i would recomend the revese, were you start with fat systems and split them once it makes sense

#

using the ECS as event system actually works pretty damn nicely. Its one of my favourite patterns to use

#

the main fun stuff with ecs events is that you can do absolutely ridiculous stuff, like if the target entity has "deflect" component, then you swap source with target in the event

deft stump
#

fat systems and split them once it makes sense
do it also with components too. splitting them up is far better than making a monolithic one

vagrant surge
#

the problem is just how tied it is to system order, and that it creates far too many sync points

#

something ive done is that the event ecs is on a different "ecs world"

#

and the event systems are also their own "event loop", separated from the simulated loop

amber flicker
#

Yea to be clear, I'm not at all of the mind "events are bad". I think maybe one common friction point is related to recursion - how it's quite natural with events to have one thing trigger another which triggers another etc. Without events it's something like running systems multiple times. One area of event usage I feel that can get pretty messy.

pulsar jay
#

To chime in on the discussion: How would you guys handle an "event" like an enemy died. There would be some system that decreases health and checks if it dropped below zero. What then. How trigger a die SFX, VFX, die animation (increase kill count) and finally get rid of the entities representing the enemy?

gleaming plank
#

Can the weapon entity just have a component that points back to the player who owns it?

pulsar jay
#

@gleaming plank yeah you could reference the player entity. You just need an Entity field for that

gleaming plank
# pulsar jay To chime in on the discussion: How would you guys handle an "event" like an enem...

One way I could imagine doing this:
Entities have a DynamicBuffer<ModifyHealth>, where each ModifyHealth element is +(heal) or -(damage).
Have one system process this buffer and apply the overall change to health at once.
If the entities hit or drop below 0, tag them as "Dead" with an empty component.
Then you can just process those entities and trigger all the death animations and cleanup.

amber flicker
#

@pulsar jay Couple of other options (there are many I guess) - the enemy entity could have an ISystemStateComponentData - the SFX/VFX systems could look for any enemies that still have that tag and then respond. The System that kills the enemy could have a 'PlaySFX' tag that fires based on an enum (born, killed, hit, whatever) that has a reference to a sound (or id into sound db).

pulsar jay
north bay
pulsar jay
gleaming plank
#

idk an exact code example off the top of my head, but once you've isolated the entities that are dead, shouldn't it be simple to do stuff with them?

north bay
#

I just tag my entities with a BelowZeroHealth component and let everyone that needs to do processing on them do that. (spawning ragdolls, counting kills etc)

amber flicker
pulsar jay
amber flicker
pulsar jay
gleaming plank
#

I don't like to think about systems as event-based. Systems process entities that have (and or don't have) certain components.

You can run systems as soon as the components are ready. Systems that handle entities with some kind of "BelowZeroHealth" component should follow the dependency chain and run after all systems that add it.

#

"Responsibility" feels like an OOP concept.

elder bluff
#

I am kind of unsure of why this is happening

#

wait

#

nvm

#

I had a problem but I found it by scrolling down once lol

pulsar jay
amber flicker
#

why would systems trigger multiple times? Unless mixing fixed + update?

#

nonsense psuedocode:KillSystem() { DestroyAllEntitiesWith(DeadTag); // This happens a frame after the below AddDeadTagToHealthlessEntities(deadedQuery); }

pulsar jay
#

if you add a "BelowZeroHealth" and no system removes it

#

just said some system has to be "responsible" to remove it

gleaming plank
#

sure, you'd need a system to do that

coarse turtle
#

Well you add a system that runs last to remove it, everything else that needs to process that tag + entity can run earlier

gleaming plank
#

^

amber flicker
#

With the above example, it doesn't matter where you put that system - just a sensible place for a sync point.

#

or as psuong says, you can have a system that does the actual deletion of entities as e.g. the last system that runs in a frame (the implication being every system that wants to know about Dead entities is between the system that adds the tag and the end of frame)

low tangle
#

I highly prefer the system that had evaluated the condition to do the work in absolute entirety right then

#

Or to trigger a event (full blown entity if desired) to then cause it to happen

#

Deferring or splitting the action into multiple descrete steps when not needed is how I usually run into unneeded complexity.

#

Kinda like procrastinating in the logic

agile dome
#

Multiple discrete steps does feel like the ECS way though

low tangle
#

Don't overdo is all I'm saying

#

Do more per each system

#

When I was starting out I had a tendency to really really fracture things out

agile dome
#

Oh I see

low tangle
#

I'm not talking about absolute ways of working with ecs, your gonna have to learn where you can move the balance

#

That comes from actually hands on learning how to solve these questions you have

#

Not just being handled the best solution (there's always assumptions about the problem domain)

gleaming plank
#

The Overwatch GDC talk has a good examples on when deferring or dividing work into multiple systems is useful to reduce complexity.

low tangle
#

And I can confirm they do as well. But make sure the problem of actually that complex

pulsar jay
low tangle
#

Their ecs works slightly different then uecs

gleaming plank
pulsar jay
#

thx

olive kite
#

What's a good way to store or get a reference to a specific child entity after conversion?

#

or is the most efficient way to store during conversion

vagrant surge
#

important detail on overwatch ECS. Their system doesnt work well with many systems and many components, so they just have relatively "big" systems and components

#

you can see they basically have 1-2 systems for all rendering

#

they use ecs more for the architectural pattern than for perf or similar

olive kite
#

yeah, I was wondering if that was actually all of their systems or just a subset to show the example. Because he talks about having the RESOLVE_CONTACT component but I don't remember seeing it on the chart

low tangle
#

things like this makes me think there running at a big higher level of abstraction, not breaking it down as much as UECS

#

I mean, you can totally have character controller components just fine, but I hope you understand what I mean when I say thats more of a oop thing

median glen
#

is it worth it to use dots in my project with no prior knowledge of dots?

zenith wyvern
#

It's not something you can easily integrate without experience. Go through examples, read the docs, then decide

#

Well, ECS is not easy to integrate. Jobs on the other hand, you should be able to get performance boosts from bursted jobs in performance critical areas without too much trouble.

bold basin
#

How would I move an object in the direction it is facing?

#

I'm making a 2d bullet hell demo and I want all bullets to move in the direction they are facing according to their velocity

#

I can't figure out the quaternions in mathematics, so I have no clue what to do in my system

zenith wyvern
#

You can get their direction from localToWorld.Forward

bold basin
#

What component holds that?

zenith wyvern
#

LocalToWorld

bold basin
#

Thanks

bold basin
#

So all of the projectiles are disappearing too soon (they stop rendering before they are fully offscreen)

#

how do I fix this?

#

Example screenshot

#

the purple things are shot in a perfect circle

#

but there are noticable gaps at the edges

#

wait

#

I think I know whats going on

#

Nope

#

OK I don't know what's going on now

#

I have no logic that deletes them and they show up in scene view

zenith wyvern
#

Plenty of things it could be. Are you spawning them based off deltatime? If so it's unstable so you could see gaps like that in that case

bold basin
#

The gaps don't form naturally, they suddenly appear when the things start dissappearing

zenith wyvern
#

When you say they show up in the scene view, you mean there are no gaps in the scene view?

bold basin
#

Yeah

#

I can see them disappear before they go fully offscreen

zenith wyvern
#

How are you rendering? Hybrid renderer?

bold basin
#

Yes

#

These are my components

#

bulletcomponent stores an unused enum and a velocity

#

They are also scaled to 0.5

zenith wyvern
#

Did you update renderbounds to match the scale change?

bold basin
#

How do I do that?

#

would it be a system?

zenith wyvern
#

The expected workflow for this would be to make your bullets a prefab. Like a gameobject prefab. Then you can use the conversion system to convert it into an entity prefab, and you can instantiate that instead of using an archetype you build in code. I only mention that because it takes care of things like that - if you set the scale of the gameobject the conversion system will generally set up all the relevant data for you so you don't need to do it manually

bold basin
#

So when it spawns copies, it spawns them as entities directly and not as objects which it then converts?

zenith wyvern
#

Otherwise you need to call SetComponent<RenderBounds> and set the proper size

#

It spawns them directly as entities, yeah

#

The converison system just creates a canonical prefab you can spawn from

bold basin
#

Oh that's awesome

#

that sounds like a lot less pain

zenith wyvern
#

It is awesome, unfortunately annoying to set up right now

bold basin
#

wouldn't I just need to put the GenerateAuthoringComponent attribute on my components?

#

Or are there other steps

#

oh right I don't actually know how to convert it

zenith wyvern
#

Yeah, you would set up your authoring scripts on your bullet like you would with a normal entity, then change that gameobject with the scripts on it into a prefab. You then use a second entity to reference your converted entity, then query for that second entity any time you want to spawn the prefab

#

Like I said, annoying right now

#

Basically you want to do what they're doing here

#

A smoother process is in the works supposedly, but as far as I know this is how we're meant to handle prefabs right now

bold basin
#

Hmm alright

#

I'm using this for a bullet hell type of game, but I'm planning on only using ECS for the bullets since it seems like more work than it's worth atm for anything else as the performance won't be noticable

zenith wyvern
#

If you don't want to bother with all that you could just set up the prefab yourself in code, than call Instantiate on that

bold basin
#

By set it up yourself do you mean like manually add all the components like I was doing?

zenith wyvern
#

Yeah, but as mentioned make sure to set the renderbounds manually - and I still don't even know if that's for sure the problem, hahah

bold basin
#

yeah it's scaled down so idk why it would dissappear before it goes off screen

#

Oh also is there better way to do rendering with sprites? Or is it just quads

zenith wyvern
#

Are you sure they're not leaving the game camera's frustum?

bold basin
#

the what

#

they are still visible on screen is all I can say

zenith wyvern
#

When you have the camera selected in the hierarchy the frustum is the shape it shows where everything gets rendered

#

You should verify in the 3d scene view that all your sprites are still inside that shape when they disappear

bold basin
#

Unity crashed when I tried that lmao

zenith wyvern
#

If it continues to break on you I would honestly say just use regular sprites. I doubt you'll see much difference in performance since most of the "work" should be happening in your movement system

bold basin
#

Wait so

#

hm

#

would that make them gameobjects again?

zenith wyvern
#

Just the rendering part. If you convert a sprite I believe it will create a hybrid component so the sprite is "attached" to the entity and moves with it. You can still write to entity components but the rendering is done via sprite renderers - which are still very efficient

bold basin
#

I guess?

#

I'm not sure about the stats lmao

#

Would it add any extra work to instantiating them?

#

I used object pooling in my last game and it caused a bunch of issues

zenith wyvern
#

I guess in your case it would since you're not actually using prefabs...

bold basin
#

also these are the ones that are dissappearing ingame

#

seems like the renderer picks a point in the middle of the quad

#

for some reason

zenith wyvern
#

Yeah it looks like me like the render shape is incorrect then

bold basin
#

Alrighty well I'll do more work on this tomorrow

zenith wyvern
#

RenderBounds I mean

bold basin
#

but thanks for your help

zenith wyvern
#

Set that to the proper rect and see if it helps

#

No worries

bold basin
#

how would I do that with an AABB?

zenith wyvern
#
        EntityManager.SetComponentData(e, new RenderBounds
        {
            Value = new AABB { 
                Center = whatever,
                Extents = whaever
            }
        });
bold basin
#

I mean like what do I put for the center

#

I might just use sprites

zenith wyvern
#

Center and extents are both generally half the size, in world units

frosty siren
#

I'm in case when i have converter (IConvertGameObjectToEntity mono) that creates additional entities which are linked to converted entity.
I want to make this entity as prefab. To do this i use ConversionSystem.GetPrimaryEntity() which is super easy. So converted entity has Prefab component which exclude this entity from any query.
But even with prefab conversion created additional entities has no Prefab component which is expectedly.
Can i somehow get primary entity hierarchy? Of course i can create additional entity only when entity actualy exists (not prefab). But maybe there is some useful tools

hybrid wadi
shrewd lion
#

Hi! Is there any conensus on how to do an inventory system where items can have complex functionality (regular uses, weapons, consumables, throwable grenades, etc.) in DOTS?

#

a quick ctrl + f in this sub for dots shows no mentions for "invento" so I don't think it has been discussed here

#

So for a typical inventory system where you have a base item class, something like a weapon or potion class that inherits from that, and then a script for each item, how would you approach this in ECS?

#

After reading on DOTS personally, I think there is simply no way to do this other than making everything that would have been a field in OOP (such as healthRecoverAmount) a component

#

So instead of Bandaid : MedicalItems : BaseItem, you have like Item with that component

#

Instead of Shotgun : Weapon : BaseItem, you got something with a ton of components, etc.

coarse turtle
#

You can try to treat an inventory like a database

#

You're storing records of information, so a player can have a collection of Item IDs

#

and each item ID can be mapped to a specific table

#

or each item can refer to multiple tables

#

I do an approach like that with cards - which you can treat as my inventory.

#

So unlike OOP you can compose different records from tables instead of inheritance

shrewd lion
#

So, if I understand, a player does not store an entity, it stores ids for whichever entity might exist?

coarse turtle
#

Well you can store an Entity if you choose to - depends on implementation and your design

#

I just chose not to store an entity and just used an ID for my needs

shrewd lion
#

I'm really new to this DOTS approach so sorry if I'm being slow, but you're suggesting for each Item, you compose it out of many different things, instead of inheriting them from a parent right?

#

The issue with simply using ids that refer to templates is that you might want to change some values, such as having a weapon that can get damaged/worn out

#

Yet, if I'm understanding DOTS correctly, there is no weapon. There is simply an entity that contains an item component, a worn component, a damage component, etc.

coarse turtle
#

Well that's why I said it depends largely on your design, since my example was for my own needs.

Let's call your feature "Maintenance" and we have a Weapon Entity. Your weapon Entity can be associated with a Maintenance component that stores a float. For simplicity, let's say you store entities in your inventory. Because you store entities in your inventory, you can access the "Maintenance" struct and update the float value.

Your float values can be:

  • 100 - fully maintained
  • 50 - worn out
  • 0 - destroyed

Depending on the float value you assign to the Maintenance struct can tell you the state of your weapon effectively

coarse turtle
shrewd lion
#

What I thought you meant was that you had a database of immutable things like cards and your inventory merely stores IDs that refer to those things you can use

coarse turtle
#

Ah - yea you dont have to design it to be immutable

shrewd lion
#

But what you said lines up with what I took from reading about DOTS, I won't have Shotgun : Weapon : BaseItem, I won't have Bandage : MedicalItem : BaseItem, I merely have an entity, and that entity has components in it.

coarse turtle
#

Yep

shrewd lion
#

I shouldn't care or even know high level concepts about whether something is a weapon or not. Something in DOTS is, what it's made out of

#

Is that it?

coarse turtle
#

Like if an entity is a weapon?

shrewd lion
#

Yes, what I take from this is that in DOTS entities aren't really concepts like Boat, entities exist, and are composed of things like "ItemMaterial" and "Buoyancy". Whether that is a Boat or not doesn't really make sense like in OOP

#

Or maybe I just don't get it, which is more likely

coarse turtle
#

Yea that's correct

#

Yeah I just had to ask that question to make sure I wasn't misunderstanding your statement

#

but yes - you're right about that. The idea is - the composition of data describes the entity, the entity itself doesn't describe what it is on a higher level (since by default entities is just another form of an ID)

odd cipher
#

How would I check if a dynamic buffer contains something?

shrewd lion
coarse turtle
odd cipher
#

NativeArray does not have a Contains method

shrewd lion
coarse turtle
#

if you want to use the Contains extension method

odd cipher
#

Doesn't seem to work even with IEquatable.

#

unless that Contains method is in some other class

coarse turtle
#

should just be in Unity.Collections

#

but that static class is NativeArrayExtensions

low tangle
#

yeah you will have to include collections

#

nativearray is in the base unity namespace now, but not the extensions

odd cipher
low tangle
#

looks like you got good feedback on items, but one thing I can tell your doing is still thinking in one object, inheritance mode. most people start from a oop background and that's totally fine, but one thing you might ponder is that there is no reason the item entity needs to also include the durability entity, maybe multiple entities is what you would want @shrewd lion

shrewd lion
#

Oh btw, one last thing, are you familiar with the performance of entities with many components? So if I want a complex item, of course in a DOTS game that conceptually doesnt exist, just an entity with many components. However, what is the performance of having an entity with say, 100s of components on it?

low tangle
#

the performance isn't a issue with that, but there are several things to be aware of

#

also 100s of components on a single entity would be concerning from a design pov

shrewd lion
tawdry tree
#

Complexity (in terms of developing and debugging) of understanding comes to mind as an obvious problem

low tangle
#

yes, but weapon/item durbility doesn't strictly have to be associated with the item description? the item icon in inventory?

#

theres a lot unrelated data that would all be grouped together in a traditional item class

tawdry tree
#

For an item in a game, I'd probably split it into the logical representation of an item (what you have in your inventory; just an id) and the actual data (in a data store).

low tangle
#

if you think of entities, ID's as pointers to data, and can freely update and store them within components, you can create any sort of structure, tree or otherwise within your entities

#

yeah, in my old mb based games I ran with a ItemData which was a key'd scriptable object, and simply had a item in oop land with the id for lookup

tawdry tree
#

Durability is one attribute that you might want on a logical representation, but you you don't need all, say, swords to hold their max durability

#

I would also like to comment on entity with 100 components:
It should be a GIANT red flag if far before you get close to that amount

low tangle
#

durability = 100% omit it, durability = 0 remove it add broken
thats the more common data processing idea ecs can teach you

tawdry tree
#

For example, yeah

low tangle
#

allows for cpu savings, but thats not what we were trying to get at

#

same goes for health, healing over time etc

#

highly recomend the DOD book by richard

#

think its pinned in here

#

oh maybe not

shrewd lion
#

Yeah, there's no way I'm getting into DOTS for now

low tangle
tawdry tree
#

Though for simplicity you might want to keep the durability even at max, to represent that the entity can lose durability.
So no Durability = indestructable, with Durability = has durability, not broken, with Broken = has durability, is broken

#

^DOD is useful to know even if you're not doing DOTS

#

Expand your mind, broaden your horizons.
Also that kind of thinking is used in many projects even in languages that are traditionally OOP.
Same with functional programming, really; by understanding the concepts and "why" and "what" lets you use the knowledge in other contexts

zenith wyvern
#

For an item in a game, I'd probably split it into the logical representation of an item (what you have in your inventory; just an id) and the actual data (in a data store).
@tawdry tree

Isn't this what storing your items in your inventory as entity references effectively does?

#

Oh I see your point, you want to have a base representation to build instances from for relevant per instance data

shrewd lion
#

Basically, you're building a game, but the logic will operate like that of a relational database

#

avoid null checks and stuff

low tangle
#

yep, dont have to check for null if you only work on a live set of data always

#

you do have to check refs to other entities, but thats much faster due to the entity manager

shrewd lion
low tangle
#

can I ask what your motivations for playing with ECS/DOD are?

shrewd lion
#

Sure. I want to potentially have millions of entities in a game. I realize there's no way that's going to happen with GameObjects + Mono, so I must use ECS at least because GameObjects are too heavy

low tangle
#

millions of what kinds of entities?

shrewd lion
#

Of items, which can be very simple, or very complex. Even "abilities" in my game are items, which you can click and will do logic and apply effects, and that allows me freedom

#

I already had to use Jobs because I have some tasks which absolutely require multithreading

low tangle
#

thats good

#

juggling a pc atm, almost done

#

how was the port to using jobs? if it wasn't too much of a challenge I would say try to make a MVP of your item system, if its the main driver of performance loss in your game design

#

you dont have to go all in on DOD, and can write it much more oop like, but you are leaving a lot of performance on the table by not simplifying the data to simplify the logic/processing cost

shrewd lion
#

There was no port to using jobs, I designed the critical parts of the game from the start to work with jobs since I knew they would clog up the main thread.

low tangle
#

ah yeah true, jobs have been out awhile now

#

my current game was started before the job system was shipped, sorry forgot not everyone has to port to it

shrewd lion
#

It can't perform worse than GameObjects

#

I hope

low tangle
#

it won't

#

even naive implementations run quite well

shrewd lion
#

Again, thanks for the input on this, and that link you posted helped a lot as well

low tangle
#

glad to help, as are most people in this channel

vagrant tulip
#

Hey guys, I have written my own A * Pathfinding algorithm and am in the process of converting it to DOTS, but I am having some issues. I was wondering if there's anyone familiar with both DOTS and A * that might be able to help me out. It actually doesn't crash now, and everything is I think indexed properly, but I maybe am missing a logic error somewhere.

#

I'd be willing to send it over discord, if anyone is willing to help. It's fairly well commented and all contained to a single script.

#

I maybe have accidentally used a data type not compatible with Burst Compile somewhere or something, I just want to make sure that the issue is not with DOTS but rather with my loops or parenting of nodes or something.

zenith wyvern
#

@vagrant tulip Sure, hit me

vagrant surge
#

DOD and ECS is basically the same

#

or very similar

#

ECS the way unity works is kinda like "training wheels" for DOD

wet epoch
#

should empty entities (no components) automatically get deleted?

#

trying to use unity netcode to send RPC commands, but it's leaving empty entities behind

#

(i can't scroll up on the matching chunks; there's no tags associated with it)

amber flicker
#

I don't think there's any reason they would get automatically deleted - what if you wanted to remove all components and add a different one for example.

wet epoch
#

hmm

#

not sure how i could delete these ones it's left behind

#

guessing i can't use .WithNone<IComponentData>

#

that probably wouldn't be safe anyway

amber flicker
#

Ideally you don't let them get empty without a reference to them I'd say. One tactic is to make one of your ICDs/Tags/whatever inherit from ISystemStateComponentData instead of IComponentData - then it won't actually get removed and your cleanup system can require the presence of it

wet epoch
#

yeah, it's not my code removing the components though

amber flicker
#

there's also the UniversalQuery to find all entities which you can use WithNone on as well I guess

#

I haven't messed with netcode at all - that sounds really odd netcode itself would leave this floating around - perhaps someone else here knows more about that

wet epoch
#

hmm it calls DestroyEntity

#

so not sure what these are :/

#

i'll try and reproduce it in something smaller (or see if i've got something else creating them)

wet epoch
#

gah was my bad, sorry

#

thanks timboc

amber flicker
#

np - glad you sorted it

dull siren
#

I have 2 inputs in my job struct and an output. The output is set in the Execute function, however it says Job.output has not been assigned or constructed. All containers must be valid when scheduling a job. - Well I have to schedule the job to set the output value, what??

#

Ah I found a youtube video explaining how to set it to an empty value first

hollow sorrel
#

wah

#

uses il post processing so prob still the same thing under the hood, but nice to be able to just call a burst function directly

deft stump
#

hrmmm
is it any better than running bursted ijob.run?

zenith wyvern
#

It's a lot worse I'd say. Function pointers are slow by comparison and the syntax is really awkward for a normal function call

#

I wonder why they wouldn't wrap an ijob instead actually

deft stump
#

maybe it's an alternative without doing the setup of jobs?

#

but there's also a setup for burst functions... sooo...

mint iron
#

should be pretty easy to do a test compare

mint iron
zenith wyvern
#

Wow, I would not have expected that. Good to know

stiff skiff
#

How does it perform if you move the loop inside the burst compiled utility?

#

Ah wait, just noticed this is comparing job vs burst function.

#

Though it was burst vs non-burst

#

This is cool tho! I have lots of code in places that would benefit from burst, but I cant make the whole thing burst due to some non-burstable code

mint iron
#

yeah i wouldn't call this test conclusive yet. i moved the loop into burst and the job goes way faster now.

flint schooner
#

Best most up to date tutorial/guide on DOTS & ECS recommendations welcome.

stiff skiff
#

"up to date" is very relative

mint iron
zenith wyvern
#

Yeah that looks like what I'd expect

stiff skiff
#

How so?

#

I expected the burst invoke to be faster

zenith wyvern
#

Hmm, if you move the for loop into the function call does it win again?

mint iron
#

mmm thought i did, maybe i made a mistake

zenith wyvern
#

Oh yeah you did

flint schooner
#

OK Relatively upto date, where I can actually make something without too much of a detective job to piece together the correct info

stiff skiff
#

They have samples on the Unity github page that are decently up to date

zenith wyvern
#

In the pinned messages, the github samples

flint schooner
#

Yep saw the samples were only a month out of date (well some of them ) which is super recent (kinda)

stiff skiff
#

That sounds about right

#

don't forget all of this is super preview, and can change on a dime

#

(And has... several times)

flint schooner
#

I know I last dipped into it a couple of years ago when it was super x10 preview

proper silo
#

@flint schooner I used the "recent" videos from Game Academy school youtube channel, very nice to start. I found a couple of interesting videos on the Turbo Makes Games channel as well

odd cipher
#

Still haven't figured out how to use Contains on a DynamicBuffer. I don't understand this error.

stiff skiff
#

It wants an int as a parameter?

odd cipher
#

yeah it is an int

stiff skiff
#

Actually, where does that Contains come from? I cant find it in the docs

odd cipher
#

Unity.Collections

stiff skiff
#

Are you sure? DynamicBuffer is from Entities

#

It seems to try to use Contains from FixedStringMethods

odd cipher
#

Yeah I'm sure. I suppose they won't work together. Someone else in here recommended me to use it.

#

yeah thats the one

stiff skiff
#

But you're using a DynamicBuffer, which doesn't have a Contains so its confused

coarse turtle
#

Did you try AsNativeArray().Contains? Since that was what I put in my example ๐Ÿค”

zenith wyvern
#

Convert it to a nativarray and use that contains

odd cipher
#

Oh yeah, tried that too but gives the same error.

stiff skiff
#

Write an extension which iterates over it and checks if the value is there

coarse turtle
#

yea that's the other option

stiff skiff
#

converting it to a nativearray is just a waste

zenith wyvern
#

AsNativeArray doesn't do any copying. It's not wasting anything

stiff skiff
#

Ah you're right, I missed that

odd cipher
#

I'll do a loop instead. Seems to be the easier option here.

stiff skiff
#

using AsNativeArray will probably be less work

zenith wyvern
#
    public struct Comp : IBufferElementData
    {
        public int Value;
    }

    void Find(DynamicBuffer<Comp> buffer)
    {
        buffer.Reinterpret<int>().AsNativeArray().Contains(10);
    }
stiff skiff
#

It's Contains extension method will just do the work for you

mint iron
#

a function wrapper on job gets pretty close, if you need to run burst functions outside of systems.

#

though the calculation is wrong, thats odd

dull siren
#

Why can't my Job struct not contain any reference types? I need to pass it a Dictionary

#

I can pass it an int2, but not a Dictionary

mint iron
#

because everything in burst needs to be struct/unmanaged

dull siren
#

How do I pass it a corresponding list then? a NativeArray?

mint iron
#

you can use NativeHashMap or UnsafeNativeHashMap instead of a dictionary

dull siren
#

I need to pass it a set of tiles as int2 and a bool showing if it is a walkable tile

#

Oh sweet! That looks like a Dictionary Thanks @mint iron

#

It says it has not been assigned or constructed

#
                {
                    startPosition = start,
                    endPosition = new int2(i, y),
                    gridSize = new int2(20,20),
                    walkableMap = inputMap,
                    path = path,
                    finalGCost = finalGCost
                };```
#

walkableMap is the only one it says has not been assigned, just because it is a NativeHashMap type? I am assigning it

north bay
#

Did you allocate it? new NativeHashMap<TKey, TValue>(capacity, allocator)

stiff skiff
#

You could also not burst compile the job

dull siren
#

Not familiar with Capacity, maybe it is the Capacity of the list I am using to populate it's KeyValuePairs? Also I did not put an allocator because it is an input value, not something I need as output.

#

I am going to pass the same map to many jobs, so they can use it to see which tiles are walkable

#

Then I can dispose of it

#

I tried creating a new map for every call NativeHashMap<int2, bool> inputMap = new NativeHashMap<int2, bool>(map.Capacity, Allocator.TempJob);

deft stump
dull siren
#

Still says its not constructed or assigned

zenith wyvern
#

Capacity is the same as in non-dots containers. Max length before it has to resize internally

dull siren
#

                foreach (GroundPosition p in map)
                {
                    bool occupied = false;
                    if (p.occupied != null)
                        occupied = true;
                    inputMap[new int2((int)p.position.x, (int)p.position.y)] = occupied;
                }

                NativeList<int2> path = new NativeList<int2>(Allocator.TempJob);
                NativeArray<int> finalGCost = new NativeArray<int>(1, Allocator.TempJob);
                FindPathJob findPathJob = new FindPathJob
                {
                    startPosition = start,
                    endPosition = new int2(i, y),
                    gridSize = new int2(20,20),
                    walkableMap = inputMap,
                    path = path,
                    finalGCost = finalGCost
                };
                JobHandle jobHandle = findPathJob.Schedule();
                jobHandle.Complete();

                output.Add(new int2(i, y), ((float)finalGCost[0] / 10));
                inputMap.Dispose();
                path.Dispose();
                finalGCost.Dispose();```
#

walkableMap is the only variable it says is not constructed

stiff skiff
#

Ah right

#

Can you copy paste the full error?

dull siren
#

InvalidOperationException: The UNKNOWN_OBJECT_TYPE FindPathJob.test has not been assigned or constructed. All containers must be valid when scheduling a job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.Schedule (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters) (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
Unity.Jobs.IJobExtensions.Schedule[T] (T jobData, Unity.Jobs.JobHandle dependsOn) (at <a9810827dce3444a8e5c4e9f3f5e0828>:0)
Pathfinding.Get_SingleTileMoveCost (UnityEngine.Vector2 startPos, UnityEngine.Vector2 endPos) (at Assets/Scripts/Pathing/Pathfinding.cs:28)
Character.Set_Position (UnityEngine.Vector2 newValue, System.Boolean ignoreAP) (at Assets/Scripts/Character.cs:186)
PartyController.AddCharacter (System.String type, System.String name, System.Int32 health, System.Int32 AP, System.Int32 Exp, UnityEngine.Vector2 pos, Item startingEquipment) (at Assets/Scripts/Controllers/PartyController.cs:84)
PartyController.Start () (at Assets/Scripts/Controllers/PartyController.cs:24)

#

I simplified this by just trying to pass a test variable ``` NativeList<int2> path = new NativeList<int2>(Allocator.TempJob);
NativeArray<int> finalGCost = new NativeArray<int>(1, Allocator.TempJob);
NativeList<int> testInput = new NativeList<int>(Allocator.TempJob);
testInput.Add(1);

            FindPathJob findPathJob = new FindPathJob
            {
                startPosition = start,
                endPosition = new int2(i, y),
                gridSize = new int2(20, 20),
                test = testInput,
                path = path,
                finalGCost = finalGCost
            };
            JobHandle jobHandle = findPathJob.Schedule();
            jobHandle.Complete();```
#

It will not take anything other than an int2 as input, yet it takes array and list outputs no problem

#
    {
        //Inputs
        public int2 endPosition;
        public int2 startPosition;
        public int2 gridSize;
        //Outputs
        public NativeList<int2> path;
        public NativeArray<int> finalGCost;

        //Testing one more input
        public NativeList<int> test;```
#

If I change the type of the input param to just an int2, it works just fine. It just will not accept any input paramaters which are of type NativeX. I don't even know how it knows my Output parameters are being used as output, but it takes those just fine.

coarse turtle
#
FindPathJob findPathJob = new FindPathJob
{
  startPosition = start,
  endPosition = new int2(i, y),
  gridSize = new int2(20,20),
  walkableMap = inputMap,
  path = path,
  finalGCost = finalGCost,
  test = ?? <- you're likely missing this based on that error message
};

So the error says: The UNKNOWN_OBJECT_TYPE FindPathJob.test has not been assigned or constructed. I don't see you assigning FindPathJob.test in this job struct ๐Ÿค”

dull siren
#

The errory says FindPathJob.walkableMap when I was using that name. I updated my code above where I am using a simpler List called Test

#

Uh oh I might have figured it out, another function was calling the FindPathJob as well and it did not have the new input param. Could that cause it? Normally my code would not compile if I was missing an input param

#

But since it is a struct and not a function......

coarse turtle
#

well you're doing struct initialization, not a function call

#

usually if you have a default implementation of a constructor for structs all fields will need to be assigned and you're initializing the struct through the shorthand - so fields can be assigned optionally

dull siren
#

Oh I should create an initializer function and use that, IE public FindPathJob()

coarse turtle
#

Sure if you want, or a default constructor for the struct so you can do new FindPathJob(... /* Put params here*/)

dull siren
#

Ok, that way I wont make the same mistake, trying to update now to verify

#

I followed a video to get started on pathfinding with DOTS instead of coroutines and it was shown this way.

#

Whew that was it! It was complaining about another call! I will use constructors to prevent compiling, thanks!!

coarse turtle
#

Usually you can just click where the error is in the console, so you can bring up the line(s) that have an issue, since there's nothing preventing you or anyone else from using the initialization list of structs/classes

spark glade
slim nebula
#

if I need to edit code in a package, what's the easiest workflow to do that?

#

(i need to change 3 lines in kinematica to support the newer unity.collections library)

coarse turtle
slim nebula
#

ok

coarse turtle
#

yea you would get a development package and unity won't revert the packages to its src version

slim nebula
#

aight

proper silo
#

Hello! is there a way to have a trail renderer converted with an entity (imagine a bullet having a trail when fired) or is it not supported yet?

spark glade
proper silo
#

Is there a way to get an EntityArchetype from an entity and/or a prefrab?

spark glade
proper silo
spark glade
#

Ha, I was gonna say it sounds like you want to clone/instantiate something ๐Ÿ™‚

buoyant ivy
#

how do you schedule a job? i was following the unity docs and they dont seem to work? After creating an IJob and instantiating it, there is no ".Schedule" method that I can call on it...

slim nebula
#

you're probably in a componentsystem, for .schedule you'd need to be in a job component system

#

componentsystems are moree geared towards main thread execution

#

jobcomponentsystems are more geared towards creating jobs

#

@buoyant ivy

zenith wyvern
#

Don't use jobcomponentsystem or componentsystem. Just use SystemBase

#

It replaces both of them.

slim nebula
#

oh

zenith wyvern
#

@buoyant ivy That's weird, can you show the code?

#

You should just be able to call .Schedule() on your job struct

buoyant ivy
#

i just tried to post it but it didnt post lol

#

do i need to install a package ?

#

yea i guess you cant post code here

#

ill msg you

zenith wyvern
#

You can definitely post code. You need to surround it in triple backticks. Or just post a link to pastebin/hatebin

buoyant ivy
#
        public float a;
        public float b;
        public NativeArray<Stats> result;

        public void Execute () {
            result[0] = result[0];
        }
    }```
#

       
        void Start () {
            Stats stats = new Stats();
            NativeArray<Stats> result = new NativeArray<Stats>(1, Allocator.Persistent);
            result[0] = stats;
            testJob = new TestJobThreaded();
            testJob.result = result;
            // testJob.Schedule(); // this line doesn't work
        }```
#

oh ok the discord code button doesnt do the triple backticks lol

zenith wyvern
#

Do you have using Unity.Jobs; in the file where you're scheduling?

buoyant ivy
#

no

#

ok that fixed it thanks

zenith wyvern
#

Schedule is probably an extension method

#

No worries

buoyant ivy
#

they should put that in the guide

#

there is no way to access gameobjects or anything inside jobs right ?

#

so like if you wanted to be able to check for example the distance between some gameobjects, you'd need to actually set the positions in the job via floats from all the gameobjects before scheduling ?

deft stump
#

yes

#

prep the data

#

sched

#

get result /then re-apply data to main thread if needed

buoyant ivy
#

i wonder why its not able to have maybe just read only access or something to gameobject data

deft stump
#

well the main thread has read/write access to it

#

so you now have concurrency problem

#

main thread writes.
job thread reads.
but in the middle of a read, the data changed.

#

Job thread be like : "yo wtf"

#

so it's better to give a copy of the data to the job thread to avoid this problem

buoyant ivy
#

oh i see you mean like litterally in the middle of the reading

deft stump
#

yup

buoyant ivy
#

oh ok

#

is there any case when jobs would not be worth it due to the overhead of setting and updating values before and after the job ?

deft stump
#

multithreading is great when you need to compute multiple stuff. in large batches.

#

Although right now, there's .Run which runs a job on the main thread and bursted if you so desire

buoyant ivy
#

what is bursted, i thought that was just the multithreading jobs thing

deft stump
#

using the Burst Compiler to speed up the job

buoyant ivy
#

oh I see so it runs faster than it would in normal monobehaviors ?

#

like if you had the logic outside of a job

lilac harness
#

Anyone know of a rough timeline when DOTS will be fully released? Can't seem to find anything about it on the Unity road maps (which worries me)

spark glade
#

Can I get a sanity check on this idea ๐Ÿ™

Currently I have a PrefabRegistryAuthoring ( IConvertGameObjectToEntity, IDeclareReferencedPrefabs) which basically holds a list of prefabs to be converted. In the Convert method I convert all the prefabs and then store mapping from PrefabIdentifier -> Entity in a NativeHashMap inside a small System. This conversion happens at runtime on a GameObject with Convert To Entity.
My Spawner system looks up a Entity by said PrefabIdentifier and instantiates it via EntityCommandBuffer.Instantiate(...).

All this works without problems.

Now, I'm thinking of putting the conversion into a SubScene, because that should be more efficient to load, instead of doing the runtime conversion every time I'm opening my game scene.

So I'm thinking of storing a NativeHashMap in a BlobAsset (someone wrote a BlobHashMap already, yay) where I'd store the same PrefabIdentifier -> Entity mapping. Since I want this in a SubScene, this conversion happens in the editor. So my question is would I store this NativeHashmap-BlobAssetReference mapping as a PrefabRegistryMapping component on entity and just fetch it for lookup with GetSingletonEntity?

Does that make sense?

I'm wondering if this approach is solid, aka will the Entity references be usable at runtime.

low tangle
#

@lilac harness current year + 1

lilac harness
#

So... not even close?

deft stump
#

I mean... our current version number is 0.16

#

not even close 1.00

opaque ledge
#

wasnt machiene learning package was like 0.15 and bumped to 1.00 ?

craggy orbit
#

DOTS packages are hidden by default in the package manager because they're still so experimental. they're nowhere near 1.0

spark glade
# spark glade Can I get a sanity check on this idea ๐Ÿ™ Currently I have a `PrefabRegistryAut...

Shameless plug to the forum version of this question, if anyone is interested in it: https://forum.unity.com/threads/baked-prefab-registry-editor-conversionsystem.1026994/

buoyant ivy
#

can i make a struct scriptable object? or something that can be used in jobs?

deft stump
#

which can be used in jobs

buoyant ivy
#

can you make those easily in the editor ?

#

or is that just code ?

deft stump
#

it's code

buoyant ivy
#

ok

deft stump
#

so I saw this class called

#

GameObjectEntity

#

What... does it do?

coarse turtle
#

iirc I think that was the old way of defining a GameObject to be associated with an entity, pre conversion days

#

believed it would execute in the editor so that it can write the entity into a world, and you'd get an entity you can now process

deft stump
#

mhm mhm.
I found it when I was playing around the samples for the latest 2D animation. There's an option now to make use of burst.

and then I saw that there's a Sprite Skin Entity : GameObjectEntity and it seems to be talking to ECS world or something. Not sure what it does with all the preprocessor directive

amber flicker
#

I hope there aren't new samples being put out with year-old ecs stuff

coarse turtle
#

hmm has the 2D stuff been updated? @deft stump

#

It's been a long time since I looked at that and I'd probably want to revisit it

deft stump
coarse turtle
#

Oh I guess I missed the updates for 2D entities lol

deft stump
#

isn't 2D entities for Tiny?

coarse turtle
#

Yea essentially

deft stump
#

so I can't use 2D entities on DOTS-hybrid?

#

oh it's built literally on top of tiny

coarse turtle
#

yep

deft stump
#

huh

#

somewhere down the line

#

my issue withsprite renderer murdering my cpu is gone.

stone osprey
#

So... I have a weapon entity with components like { Weapon, AttackDamage, AttackSpeed... } and a player which owns an inventory that references that weapon. When my player gets marked as "Attack{ List<Entity> entities }", i actually wanna have the weapon itself fire the damage event, not the player. But heres the problem, the weapon does not know if the player is marked with "Attack", because its an seperate entity... any clue how to solve this issue ? :/ Or any other tipps regarding my combat strategy, ways i could bypass this ?

stone osprey
#

Damn... i have no clue whats the best solution for this... this drives me crazy. I actually just wonder if this is the right way at all, having a weapon entity that contains stuff like the damage event, attack speed and a player entity that is using it.

mint iron
#

its been a while since i was immersed int his but i gravitated towards entities with lots of components for that reason. And as soon as you start keeping references between children back to their parent to check if state exists you're going into random access land. But that solution is to have the weapon know what the player entity is, and then lookup the component with the entity.

stone osprey
#

@mint iron Thanks ! So we should basically reference the weapon to its player like... {Equiped( byEntity ) }, then iterate over Entities.ForEach(Weapon, Equiped ) => {} for checking if the referenced player entity is marked with that combat component ? ^^

#

Well it looks like this would work, the only downside i see so far is that it would check for that component every frame... due to the loss of marking

mint iron
#

i was thinking that if you're in a foreach for your weapon already, you could Get/HasComponent<Attack>(ParentEntity); parent entity the weapon could get access to by in Entity SomeRelationshipComponent parentRefs.

stone osprey
#

Ah ok, we mean the same ^^ I also thought about some sort of event system, but im not sure if this would work better or properly at all... Or some system that copies components to "childs" of an entity like events...

mint iron
#

another option could be to have some sort of lookup you can pass in that contains the targeting data like a hashmap indexed by weapon entity id. another option could be to have the player set the attack component on the weapon instead of player, so the weapon only fires if the component exists.

pliant pike
#

I don't suppose anyone knows how to use this dynamicbuffer with ReadOnly csharp var tempbuff = GetBuffer<ObstacleCollisionVerts>(colliderents[i]);

#

I need to get the buffer inside the job but have it Readonly so it can be multithreaded

safe lintel
#

hey anyone using the dots editor get the prefab options(apply changes, revert etc) in the inspector? not sure if they moved that stuff to a rightclick menu only in the hierarchy or if its dots inspector hiding it

pliant pike
#
var tumpbuff = GetBufferFromEntity<ObstacleCollisionVerts>(true);
var tempbuff = tumpbuff[colliderents[i]];```
#

that's the solution to above if anyone is interested

#

true being the part where you tell it to read only

slim nebula
#

is 2020.2 going to be LTS?

slim nebula
#

in unity.physics, why does SimplexSolver.Solve no longer require a physics world parameter? how does it know the world?

#

(changed in 0.4)

slim nebula
#

thanks

#

perfect

#

I think it meets my requirements

#

assuming this preview dots shit gets LTS support too

amber flicker
#

nobody external knows - some of DOTS, maybe not entities

slim nebula
#

oof

#

it's fine

hexed yoke
#

Hopefully this isn't too dumb question, I tried getting into ECS last year, but it was a bit of a mess and every resource I looked at was out of date so I put it off. i want to give it another crack, where's the best place to start??

I had a look in the forum but it's so messy and so many pinned things, where's like, some code samples 101. I get the concepts and have watched all the videos.

robust scaffold
#

From back when DOTS used to be named Unity ECS. Ah, unity and constantly renaming things.

#

Although the one package they should rename they never did. Ever tried googling "Unity Jobs"?

deft stump
#

is it normal to have a... game manager entity?

#

or can I avoid it?

coarse turtle
#

depends on your design? Why do you need a game manager entity?

deft stump
#

coz I have a 6 x 3 grid, and instead of scanning the entire the grid, check, and then move.
I figured I would turn it into a hashmap and store it at attach it to some game manager entity

#

to avoid the scan

coarse turtle
#

yeah doesn't sound like a bad idea tbh

deft stump
#

or I could tag each panel with their respective ID's as type

#

no wait, that's inflexible

deft stump
#

oh right

#

native containers aren't blittable

deft stump
#

okay so burst is complaining

deft stump
#

how would I go about retrieving data from a hashmap inside a system?

craggy orbit
#

there's NativeHashMap<T> iirc

deft stump
#

and where do I store this hashmap

#

yeah but burst is complaining

craggy orbit
#

about what

deft stump
#

NativeHashMap aint blittable

craggy orbit
#

ohhhh right

#

there's a ParallelWriter (or something similarly named. i don't remember the exact name at the moment) property of the hashmap that you can use

#

like myNativeHashMap.ParallelWriter

deft stump
#

hrmmm alright

#

I'll try that

craggy orbit
#

oh wait sorry it's myNativeHashMap.AsParallelWriter()

deft stump
#

no wait

#

I can't read from it

agile dome
#

@deft stump Is GameManager the best name you can come up for it?

#

GameManager to me always feels like a naming issue.

summer canyon
#

is ECS more performant mostly because logic is no longer contained on the Entities?

#

if so...does that mean i could get a performance boost with non-ECS by taking a GameObject as my "Entity", sticking some blank MonoBehaviours all over it as my "Components" that are nothing more than data containers, then having "Systems" act on them by just using Manager Scripts somewhere?

#

nevermind i just stumbled upon the answer

#

you can, and its called Hybrid ECS

agile dome
#

I don't think that is what Hybrid ECS is though

summer canyon
#

idk lol thats what this brackey's video just told me (4:09) https://youtu.be/_U9wRgQyy6s?t=269

This changes everything! ECS is here so let's see how it works!

This video is sponsored by Unity.

EDIT: ECS can now be obtained via the package manager.

โ— Manifest.json Text: https://bit.ly/2xE4pTA
โ— ECS Documentation: https://bit.ly/2J9YvLe
โ— More on Pure ECS: https://bit.ly/2H9ResT

โ™ฅ Support Brackeys on Patreon: http://patreon.com/brackeys...

โ–ถ Play video
agile dome
#

Oh wow. Didn't realize it was literally that and always thought it was just a name for a setup that uses pure ECS in a Monobehaviour environment.

#

I've only used ECS with Project Tiny ๐Ÿ˜„

zenith wyvern
#

You're not going to get performance using monobehaviours, even with ecs

#

ECS is fast when it can lay out your data in chunks. It can't do that with class based components

deft stump
agile dome
#

@crimson smelt Don't cross post, especially to unrelated channels.

crimson smelt
#

ok sorry i just didnt know which channel to put this in

#

but can i get my answer??

deft stump
crimson smelt
#

then where

zenith wyvern
crimson smelt
#

ok

deft stump
#

funnily enough

#

this idea worked.

zenith wyvern
#

how would I go about retrieving data from a hashmap inside a system?
@deft stump

You call World.GetOrCreateSystem().GetHashMap(). And that function would get your container, or some struct that wraps your container. But then you need to manually manage the jobhandles for any job that touches the container

deft stump
#

no wait... my idea didn't work aaargh

#

hahahaha

deft stump
odd cipher
#

Do IJobChunks have any advantage over typical Entities.ForEach loops? Or do I not understand what an IJobChunk is

zenith wyvern
#

Ijobchunk is what Entities.ForEach gets converted into after codegen

#

Writing it out manually is quite a lot more typing but gives you more control and lets you do some things you can't do in a ForEach

odd cipher
#

Oh I didn't know that

#

Gotcha

summer canyon
deft stump
tawdry tree
#

The post date suggests the post is a year old, tho

gleaming plank
#

Reading that thread to the end, the author redid their tests once they learned about JobComponentSystems (now obsolete) and the Burst Compiler options and got a ~40x speedup over the Update() way.

deft stump
#

what's the difference between the different counts in the IJobChunk?

#

Count, BatchEntityCount, and ChunkEntityCount.

#

I assume Count would be all entities that matches EntityQuery right?

coarse turtle
#

Thought chunk.Count is the number of entities in the chunk.

deft stump
#

I dunno lol I'm gonna debug log

#

so even with ijobchunk

#

it's still getting complaints that I can't read NHM

#

what are my other options?

lusty otter
#

I haven't worked on ECS stuffs in a while, but I remember you can just read NativeHashMap no issue.

deft stump
#

it doesn't want to compile

#

job safety check is telling me no

craggy orbit
#

did you mark it readonly

deft stump
#

yeah

lusty otter
#

Error message?

craggy orbit
#

and the type is NativeHashMap<T>.ParallelWriter, right?

deft stump
deft stump
#

I can't read

#

it assumes I want to add to it

#

I just wanna read my nhm T_T

#

no wait hold on

#

I think the error was pointing to somewhere else

lusty otter
#

It says the error is GridPanelManagerData having non blittable data though.

#

It doesn't seem like it has anything to do with NativeHashMap.

craggy orbit
#

i thought Unity had fixed incorrect stacktrace links with Burst but i guess not ๐Ÿค”

deft stump
#

an icd was the one that throwing the errors

#

wth

gusty comet
#

I would seriously kill a dinosaur for some NET STANDARD 2.1 right now.

deft stump
#

why 2.1?
go for .NET5

tawdry tree
#

That might be a bit much to ask for, but of course it would be better.

stiff skiff
#

I'd like them to just move to a decent version of mono

#

Did they ever fix the issue where their version used doubles for floats?

deft stump
#

yo 2021 is in beta

#

and I saw alot of new features for burst

#
Burst: Added support for calling Burst code directly from C# without using function pointers.

Burst: Added support for creating profiler markers from Burst code.

Burst: Added support for exceptions thrown from Burst to contain a callstack.

Burst: Added support for LLVM 11 to bring the latest and greatest code generation benefits to Burst.

Burst: Apple silicon support.

Burst: Experimental support for some ArmV8.2A intrinsics (dotprod, crypto, RDMA).

Burst: Full support for ARMv7 and ARMv8-A Neon intrinsics (out of experimental).

Burst: Preliminary support for loading additional burst compiled libraries in play mode/standalone - for modding support -.

Burst: Support for new intrinsics.
zenith wyvern
#

Modding support...hmm

deft stump
#

there's more

deft stump
#
Scripting: Changed NativeArray limit of 2GiB in size, and now it can contain 2^31 items instead.
dull copper
#

I guess no dots blog post this year..

orchid gate
#

Is there a way to use SystemBase methods like HasComponent or GetComponentDataFromEntity in a static method for use within burst jobs?

zenith wyvern
#

You would need to pass in a ComponentDataFromEntity

orchid gate
#

Gotcha, was just trying to hide some of that logic in a method, thanks

median glen
#

when will NetCode be available for production?

light mason
#

Do we have the office roadmap for dots anywhere

#

I know Joachim mention a while back that one was being worked on but I never saw it

deft stump
#

a question on conversion

#
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            dstManager.AddComponentData(entity, new PanelData
            {
                offset = offset,
                type = type
            });
            Panels.AddToGridPanelMap(index, entity);
        }
#

so i need to store the converted entity into a nhm.

#

but I'm getting a null error when I try to retrieve the entity

#

is it right to assume the entity here is from the Conversion World? and not in the destination world?

zenith wyvern
#

Yes. I believe conversionSystem.GetPrimaryEntity(gameObject) would refer to the entity in the destination world. I haven't tested it though, not sure it will work in that case

#

Since the conversion probably isn't applied to the destination entity until after that script runs

deft stump
#

welp

#

didn't work.

#

one thing I can do is make system that only runs OnCreate on initialize group.

mint iron
#

what is panels and is your conversion happening at runtime? i'm guessing you're adding it to panels at conversion time, but if its a subscene or a conversion system that world will get shutdown and not exist at runtime so there's not going to be anything in panels anymore.

slim nebula
#

wut

#

my message got deleted. sorry if I broke some rule?

#

was just saying reimport subscene got me again

#

word of warning haha

pliant pike
#

I don't suppose anyone knows how I get all of the types of a dynamicbuffer converted into an nativarray?

#

I have this csharp EntityQueryDesc queryDescription = new EntityQueryDesc(); queryDescription.All = new[] { ComponentType.ReadOnly<ObstacleCollisionVerts>() }; TerrainObsQuery = GetEntityQuery(queryDescription);

#

which gets all the dynamicbuffer but when I do this

#
var tempterrainobs = TerrainObsQuery.ToComponentDataArray<ObstacleCollisionVerts>(Allocator.TempJob);```
#

it does not work

#

I just get the error ObstacleCollisionVerts cannot be used as a type parameter etc

robust scaffold
#

@pliant pike Did you solve this?

pliant pike
#

@robust scaffold nope

robust scaffold
#

Right, okay.

#

Your main problem is that you're trying to create a "ComponentDataArray" from a type designated as BufferElement.

#

You cant do that.

#

If Im reading this correct. ObstacleCollisionVerts extends IBufferElement right? It's a dynamic buffer.

pliant pike
#

yep

robust scaffold
#

What you need to do is get the component data that the dynamic buffer is attached to.

#

Then get an array of that component data then request the dynamic buffer of that component.

#

Will you be doing this inside a ForEach / IJob or in the main update chain?

pliant pike
#

in a foreach, I need to compare buffers from two different sets of entitys

robust scaffold
#

Right, you probably know to add "in DynamicBuffer<>" in the parameter types

#

The other comparison will need to be access by entity query yes.

#

This is in a systembase right?

pliant pike
#

yeah

robust scaffold
#

Use EntityManager.CreateEntityQuery(typeof(<Whatever component the ObstacleCollisionVerts is attached to>));

#

You dont need the ComponentType.ReadOnly

#

You can set read only as.. Wait, give me a sec to check the syntax

pliant pike
#

well it is readonly so that would make it more efficient

robust scaffold
#

I dont think you need entity query, I believe you can generate a component data array directly

#

The read only should be assigned in the creation of the component data array and the Entity.WithReadOnly(<ComponentDataArray>)

pliant pike
#
EntityQueryDesc queryDescription = new EntityQueryDesc();
        queryDescription.All = new[] { ComponentType.ReadOnly<ObstacleCollisionVerts>() };
        TerrainObsQuery = GetEntityQuery(queryDescription);```
#

I can get the enitities with that just not the actual buffers

robust scaffold
#

Wait, how are you comparing the entities in you Entity.ForEach lambda code?

#

Is the opposing entity found within the initial entity? Then you can use GetComponentDataFromEntity<>(true); If not, that'll be a little more rough trying to inject data.

pliant pike
#

I'm not sure what you mean by the initial entity, but I'm getting them currently using var tumpbuff = GetBufferFromEntity<ObstacleCollisionVerts>(true);

robust scaffold
#

Wrong code, it's GetBufferFromEntity<>(true).

#

Yep.

pliant pike
#

I was wondering if there was a faster way using an entityquery though

robust scaffold
#

Are you using an actual ForEach(var entity in TerrainObsQuery) or Entities.ForEach?

pliant pike
#
 Entities.ForEach((ref CellData cooldata, in DynamicBuffer<FlowfieldVertPointsBuff> flowverts) =>
        {```
#

I'm using that for a different dynamicbuffer

robust scaffold
#

Yep. And you're comparing this entity with every other entity that has ObstacleCollisionVerts?

pliant pike
#

yep

robust scaffold
#

Hmmm, that doesnt seem efficient.

pliant pike
#

that's what I thought getbuffer is random memory access surely

robust scaffold
#

What is being compared? Floats == Floats?

#

Yep

#

If it's Floats or some other type equals the exact same type, you can instead populate a hashmap with one Entities.ForEach with all ObstacleCollisionVerts then use that as a lookup in the next.

#

If it's a range, that's a little bit more difficult.

pliant pike
#

Its kind of a range

robust scaffold
#

Depending on the possible variations in that range, you can repeatedly sample the hashmap for possible values.

#

If it's an infinite range, then I cant think of any other improvements then without knowing the reason you're comparing these values.

pliant pike
#

I'm not to familiar with hashmaps to be honest

robust scaffold
#

They're dictionaries. You've used them before?

#

Some of them are key only, some of them have key, value, others are key, many values.

pliant pike
#

I've used dictionaries

robust scaffold
#

They're used like arrays with non-continuous indices.

#

From your variable names, you're attempting to determine if an object collides with another? Is there a reason why you're not using the built in physics engine? Their literal job is to optimize this lookup.

#

Dont try to reinvent the wheel and build a physics engine from the ground up.

pliant pike
#

there's is to complicated and I don't think its really finished

#

I just need to do a simple AABB comparison

robust scaffold
#

Yeaaaaaaa. That's DOTS, the whole thing is not finished.

#

Hmm then yea. If you have a specific reason, use the entity query to get all entities with ObstacleCollisionVerts.

#

Does an entity with <FlowfieldVertPointsBuff> compare against all <ObstacleCollisionVerts> or a select few?

pliant pike
#

against all

robust scaffold
#

If it's all, you can populate a NativeArray/List before the <FlowfieldVertPointsBuff> ForEach

pliant pike
#

yeah I'm trying to figure that part out

robust scaffold
#

Then use that NativeArray and do an actual foreach(){} loop for all values of the NativeArray inside the Entities.ForEach.

#

Is the dynamic buffer of ObstacleCollisionVerts of constant singular length across all entities?

pliant pike
#

yep it should be

robust scaffold
#

Then you can use something like this:

pliant pike
#

I'm going to have do it manually arent I

robust scaffold
#

Yea

pliant pike
#

I did attempt that before but got a bit lost in it to be honest

robust scaffold
#
var comparisonArray = new NativeArray<ObstacleCollisionVerts>(<number of entities with ObstacleCollisionVerts * length of each buffer>, Allocator.TempJob);

Entities.WithParallelRestrictionDisabled(comparisonArray).ForEach((in <Some sort of ComponentData containing a unique index>, in DynamicBuffer<ObstacleCollisionVerts> OCV) => {}).ScheduleParallel;```
#

Then you do the Entities.ForEach((ref CellData cooldata, in DynamicBuffer<FlowfieldVertPointsBuff> flowverts) =>{}).ScheduleParallel(); comparison.

#

Using Entities.WithReadOnly(comparisonArray).ForEach()

#

Should be slightly better than doing a random access .GetBufferFromEntity(true);

pliant pike
#

I guess job is the best place to write the buffer to a nativearray

robust scaffold
#

Yep. You should aim to make everything into a job.

pliant pike
#

I've been looking at that its similar but using Ijobchunk, I haven't really used IJobchunk before though

robust scaffold
#

Ehhhh, dont use IJobChunk if you dont need the specific custom chunk declaration and joining.

#

Entities.ForEach is basically IJobChunk. Has some restrictions but it's like the difference between using ShaderGraph vs handwriting HLSL.

pliant pike
#

oh cool, I'm glad I dont have to use Ijobchunk ๐Ÿ‘

robust scaffold
#

ShaderGraph might not be able to get deep down into the GPU engine but it's a hell of a lot easier to read, code, and change than raw HLSL.

#

The only dinosaur from the old days of DOTS you might need to use is IJobParallel. The Lambda Jobs is not parallel and I dont believe there is any plans to make it such.

#

If you're doing just number crunching with arrays and not touching the entities side of the DOTS, use IJobParallel. I use it occasionally when I'm modifying one of my 16k textures.

pliant pike
#

cool, simpler the better for my small brain

#

thanks a lot for the help @robust scaffold

robust scaffold
#

Yea, the dinosaur struct based IJob code is rough. Although, looking at the Entities patch notes, it might be coming back with a vengeance with burstable systems.

#

No problem. This was all questions I had back when I started. Trial and error isnt fun.

deft stump
slim nebula
#

so I switched to SystemBase. What am I supposed to pass in for the parameter of Run() and Schedule() for when I want a job handle from them (to pass to AddJobHandleForProducer)

#

is this correct? cs Entities.blahblahblah().Schedule(); EndSimulationEcbSystem.AddJobHandleForProducer(this.Dependency);

slim nebula
gusty comet
#

Are there any good articles on ECS pathfinding?

last jasper
#

I've been out of the loop for a while and saw ToComponentDataArray got removed. What is the suggested replacement?

zenith wyvern
#

It didn't get removed. You call it via an EntityQuery

last jasper
#

Ahh ok, I saw it got removed in 0.11 - Removed expired API EntityQuery.ToComponentDataArray<T>(Allocator, out JobHandle). - is that just a static method from EntityQuery then?

zenith wyvern
#

They renamed the async version to ToCompoentDataArrayAsync. That's what that is referring to

last jasper
#

ahh ok, got it. Cheers!

mild ledge
#

So. Lets say I want to do procedural terrain with dots. Any resources to get me started? I want to generate smaller self contained areas rather than endless terrain

odd cipher
#

I'm not sure if this question would fit in here but it uses ECS stuff so I suppose it is, Each BufferElement in my DynamicBuffer has a ID, which until now has been used to find it's location in the Buffer. However, I want to be able to remove the Element from that list. Though that makes everything else break when trying to find the correct thing in the Buffer. I've tried doing some sort of 'offset' that would increase when a Element is removed from the Buffer, and when a new Element is added the Buffer length + 'offset' is used as the ID. but I haven't gotten that to work.

#

I hope I described it correctly

gusty comet
#

Has anyone worked with DOTS and 2D? I'm just wondering how well Unity's ECS systems work with 2D tilemaps.

pliant pike
#

Well it was definitely worth putting the buffer into a more efficient nativearray it basically halved the time it took

#

to calculate 1 million entities with getbuffer took 226ms

#

1 million with nativarray took 118ms

#

is there not some button I can press to stop unity, I'm stuck in a loop where its drawing 1 million entities now

odd cipher
#

anyone?

pliant pike
#

I don't think buffers really work like that are you sure don't want a hashmap or something like that

odd cipher
#

I don't think that would work either.

pliant pike
#

when working with buffers I think it's best not to work with a specific element if you are going to change the structure of the buffer

odd cipher
#

huh? structural changes work fine.

#

using HashMaps might have been better but you can't have those in Components anyway.

zenith wyvern
#

You can do it with sprites or meshes

slim nebula
#

how can I reference a gameobject in an IComponentData?

#

or is there some better way?

slim nebula
#

oh. neat ok

#

can't have a managed ISystemStateComponentData?

#

I need to dispose some things ๐Ÿ˜ฆ

#

oh no never mind old error

#

seems to work

gusty comet
#

@zenith wyvern do sprites convert to entity correctly?

#

I'm just confused with what rendering implementation I'd be using

zenith wyvern
#

They attach to entities as hybrid components. If you use Project Tiny they have actual proper entity representations of sprites

#

For non-tiny you need to use ECS-friendly rendering data and convert it to your sprites/mesh on the main thread as needed

slim nebula
#

getting errors trying to do gameobject stuff in a foreach that is using an entitycommandbuffer

#

had to switch back to ComponentSystem instead of SystemBase so that I could use EntityManager instead of a EntityCommandBuffer

#

not sure what that's all about

slim nebula
#

hmm thanks I"ll have to look closely

odd cipher
gleaming plank
#

So you have some DynamicBuffer<ElementWithID> and you want to remove elements from it based on their ID?

odd cipher
#

Yes that's what I've been doing, until now, as I need to be able to remove Elements from that Buffer. Which causes all of the other Element IDs to be wrong.

gleaming plank
#

Can you describe more of the surrounding use case for these IDs?

wispy iron
#

Whatโ€™s Dots?

odd cipher
#

well I only use the IDs so I can figure out what position they are in the Buffer.

gleaming plank
#

Well, if the ID is based on the buffer length at the time of insertion, removing an arbitrary element will invalidate the IDs of all elements following it, and you could also end up with duplicate IDs. You could maybe just increment the ID of the last element or use a generational index (like DOTS uses for entities).

I'm just wondering why you need this bookkeeping in the first place?

odd cipher
#

Well, it's kinda hard to explain, it's for a Neural Network and each Neuron in that network needs to know what synapse is connected to it, and that's why I need IDs.

#

And yes, what you suggested there is what I attempted to do but didn't get it to work.

gleaming plank
#

Are the neurons not entities?

odd cipher
#

No, they are Buffer Elements as well, just like the synapses.

#

A different way to do it might be a NativeHashMap but I'm not sure if that would work since it would be unable to be used on a Entity as a Component.

#

I'm not sure what you meant by "generational index" by the way.

gleaming plank
#

In ECS, each entity needs to be a unique array index. A "generational index" is basically an (uint index, uint generation) tuple. Every time you delete an entity, you increment the generation, which solves the problem of invalidating any stale data of deleted entities when you need to reuse those indices.

odd cipher
#

Hm I'm not exactly sure how that could be used in this case, since Buffers only use an int to get the Element. What I have tried doing is every time I remove a 'synapse' Element I increment a integer stored on the Entity and then later use that integer when accessing the list, such as doing a = buffer[i - offset] though that barely works. As for example, if i is 0 then it would be -1 if the offset is 1. Which would not work when accessing a Buffer. And I don't really know how to make it any better.

warm panther
#

How do I correctly share mutable data between multiple entities?

I thought it was BlobAssetReferences, but I can't create these on the fly.

It's not SharedComponentData either, because that is functionally immutable.

Do I put it on another entity and store an Entity reference in a IComponentData? But then I'd always have to get these components; so much boilerplate.

#

(this is for a floating origin system, with a moving point of reference - that point needs to be shared between groups of entities whose systems decided they want to use that particular point of reference)

gleaming plank
#

@odd cipher
I meant that assuming these neurons were entities, you could just have DynamicBuffer<Entity>.
Then removing, a neuron would be easy:

That said, whatever you're trying to do with this NN sounds pretty foreign to me. This is first time I've seen a scenario where it's important to remove individual neurons. Usually, you've got a static structure, where the number of layers is fixed, the size of those layers is fixed, and the layers are all fully-connected.

warm panther
#
namespace Jovian.ECS.Components.Space
{
    public struct Instanced : IComponentData {}
    
    public struct SharedInstance : IComponentData
    {
        public BlobAssetReference<InstanceData> data;
    }

    [Serializable]
    public struct InstanceData
    {
        public byte id;
        public int tenants;
        public double3 origin;
        public double3 extents;
    }
}
#

Because this gets read a lot each frame in various physics and motion/transform systems, I'd like a lightweight way to share at least the id, the origin, and the extents - in parallelizable Jobs.

#

(and the BlobAssetReference seems to be the wrong way to go for this)

odd cipher
#

@gleaming plank Yes I understand what you mean, However neurons are not Entities and it would be very annoying to change it to be so, and most likely wouldn't work for how I want it to. And yes, typical NNs have fixed amounts of layers but NEAT (NeuroEvolution of Augmenting Typologies) neural networks don't. They are dynamic. Which certainly complicates things.

gusty comet
#

error CS0246: The type or namespace name 'GameObjectConversionSystem' could not be found (are you missing a using directive or an assembly reference?)

I created an asmdef file and now I can't compile anything. The reference to Unity.Entities is there, it's visible in the solution explorer in .NET, Unity.Entities is recognized, it just doesn't compile and I don't know why.

#

I've got to admit I have had nothing but trouble trying to get anything ECS working out of the box. I can even download a Unity Tiny project from the demo github, install the exact Unity version, and I still get burst errors trying to generate a DOTS C# Solution

#

I really don't understand how people are able to work with this

zenith wyvern
#

For conversion you need to include Unity.Entities.Hybrid in your asmdef. If you're using tiny it needs to be in a separate asmdef that is not referenced by your root asmdef too.

#

And yes, technically all ECS stuff is still early preview. Usability is definitely not their top priority right now unfortunately

deft stump
#

@zenith wyvern is there a reason why burst doesn't like nativehashmap (unless it's readonly)?

coarse turtle
#

Depends on how you're accessing it I suppose

#

I mainly use NativeHashMaps with read/write capabilities on a single thread

#

if it's across multiple threads then its exclusively a NativeHashMap Parallel Reader/Writer w/ Burst

gusty comet
#

System.InvalidOperationException: Type 'ApplicationIdentifier' is missing / is not derived from any type in build pipeline 'GenerateDotsSolutionBuildPipeline' UsedComponents list.
This is preventing me from generating a DOTS C# Solution. Not a clue what it's for. The project has almost nothing in it but assembly references.

zenith wyvern
#

I've never had an issue using a NHM in burst. Just make sure you're using the ParallelWriter if you're trying to write to it in a parallel job, and pass it as ReadOnly for parallel reading

#

System.InvalidOperationException: Type 'ApplicationIdentifier' is missing / is not derived from any type in build pipeline 'GenerateDotsSolutionBuildPipeline' UsedComponents list.
This is preventing me from generating a DOTS C# Solution. Not a clue what it's for. The project has almost nothing in it but assembly references.
@gusty comet

Not sure what would be causing that. Double check your build configurations and ensure they meet the requirements for project tiny - there are a lot of obscure requirements

gusty comet
#

I get the same error trying to compile the Tiny Spaceship demo without any custom changes

zenith wyvern
#

Do you have the C++ and .net dev packages installed via the visual studio installer? Like I said, obscure requirements

deft stump
#

here's the code

zenith wyvern
#

You can't use mutable static data inside burst.

#

Assign your map to a local variable then pass it into the ForEach

deft stump
#

burst still doesn't like

#

or am I missing something?

zenith wyvern
#

What's the error message

deft stump
#

no wait. it's working. I didn't clear console.

warm panther
#

How do I share mutable data between entities?
Currently building a NativeArray with the data (not sure how to safely share that across systems...yet) and a SharedComponentData with the index into that array.

#

It just feels wrong.

#

I must be missing something here ๐Ÿ˜„

#

Only one system/entity writes the data, and that entity is disjunct from the entities using the data.

zenith wyvern
#

I don't know if there is a good way that fits in well with how they made their ECS. I guess you could have managed components that have a reference to an instance of your shared data

warm panther
#

Yeah... it also needs to be kind of fast.

#

I will be looking into Managed Component Data for other things.

zenith wyvern
#

Hahah....good luck

warm panther
#

I wish they hadn't tied SharedComponentData to chunks. Or have a ChunkComponentData for that.

#

But I guess it makes sense for cache locality.

zenith wyvern
#

Yeah shared mutable data is pretty antithetical to the whole chunk design

warm panther
#

Thing is, it's only mutated by something else entirely. I would just be fine changing the SharedComponentData ... if I could, haha. It's actually the exact behaviour I would expect.

#

But no, what it does instead is move entities over one by one, it seems.

#

If I had control over the hashing of SCD... hmm.

odd cipher
#

I wish a HashMap version of DynamicBuffers were a thing :p

zenith wyvern
#

Is that not what you want pretty much?

warm panther
#

Huh.

#

Not really but actually might be useful for something else.

#

Well actually.

#

I don't quite understand chunk archetypes yet, to be honest.

#

What happens if I have multiple chunks?

#

(i.e. more than fits in one chunk)

zenith wyvern
#

It creates a second chunk and that's how you get parallelism from ECS jobs since they only run parallel across chunks as far as I know

warm panther
#

But if I set a chunkcomponentdata for an entity in that chunk... will it change it in its related chunks, or really only THAT one chunk? ๐Ÿ˜„

#

But actually I could do it with the Query as described. Which is close to what I actually want to do, hmm.

zenith wyvern
#

Yeah I would have thought it would change it for all entities with that data but that's not right. It is a bit confusing

warm panther
#

This looks like I can only read it through EntityManager.

Weird. I need a Write-Seldom, Read-Often component. Reading very very often, actually; and updating at most once per tick.

zenith wyvern
#

It says you can read and set it inside an IJobChunk

#

You just can't add it inside a job

warm panther
#

That's fine.