#archived-dots
1 messages · Page 205 of 1
He's mixing the object/component model up with an ECS
isnt unitys default architecture called EC ? Entity/Component ? But yeah, ecs is different from that.
No idea to be honest
tis why this channel is called DOTS
You are mixing up things
Entity-Component architecture is different than Entity-Component-System architecture
Unity has always been Entity-Component (GameObject-MonoBehaviour), but it has nothing to do with their ECS implemention which is still in preview and absolutely not being used "by default"
BTW... is there any EC/Entity Component architecture/lib/framework for code only ?
Do you guys think it would be better to make a branching System that has two jobs where only one job is executed or for them to just have their own separate Systems?
DOTS is short for Data Oriented Tech Stack. which has ECS, Burst, etc
yea I know
I was saying there's a reason this channel isn't called ECS
there's a bunch of things that make up DOTS
Oh my bad.
aside from just the entity component concept
not reading high enough
yep
Actually had a question. Is ECD conceptually easier to understand than OOP?
ECS
@ionic sierra it is for me
it kind of has it's ups and downs to be honest, figuring out the right syntax and how exactly to do things can be difficult, especially when ECS is new and theirs a lack of resources to help
but when you do understand how to use it a bit, it does simplify problems(its all just manipulating the raw data) make them somewhat easier to solve and the forced structure helps a lot
I think something that's often not mentioned much is that DOD/ECS makes it within your control (and often actually difficult/obvious) to care about linear memory access. You combine that with threading/Jobs and you have two huge class of problems you're constantly thinking about that (usually) with an OOP mindset you don't much. Restricted to main thread and not caring about memory layout I'd say there are many things that are conceptually very simple. Mostly getting rid of initialization/nullref issues etc is huge imo.
yeah I was thinking the simple fact that things existing is implicit in DOTS and update order is also is so much better than Monobehaviour, what you have to do in Monobehaviour to ensure those things is way more difficult
I'd say update order is a little debatable myself.. I find that to be a somewhat more implicit aspect to ECS that requires a lot more mental overhead than is obvious at first.
agreed, but I still thinks its better than monobehaviour though, I think I remember you having to find an obscure option in the editor to order monobehaviours and then it still might not work
the largest thing for me that is holding DOTS back right now is easy to find and follow simple tutorials and copy/paste code examples for various common situations
not looking for hand holding, but it's super easy to find monobehaviour based "recipes" for when you want to do something you know many others have done
they'll come in time obviously
just the sideffect of being pre-release software
yeah definitely, its because it is so new and everyone is just figuring out things as they go
also I really hope that with a full release we'd be able to really edit the core systems/replace them
Hmmm... Should we decouple networking and databade acess from the ecs itself ?
Having a MovementSystem that has a few codelines in it that define how we send the positions to the client vs.
Having a MovementSystem firing/queueing events and a seperate networklayer that receives those and takes care of sending stuff
What would you choose ? The last is probably more flexible and seperates game logic from networking
To be honest I would really prefer if you wouldn't have those order attributes but rather lay out your systems explicitly
So many times I had to debug that freaking system order
well you can set the order of everything explicitly
they do that for megacity and fpssample if my memory serves me
Yea I can see why people would prefer it. It's a bit tricky, esp when thinking about e.g. plugins/asset store stuff, reusing code etc. I quite like having high level component system groups and only going lower when required.
i have NativeHashMap after remove one element and then add another new element will be add to place where was removed element?
The order isn't defined
Hmmm... im currently moving away from item as entities to item as datastructure. Just wondering how i apply actions on those items then :p
Damn actually each move i do feels wrong. As i implemented entities that act as items inside the players inventory... it felt so wrong.
And now, when i undo this change ( Due to the huge amount of relations ), it also feels wrong
how can i use the new input system with ECS?
@karmic basin of course, but I feel with tools there's less pressure on making them compatible, but I guess if I'm sharing my tools that will change
@karmic basin I like the idea of a web interface, I've actually built that before for a different game, but making the UI dynamic and "good" is a real pain
@karmic basin the base/modifiers are a good idea, but also something the dev could have
not sure of it fits the channel, here it is anyway:
how do I tell a ParallelFor Job that the length and step are defined only for input NativeArrays ? My output array has different length and when I write to it it raises an exception telling that the job is writing to index outside its permitted range
individual job instances won't use the same write index, so it should be safe in that regard
Add [NativeDisableParallelSafetyRestriction] to your output array in your job struct
Thank you so much 
i think having a separate network layer is better
i'd strive to write most ecs systems as if entire game is local, and have a few ecs systems that consume a queue of network packets (sent by your packethandler in network layer) that create entities or whatever else you need, and sending positions would be similar in queue type of way
so you'd have network layer to just send/receive packets on a separate thread and have ecs be able to consume packets without worrying about thread contention, + more cache friendly
I actually dont know if the most recent stuff is bugged though, previous releases worked but I had to remove all the #if/#endif code to make it work again. will require some minor fixes if you also need to do that but regardless it should show in general terms how to get the two to work together
anyone else out there using dataflowgraph and not able to forward output ports to other output ports? im assuming im alone in the void here
yeah it's faaaaar on the todo list on my side sorry
do we have enable/disable component? last time I checked, it was due for 2020 😄 but I haven't looked for a while
Hey everyone! Just learning DOTS and going through the HelloCube examples from the example GitHub repo. #5, the SpawnFromEntity one, has you spawning a prefab that itself has a ConvertToEntity component on it.
https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/ECSSamples/Assets/HelloCube/5. SpawnFromEntity
I was wondering if that ConvertToEntity on the prefab has a runtime performance cost for each entity spawned? Or does the fact that we do DeclareReferencedPrefabs ahead of time (or something like that) precompute that conversion?
Mostly just trying to wrap my head around converting GOs to entities and what costs, if any, are involved at spawn/runtime.
ConvertToEntity does have a (minor) performance cost, yes. If you use subscenes it eliminates that cost since you're doing the conversion in the editor
I'm having trouble figuring out the best way to go about just setting up a system that spawns entities from a prefab on demand (like projectiles, etc.) -- Is that still the best way to go about it, or is there something better?
SubScenes look like they're more for like, putting a bunch of things in the right place and laying them out, in a fixed number etc.
Oh sorry I didn't realize this was on a prefab. There is no extra cost if you're instantiating from an entity prefab
Ah okay. So if the prefab is never in the world, but has ConvertToEntity on it as a prefab, that happens before the spawn occurs?
Looking specifically at these two scripts:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/HelloCube/5. SpawnFromEntity/SpawnerAuthoring_FromEntity.cs
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/HelloCube/5. SpawnFromEntity/SpawnerSystem_FromEntity.cs
Basically as you suspected above when you do IDeclareReferencedPrefabs it will create a canonical version of your entity that's already gone through the conversion process
When you instantiate from that entity there's no conversion happening at that point
i figure it out but thanks
I'm not sure if this issue is limited to DOTS, but i tried searching and came to nowhere
Basically i built the project for android and am experiencing major fps drop (<20fps). Strange thing is i used an fps counter asset and it's still showing 60fps...
In the editor same asset shows a consistent 200+fps
PC build doesn't have that problem either
build in dev mode and autoconnect profiler
will do
Is there a quaternion helper class that anyone has made that contains some of the functions from Quaternion like Angle and FromToRotation?
ah weird
well if it was gpu it'd still show up in cpu profiler as waiting for gpu
seems like your actual framerate is fine, how are you experiencing the drops?
maybe your camera/physics movement are updating at a lower rate?
i switched to opengles to see what's going on
and obviously there's something going on
if so then the framerate would drop on pc build as well
oh damn seems i was wrong about gpu showing up in cpu
what does it say when you click the gpu usage view
when i was using vulkan?
huh weird
https://answers.unity.com/questions/1233192/game-running-really-slow-on-android-renderforwardr.html i did find this, gonna try
Thanks, yeah I use AxisAngle and other methods from that Unity.Mathematics, just curious if there was one with the methods found in Quaternion like Angle and FromToRotation to make conversion a bit easier when converting code to dots
@hollow sorrel Glad to hear that ^^ Then im gonna implement a seperate network layer. This should be much cleaner
Meanwhile im still struggling with item as entities vs item as oop.
My items should also listen for certain events. Like when the player attacks to apply unique logic. Or they should do something while they are in the inventory. Like showing the player where mobs are. This all speaks for item as entities, because we actually need to loop over them. Could also be implemented using OOP. But i mean... when its also possible in the ecs, with quite the same effort. Why should we use OOP then ?
Damn those decisions break my neck. On the otherside its very important, because such stuff cant be changed easily. Especially not if we persist items.
Oh ok I see, user-made helpers
Can't you achieve a from to rotation just by multiplying the quaternions ? (My quaternion-fu is weak, sorry if that's dumb)
and quaternion.Angle gives degrees IIRC, yeah I guess you have to write your own helper to convert
Also looks like there is implicit operators from that doc
@stone osprey nothing wrong with having stuff outside the ecs, you can still call that data from systems even when it lives elsewhere
i prob wouldn't have items listen to events, but instead have a system ask for items (even if they live outside ecs, can ask an OOP class to look up items that do player attack logic or whatever)
alternatively you could parse the items and create entity copies that hold the data you wanna loop over
@karmic basin yeah, I actually have them but was hoping for something by unity so that they would match exactly to how they do with the Quaternion methods, since quaternion calculations can differ sometimes
Yeah I see, like XYZ vs ZXY
Did you dig the official samples ? sometimes they write some helpers for themselves
low chance though :p
maybe you'll find a blog post or a gist from random people :p
🤞
@hollow sorrel That makes sense ^^ with listening for events i mean the following example : Player attacks -> Item in hand gets marked as OnHit -> SomeSystem can execute special logic for that item. For example spawn a lightning or create a shockwave ^^ that was the plan. Of course this is also possible in OOP, but its not that flexible...
Entity{ Item, OnHit, OnHitSpawn } for example.
i'm so confused
does this mean that .shader files aren't supported?
So i think i found a good rating schema for entities vs oop. When it should be kinda flexible and "future" proof it should be implemented as an entity. And if its mainly data or not that flexible at all, then it should be implemented via OOP. In my case inventory-items are flexible, Some are equipable, other not, some can act as weapons, others not. And some of them should do something every tick, while others only should do something when the player attacks or gets hit. Thats actually a great use case for an entity, because we can decorate the item. However, if we have items that have a predefined set of actions or a defined structure... then it would make sense to implement those with OOP. Another great example are messages. I would never, ever implement messages as entities. Because they just arent flexible. Does anyone here agree with that entity vs oop statement ?
you can use Blob assets for fixed data too though
and strings don't really work well in ECS anyway
@pliant pike Thats right ^^ I just meant as a general guideline on when to implement a feature using entities or some OOP class.
Because i lately stumbled upon many people recommending to implement items for example via OOP. Many others love using entities instead
I don't know I don't see much point in rules like that, just do whatever you can in whatever that works for you
like I'm doing items with scriptable objects converted to entities, its just what works for that project
Because of the golden hammer antipattern. Which basically says that you shouldnt enforce a certain architecture ^^ And thats exactly what i did in my case. I actually only used entities. I even used entities to calculate loot drops, i had a Loot Drop Entity with one component :p Thats just to atomic. But of course, you can go hybrid, pure ecs and both work
I would have thought entities would be perfect for that 
I also implemented items as entities because i love marking stuff : Entity{ Item, OnPlayerAttack, OnAttackSpawnCow } just so much flexibility. But then people recommended to do that in oop ^^
Uhm... yes... totally great 😄 Entity{ CalculateLootDrop(LootTable), OnLootCalculatedSpawnItems }
We shouldnt forget random number generators like Entity{ GenerateRandomNumber, OnRandomNumberGeneratedPrint }
I always generate my numbers like that
Hey guys, I've been rethinking my floating health bars and I don't like the fact that's it's a 3D element (quad) because it's not rendered on the UI and can be covered by 3D objets. Is there another way in DOTS to have a UI element "following" a 3D object? 🤔
I dont think there is in DOTS, you can just get the entity data in a monobehaviour easy enough to use normal GUI stuff
Oh, or (that might not be DOTS related) is there a way to render some objects on top of the world? Maybe another camera?
that's like z buffer stuff, I don't know if you have access to that sort of thing with hybrid renderer
I'm thinking to do a second camera that renders only the 3D UI on top of the main camera
that's basically how UI stuff mostly works anyway
Exactly :p but no chocie to have another camera because it's 3d elements
which rp are you using?
Hybrid
I mean builtin, urp or hdrp
oh sorry, urp
cool - urp has something called render features - in the pipeline asset you can define that e.g. objects on a certain layer draw at the end and even write over the depth buffer
not 100% on how this works in conjunction with hybrid renderer
but may be worth looking into
you maybe want to remove it from your opaque filtering in the top dropdown too
How can I go about doing something like this without the error? :/
Entities.WithAll<Restore, Stat>().ForEach((Entity ent, ref Current current, in Maximum maximum) =>
{
//Can't GetComponent a component already in the lambda
current.Value = GetComponent<Current>(maximum.entity).Value;
ecb.RemoveComponent<Restore>(ent);
}).Schedule();
yeah, you can't do that
It sucks tho cause I have a lot of nested entities
Yeah I guess I'll do an EntityQuery
Still hoping for a multi-depth foreach at some point so i can query component in unique children, not sure how that would be implemented but I have to create so many container components just to reference the child entity then GetComponent
yeah I think that's the only way if you want to compare different entities within the same component 🤔
Something like this would be a godsend
Entities.ForEach((Entity ent) =>
{
ent.ForEach(...)
}).Schedule();
I dont think that will ever happen to be honest
Am I approaching the problem wrong then? I feel like there should be an easy way to query a child 🤔 I feel like everyone at some point will need entities within entities and compare the values between different levels
there's a whole thing about flattening lists, I havent delved to much into that personally though
DOTS is all about single arrays and churning, through them, you convert whatever data you have into a single arrays and let it do its work
What about a sublambda then like (pseudocode)
Entities.ForEach((Entity ent, Current current, Maximum.entity.Current maxCurrent) =>
{
}).Schedule();
idk it's just like the 5th time I stumble on this issue and I'm sure it won't be the last
I feel like my data structure is rock solid, but it makes querying harder...
Just don’t pass in Current into the lambda and use GetComponent with ent
Can't write with GetComponent :/
I need to write into one's Current with another's Current
I could SetComponent(ent, new Current(GetComponenet))
But I feel like that's ugly?
Yup that basically but you just need to call WithDisableNativeParallelRestriction (or whatever it’s called) as Unity can’t guess it’s safe as you could write to any entity
It makes more sense if you’ve used IJobChunks
So something like this?
Entities.WithNativeDisableParallelForRestriction(typeof(Current)).WithAll<Restore, Current, Stat>().ForEach((Entity ent, in Maximum maximum) =>
{
ecb.SetComponent(ent, new Current() { Value = GetComponent<Current>(maximum.entity).Value });
ecb.RemoveComponent<Restore>(ent);
}).Schedule();
Basically yea I think so
are there any ECS examples I should look at for Unity? Ive been using Bevy (the open source engine) to get familiar with the paradigm and was hoping to move over to unity
Resources and forum threads are pinned in this channel top right.
also I tried the example project on Github and it wouldnt compile due to a missing function within the Collections class... is this due to my engine version or was it something different
Also thank you for the quick response
Make sure you have a recent version of Unity installed
I'm not sure that's the problem but I'd recommend using 2020
aight cool cool yeah it kept saying that theres an issue with the Collections script and wouldnt run the example, but ill try it out with LTS 2020 and see if that fixed it
everytime i code in another language besides Rust, i start missing Cargo... it does such a great job managing dependencies
I have unity physics in my project, but getting error when trying to reference typeof(EndFramePhysicsSystem)
and all of a sudden VSCode can't find physics, entities, etc
packages are all in project though...
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using Unity.Jobs;
using Unity.Physics;
using Unity.Transforms;
[UpdateAfter(typeof(EndFramePhysicsSystem))]
public class BulletCollisionEventSystem : JobComponentSystem
{
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
return inputDeps;
}
}
what was working 15 minutes ago, now that I added this new collisionsytem file is red all the way through. If I remove it, my old project works but no access to collissions and VSCode still broken
fixed the editor at least - added using Unity.Physics.Systems
but VSCode still trashed. So odd
Latest entities requires at least 2020.1.9
Hi all, I'm looking for any existing DOTS samples that would make good network tests/samples/documentation for my networking package
Its mainly for RTS/Strategy/Management type games but I'm not yet up for building a whole game to test the Networking
If anyone has any suggestions please let me know
I'm planning on starting with the official ecs samples ( https://github.com/Unity-Technologies/EntityComponentSystemSamples ) but im hoping theres something more complex out there that would make a good test
i found the root of the problem and it had nothing to do with dots
turns out i was basing my whole gameloop on audio.dspTime and that thing for whatever reason doesn't update like i expect to on android
whats the git to import unity Physics preview
Im currently on the latest hybrid compiler and its saying that GetEntityQuery is deprecated... whats the new method for this
@ocean tundra there is the asteroids sample, could be a nice and simple 2 players testbed
com.unity.physics
Though GetEntityQuery might be from com.unity.entities 🤔
anyway Physics package is kept up-to-date with Entities, should resolve dependency to latest version
Hmm that might be the issue... cause I may have switched it to the new Havoc Physics system and not the new Unity Physics system
Though they have the same methods, no?
API should be 99%-ish the same yes
at least that's Unity's promise
I didn't mess with Havoks because its licensed stuff
Hmm... yeah Rider is highlighting GetEntityQuery as wrong so it might be the fact that I switched everything to the latest version of preview
( I really wish that there’s a feature to see where the deprecated methods and functions are from even if you can use them, like in rust)
That’s a preview package right
Lemme check
The changelog can somehow help with that
But be ready to dig yourself in the code to check where things are
DOTS is not ready for everyone
It's for the ones who like to learn from themselves
So yeah it lacks a lot on these topics
System Base isn’t in the registry when I search... do you happen to know the git for it
SystemBase is the new class to inherit from to write your systems
I’ve worked with the Bevy and Amethyst ECS engines in the past so I’m familiar with ECS as a concept
Yeah it’s inherited from systembase
Oh ok
what's the error ? a namespace one ?
yeah need to solve class declaration one first, others will resolve tehn
What error Rider gives you for the class declaration ? missing namespace ?
that it doesnt contain a parameterless constructor
which I dont think is a major issue
it might be a package that im missing but idk
That's not a package issue
you don't have Entities package ? 👀
wth do I not
you can double-check with the package.json file to make sure
but yeah you def need ENtities package to go further 🙂
We don't see the top in your screenshot but probably be interested in the Collections package too.
Anyway,one issue at a time I guess:p
yeah its listed as a dependency
"dependencies": {
"com.havok.physics": {
"version": "0.6.0-preview.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.4.1",
"com.unity.collections": "0.15.0-preview.21",
"com.unity.entities": "0.17.0-preview.41",
"com.unity.jobs": "0.8.0-preview.23",
"com.unity.mathematics": "1.2.1",
"com.unity.physics": "0.6.0-preview.3",
"com.unity.test-framework": "1.1.11"
},
"url": "https://packages.unity.com"
},
"com.unity.burst": {
"version": "1.4.6",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.2.1"
},
"url": "https://packages.unity.com"
},```
This one I give you the answer already, can be tricky to find the first time, you want also the Platforms package, with the one(s) you're interested in. WIth DOTS you don't build the original way
https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/install_setup.html
if its a dependency for one package, it becomes a dependency right
well this Rider dependency manager looks like a JS one 🙂
my package.json is flat and explicit
manifest.json file
jeez I'm tired
sorry about that
oh i was looking at the packages-lock.json for my project
yeah my bad 100%
shoot yeah its not listed
yeah but the package lock has it with last version, should be good 🤔
I don't know, yeah try with explicit declaration in the manifest
Oh shoot I’ll have to look up how to type into the manifest file
I thought I’ll just be fine using git and the package manager
Lol
What does it look like in your manifest file
Wait can you really constrain an inherited class in c# ? 🤔
yeah, I've never saw this use case, so don't know if that actually make sense for the compiler
Try to remove the constraints on the class and see if Rider still complains
I think it’s limiting the Type parameter
I use it in Rust all the time so I thought it was something normally part of C#
I'm not sure you can do that on a class that does not constrain type in the first place, but maybe I'm wrong 🤷♂️ just never tried myself
IMO that would explain the parameterless error, but again, can't tell much
Well... my IDE doesn't complain when I try so looks like it's okay
so GetEntityQuery shows up for you
hmm
what package does it say its a part of
or like the reference
hmmm really weird
yeah i have the same thing
I just wanted to double check
you're also on 0.17 right
yup
im going to repull the ECS examples again and see if i can find a fix for my project
Sorry I couldn't help
Its fine lol just normal Unity jank i bet
I don't know if anyone knows but I presume int entityInQueryIndex I can use that to correlate the index with an external entityquery?
to answer my question myself, it does seem to work the external nativearray componentdata on the same entity does correlate or the lists are just kept in the same order either way it works and hopefully nothing changes to break it
Yes if the query in the foreach matches the EntityQuery they are guaranteed to align afaik
I mean they don't exactly match they are different componentdatas just on the same entity
I'd highly suggest finding a more stable indexer if you can, or pulling the entity array async into a native array
I dont trust unity's auto gen stuff too much as the apis change
yeah that's what I was wondering
but surely the separate components on the same entities must stay in the same orders 🤔
I do like to see all the green anyway
its 1million entity's
just a really difficult test, managed to make a 30ms single thread into a multithread 6.5ms job
good job!
it's fun, I do enjoy messing with DOTs
Where can I read a breakdown on how entities are stored in memory?
Found a thread here.
https://forum.unity.com/threads/ecs-memory-layout.532028/
I was trying to hook up Input.touches to a system in ecs but it isn't supported by the burst compiler. Is there an example of a mobile control system in ecs?
also trying to buffer a entity deletion in a foreach, but .ToCurrent() isn't working
It's AsParallelWriter now
thx
The issue with asteroids is its already MP and its a bit too fast gameplay wise, my networking works best with slower type games (rts)
Thanks for the suggestion tho, maybe ill try making it a mini RTS at some point
I was looking at the wrong version of the ecs manual this entire time lol
im dumb
is there some way of doing this CellBDLayerToCalc LayertoCalc = HasSingleton<CellBDLayerToCalc>() ? GetSingleton<CellBDLayerToCalc>() : null;
@pliant pike replace null with default??
or change CellBDLayerToCalc to CellBDLayerToCalc?
making it nullable
default works, nice thanks
anytime you go to use it you will need to check HasSingleton again
as default assigns it a 'default' value, so you may go to use it and have values you dont expect
default might work anyway, if it sets the values to zero then that's what I want
In a singleplayer game... would it make sense to use DOTS to create the player?
Or should i say... would it make sense to use DOTS to create a single entity or should i just use a gameobject?
depends on how much work your willing to do
DOTS is very much a preview and work in progress
@small arch yea it depends tons on the game type and how much work you want todo 😛
DOTS is best for games with LOTS of the same stuff, eg RTS (basically everything is a unit or buildings)
but you can get some awesome wins for things like huge open world rps too
if your whole DOTS use is just a single entity,,, then that makes no sense, all the wins with DOTs come from having as much as possible in DOTs world
buildings?
so placing buildings with code instead of putting them down in your map with the editor?
and that would increase performance?
oh I was meaning that in RTS you can break pretty much everything down to 2 things, units (movable) buildings(not moveable, also trees and stuff)
thats really great for DOTS
can process all moveable things at onces
then all unmoveable things
but if everything was very uniuque then you lose out on that
(also this is a high level example 😛 , even units and buildings would have common things, eg health that you can process all at once
entityManager.SetComponentData(myEntity, new FallingData
{
fallSpeed = entityManager.GetComponentData(myEntity),
lifetime = 10,
falling = true
});
how do I get use component data introduced by a prefab while only setting falling to true.
can you rephrase the question, not sure i understand
when I setcomponentdata to new fallingdata, it sets the old fallspeed and lifetime to 0 if I don't do anything to them. I want them to keep their previous values while only changing the value of falling inside the falling data of the entity
it seems to overwrite the old fallingdata in the entity
it's because your creating a new FallingData
yah how do I just update the old one?
you could just get the old data, change the values you want then set them in the componentdata
how tho....
EntityManager.GetComponentData
@crude mountain I think you should be using entities for each, is this already in one for something else?
yeah you can use just SetComponent or GetComponent
this is in a entity spawner monobehavior
Does anyone know how the DisableRendering component tag works frame by frame? I call it and it takes 3 frames for an entity to disable the renderer. Is there a more precise way to disable the renderer on an entity?
@olive kite Are you using a command buffer, that may be 1 frame of delay
i imagine another frame where some internal system state is updated somewhere
Yes I am. I'll try to complete the job and add the tag right then, see if it has any impact.
I think I did something stupid, hold on
yeah because it's a laser projectile with emission
and you can totally tell it goes way through
but as I should always assume from the start, I did something stupid. It had a child object
oh yea
that was my next guess
takes a bit to propergate down to children
really annoying
isn't that the same as new FallingData?
yeah just do the same thing right before
thanks roycon for the help
fvar .... beofre set component data
?
FallingData fvar = entityManager.GetComponentData<FallingData>(myEntity);
entityManager.SetComponentData(myEntity, fvar
{
//fallSpeed = 1,
//lifetime = 10,
fvar.falling = true
});
i usually just do setcomponentdata(myEntity, new FallingData { stuff = fvar values or new values }
sorry @crude mountain i recommend you find a C# tutorial before touching DOTS
entityManager.SetComponentData(myEntity, fvar); that was right
@ocean tundra lol XD you might be right. I do know how to program, I am just not used to unity's c#.
@ocean tundra you mean like this right?
I am having trouble with terminology, but I do know how to program XD
I swear
its a learning for everyone :p
but look into structs vs classes (objects vs value types)
ummm the ref and in keywords
maybe generics if youve never used them before
I have so many tabs in my browser. XD
oh and lamdas for when you use entities.foreach
yeah idk whats missing in my project, but for some reason the method GetEntityQuery is not showing up
its a protected method within the CompnentSystemBase class but thats inherited by SystemBase, which should allow it to be a public method
or to be called like that
oh wait it fixed itself
idk what up
😅
yayy now it works
I guess i showed the IDE where the method was by doing it that way
and then switching it to the actual method
How can I set the TransformSystemGroup systems as a dependency to a custom system that follows it?
so in system thats AFTER transform group
in OnCreate GetExistingSystem Transform....
oh
i see
Dependancy isnt public
it really should be...
agreed lol
Is anyone here experienced with shaders and hdrp
I think it's causing some issues with my ik stuff
so the automatic dependancy stuff should work if your using components and entity querys
I messed up real bad
Yeah I am using those
but you said its a componentsystembase...
Have you ever gotten this
im not sure if that has a same dependancy stuff
I will double check, it was just a hunch and wanted to see if setting it as dependency would fix it
in the systems window it shows system dependancies
hmmm but you must be using some of the same components?
either reading from them or writing too them
that combined with [UpdateAfter] should let the auto dependancy stuff work
i am reading from localtoworld and read/write to position and rotation
yeah i have update after as well
so next frame LocalToWorld will be updated to have that position/rotation
hybrid renderer stuff reads from localtoworld i belive
right, that's why I wanted to do everything after transform update, so i can do my IK calculations and save the position/rotation, then next frame it updates the LTW before I pull again
yeah i think that's correct
I wouldn't expect to have issues, but I have the exact same system in a system as a normal GameObject and seeing inconsistencies
yep
i think you may actually want a write group to prevent localToWorld being updated by the auto systems
and instead you write to it
i don't modify the LTW directly, just rot and pos
yea but maybe you should
yeah I've thought of that, was hoping I could get the engine to do those calcs for me 🙂
maybe , yeah
rot and pos are easy for gameplay stuff, but gameplay writing and then ik writing to it could get all confused
hmm yeah. Maybe I can try in lateupdate
i've done that in the past with IK and seemed to work well
but not in dots
ok yeah let me try that
works great now in late update for a few seconds then goes wacko
are you still writing to traslate/rot?
my guess is you are, and the caculations are componding and building on each previous frame
Yes, but I am reading from the LocalToWorld each frame, shouldn't that not happen?
if i run the same calculations based on the LTW
no cause the localtoworld is written to each frame as well
right,
oh sorry,
for this system, there is nothing else influencing the pos or rotation
i think you need to break the write to locatToWorld using a write group
no physics or anything, jsut a proof of concept
Translation/Rotation ===> LocalToWorld === YOUR IK ===> Translation/Rotation
I guess I don't comprehend how it could become out of sync in late update. when I update the rot and pos, doesn't it recalculate the LTW prior to running and setting those the next frame?
since they both run each frame
i mean, obviously i don't comprehend haha, i think your right about what is happening
so your writing to pos/rot then next frame it starts with those values
you never reset back to startpos
but the calculations are done by the current position to the target, not the original position
and start from the LTW rotation and position
but your current pos is always changing
😛 my brain....
it is a bit more complex as a whole, considering iterations and saving those values, but at a high level, just running this each frame i don't get why it wouldn't
why it would rather, cause de-sync in the loops
i know, i feel the same with this problem haha.
i think that the behavior would make sense if it was doing what you are saying
just trying to understand a little better how it could happen
forgot to include this line under it quaternion fromToRotation = FromToRotation(toLastBone, toTarget);
then i multiply the rotation by that
but i know it's not explained so wouldn't expect it to be too readable
but my gut feel is changing pos/rot in your IK means next time it runs you will be caculating from a different pos
precisely, intended to do such. I'll focus on that area tomorrow after some sleep, I appreciate your time, thinking it through helps
will there be a speedup for Burst on an M1 with an apple Silicon version of Unity or is it just going to be x86 intel for the planned future
I would expect there to eventually be burst apple silicon support
@ocean tundra couple weeks back we were talking about custom bootstrap
If you ever have a problem with it...
the solution for me was to disable managed code stripping
in the custom config:
theres some magic reflection finding all bootstraps
yeah
I think I will just leave that off haha
it causes more than one problem
I had it set to medium
I could try low but why risk future weird bugs
oh interesting
maybe at the end of my project life span I can look into it haha
but during early dev I doubt it's worth the potential pain
depends on the size difference i guess
Guys, how you do object pooling with hybrid entities?
@frosty siren Honestly dont think the built in hybrid does pooling
i would do it myself
its a bit of work tho
- Create a IComponent mirroring the gameobject data you want
- Entities.Foreach it WIthNone<SystemState of your component>
- that foreach creates and attaches the components (this is also using the pool)
and cleanup is just the reverse
I'm asking how u do it meaning how you implement your pooling solutions with hybrid entities case
so your already using hybrid?
yes
subscenes?
not yet
yea i cant think of a way to use hybrid to do it
wait
well
if your hybird components are not directly attached to your entities
instead you have a intermediate entity
that may work
super hard to explain
so think of a fire sword
sword entity has the rendering components and other data
and youve attached a hybrid particl emitter to it
yeap
i dont think you can pool that
instead detach the particl emitter
so now its 2 entities
as i do it for now)
now you can use the Disable tag on that entity and use a ISystemState component to track its 'attached' status
yes, i do exactly this
😛 great minds
why?
i use disable tag as you suggest, and to track "pooled" entities i use ISharedComponent which refer my prefab entity. So when i what to instantiate my prefab (hybrid) entity i firstly ask "are there any free same entities?"
to ask it i create query that track those entities
but all this stuff is only for avoiding gameobject allocations
and it looks a bit unperformant
IShared is probably the wrong one, its use case is more like Many entitys => 1 effect
ok, so how to find pooled entities?
and when every you change the IShared you will change your entities Chunk
it never changes it's shared component
so you will need a ICOmponent Tag? on all your entities
it just CreatedFrom { public Entity }
Then you can use a entitiy query to find ALL your effect entities
then next you need to know free VS not free
so you could use the built in Child/Parent components for that
that will also get you free position following
i think use some FreeTag or something is better, cause you already got entities that free and have no need to ask
yea a tag is another option
basicly you just need to boil it down to raw entity queyrs
But using Tag producing new Archetype and using Shared component producing just extra chunk
then in some system you can do FreePooledEntities.IsEmpty (or count == 0) to spawn a few more
yea so tags have some optmizations comming
but not here yet
you can either dev trusting they will come and be released one day
yeah, basically i do exactly the same
or change to using a bool inside your component
oooooohhh man, 2021 is here but i see no sprite renderer
and other basic stuff
haha exactly
so i completely lost my hope
and theres other 'core' optmizations discussed that also have no sign of releasing
yea sooo slow latly
all my need to use hybrid in world is because no DOTS sprites
yeah, but i'm love to use shader graph and other modern tools, so i'm afraid to go deep and use not built-in solutions
yes and maybe one day there will be DOTS sprites and i just run my game and it will no more hybrid entities automatically 😄
hope in this decade
Yea can't wait
I just want them to get faster on releases again
And maybe more communication
especially this
many people think dots is dead
yea exactly
it better not
i love it
and im planning many tools
would like to actually release them sometime 😛
I stg if they kill dots lmao
I persuaded my former colleague from work to switch from his own ECS solution to DOTS. So it better not be dead, yeah 🤔
i honestly dont think dots will be killed
its just slowed down a bit as focus has been on stability
Also, covid maybe?
yea i forget about covid
im guessing they realized it's way too early to be hyping up dots so they went to 0 communication so they can make proper marketing push later
same with games that get announced too early
huh weird
i remember reading about burst being deterministic across same architecture (but not cross-platform)
😛 i just saw that post too
yea
i've just always been planning that its not determistic
hence my networking tech is server client 😛
yea but there's people planning on it being deterministic across same architecture, due to whats been said on the forums by unity
yea
@dusky wind did you ever continue with that ecs rollback game
not great communication there
its kinda strange how slow dots is without burst
i guess i dont understand the subject enough and am guessing you can have determinism without burst but just running stuff without burst feels worse than regular gameobject-land
i'm pretty sure its faster then just game objects
but yea feels soooo bad
especially physics
just thought maybe because a large part of gameobjects is the native c++ stuff behind the scenes?
im positive in some cases its worse because just like 5-10 pure dots characters without burst is a slideshow 🥲
honestly i havnt tested enough
Work got busy
Still working on it
Just don't have time for it currently
@gritty bane i think thats been released
There's no DOTS/ECS-friendly way to do a SpriteRenderer yet, right? If I want 2D am I best off doing it with planes for the moment? From what I've gathered the SpriteRenderer isn't supported without a companion GameObject.
no built-in way no but there's plenty of ways to roll your own (or use someone elses that rolled their own)
if you're not using Tiny, yeah I just use SpriteRenderer + companion GameObject & Plane for many elements
Both together, or one or the other? Wouldn't they be mutually exclusive?
(SpriteRenderer + companion GameObject) or (Plane), that is.
one or the other, sorry it's not very clear. For things that are have different animations I mainly use SpriteRenderer w/ Companion gameobject. But for something like a projectile - I just use a plane + instancing
Gotcha yeah, I guess I'll use a plane for now then, won't be so bad.
Thank you both.
yea if you need to grab like the UV's so textures fit nicely to the plane, I just use Sprite.DataUtility to grab the UVs from a sprite object so I can set up the plane uvs properly
Ah yeah, I need to think about that. Okay, so take a spritesheet and then, what, set the UVs as a PropertyBlock or something?
well I actually just make my meshes procedurally
Ah, okay, so do you like feed in a spritesheet and metadata and it pregenerates all the meshes you feed into the MeshFilters?
Trying to maximize reuse.
yea something like that
Sounds good, I'll try that out. Thanks!
@gritty bane Dam this was driving me crazy
https://docs.unity3d.com/Packages/com.unity.burst@1.5/manual/docs/ModdingSupport.html#overview
also i intend to release a proper ECS modding library,
Current focus is Data modifications (eg marking a prefab as moddable and changing values like Attack/Health ect)
Next is visual changes, Models/Materials (Unity Assets)
Finally is code based mods, New ECS Components + Systems and some sort of 'simpler' API
wow wasnt expecting any real acknowledgement for mods tbh
So if I want to use Rust Lang ( and make Dylibs from rust) along with the Burst compiler, would I have to use 2021 Unity or can I stick with 2020
lots of people ask for mods in normal unity
but its def not a huge area
@gritty bane Oh dam, I didn't know you were talking about rust Dlls
i don't believe that combo would work
Burst works on C# dlls
you 'might' be able to use old dll imports to run code in the dll
Oof time for a rewrite of code into c#
Oh so your saying that it might be possible to run a dll that’s running code from a rust dll
Interesting
um no the other way
unity C# could dll import into rust code
it def can into C++ code
Looks like you can
but that transition from managed c# into c++ (or rust) is slow, thats one of the issues with normal Unity (lots of underlying unity is C++)
Oh that’s a new guide.. all the guides I’ve found were at least 3 years or older
was just a quick google
no clue how revelant it is
or if its even worth having a mix of C#, C++ and rust
I had my eyes on this one and I have no idea if it’ll work with burst
im basically 100% sure burst wont work with anything other then c#
It’s probably not ( besides very niche things) but it sure is cool to get languages to talk to each other
like the first line of burst "Burst is a compiler that translates from IL/.NET bytecode to highly optimized native code using LLVM."
and as far as i know rust is not a .net language
What if you already have highly optimized llvm code from rust 🤔
no burst takes the .net bytecode
and makes something better
the rust compiler would be doing the same thing and not outputting into .net bytecode
Yeah I know ik I was joking lol
But oof I have to rewrite some of my rust files into C#
Good thing there’s Structs and type generic constraints in both languages
Only thing I’m missing is data typed enums
This may be a silly question, but when does the Burst compiler actually run? Is it at startup (like C#, JIT) or is it part of the build packaging process?
So in editor it runs when you call a burst method
I believe it's ahead of time compilation.
Hm. There's no way to defer it in builds I'm guessing? I'm thinking about for maintaining accessibility to injectors like Harmony.
yea so in editor its 'jit' and in builds its AOT
Since we're on the topic of modding.
@vivid lotus I think no, as it needs a ton of platform dlls /tools
C# has enums, but not the same way Rust and Swift have enums... they allow you to store things in the enums like thisrust pub enum Cell{ Text(String), Number(f64), Formula(FormulaCell), Empty }
C# doesnt have this right (unless they changed it)
Ah, shame.
No it doesn't
I guess if you wanted your burst stuff to be moddable you could make it all as a plugin and release the source for that, but that's a lot of source to release, and there would be no compatibility between mods.
I was pretty blown away by the enums when I learned rust, it's awesome
@gritty bane oh yea that would be nice, C# is just numbers/chars, Ive seen attributes used to give extra data on a enum, but that means reflection
or a dictionary could work
You technically can with c#. Just gotta smash the data into a single integer value and use bit shifting to get readable data out. That's what I did for a date enum in a very memory crunched program.
You can do it with unsafe C#. Those enums are just discriminated union types.
It's still not the same thing. Enums in rust can have their own functions
Extension methods?
Unsafe and burst, hrm. Might be a bit tricky.
@vivid lotus yea moddable code with burst is going to be tough, my plan is making the mod makers install unity and all the tools and provide some sort of package to compile it
No clue if that helps
im sure mod compatibility can be done, but need to figure out a good mod API
That's what we were discussing. 😅
you can implement traits for a enum like this in Rust, which makes it inherit methods:rust impl CellADT for Cell{ fn cell_text(&self) -> String { match self { Cell::Text(string) =>{cell_text_spaces(string.to_string().borrow())}, Cell::Number(number) =>{cell_text_spaces(number.to_string().borrow())}, Cell::Formula(_form) => {cell_text_spaces(&self.get_value().unwrap_or(0.0).to_string())}, Cell::Empty => " ".repeat(10).to_string(), } }
yup i posted it earlier 😛
Oh yeah, it isn't going to be at the same level (or with the same compiler optimizations) as rust enums, but you can get part of the way there with unsafe C# and explicit struct layout stuff to create discriminated union types (which is what rust enums are under the hood).
@robust scaffold Im planning a modding package for unity, so def read all that 😛
Honestly, my current very tentative plans for modding is making the players (if any) put in PRs to the github. Adding third party dlls and making sure it's all safe and no arbitrary code execution is such a pain.
I feel PRs to Github are a bit tough for mods
if its a open source game thats different
True true, Im always running on the assumption my game will be open source and on github. Never in my plans to go private and commercial.
My plan is a mini package system, like unity packages
Full with dependencies and advanced features but with 'simple' use
a basic mod is a mod definition file and then just plain JSON edits of your moddable entities
more advanced will include a unity package (maybe with addressables?) containing models/material/sounds (unity Assets) that are linked via more complex json files (http://jsonpatch.com/)
finally im still figureing out code based mods, full on new ECS components and Systems actually dosnt seem too hard, but also overkill for mods
I'm going to ask a dumb question. Is the Hybrid renderer required when using ECS, or is it a byproduct of the Hybrid-ECS conversion process? If I'm dynamically creating my assets and won't rely on conversion from gameobject to entity at runtime, can I ignore the Hybrid renderer? Should I?
you can use ecs without hybrid renderer and: create your own renderer or just create the rendermesh yourself, or use gameobjects to render things and keep ecs as a hidden layer
but the latest hybrid renderer docs show how to create a render entity from code which might be what youre looking for
Is the Hybrid renderer basically a system which automatically renders any entity with the prerequisite components? Whereas by eschewing the
Hybrid renderer I'll need to manually render each entity? Is that an accurate statement?
yea that sounds right
you use the Graphics.Draw** to render if your not using hybrid renderer
Okay. Thank you. I'm clawing my way towards a modicum of understanding.
dispite the issues with Hybrid Renderer i would still try to use it
unity will keep working on it and eventually it will be ok
I'll look at the Hybrid Renderer documentation for creating an entity from code, as suggested by thelabaron and see if that gets me close to where I want to be.
Thanks all.
if your creating via code theres new helper methods
as hybrid renderer requires a few different components
so - I am a new Unity dev but I have experience coding. I love ECS/DOTS but almost every time I ask questions about it - people are unsure of the future of it. Is there something obvious I don't know from the handful of courses and tutorials I am going through?
@sturdy rune theres just been no real progress/communication for a bit
some of the devs are vocal on the fourms with issues
and questions
but actual long term plans/goals/timelines there not been much
Interesting. Technically I love the concept
Am computer engg and it really feels good to write in ecs
I noticed it doesn't have animations
But just in the course I am using
Perhaps as a beginner it doesn't matter - as I learn I will grow into it
With it actually
it has animations but they are super hard to get working atm
Ah. I am using 0.10 I believe. Bit older but concepts are great. Do collisions get better in newer versions?
not sure
thats physics and i dont use it much
mainly as a querying system atm
but you can plug in havoc now
that might be better
https://github.com/Unity-Technologies/Unity.Animation.Samples @sturdy rune in case youre feeling adventurous
just realised that statemachines in animation still only exist as test cases and not necessarily anything concrete enough for a working example(as they dont have any). hopefully the next slew of updates brings more of that out. spent a lot of time just spinning my wheels with this package so far 🥲
Haha. Well the last update I saw was jan24 so really not that long between.
i want to enable/disable chunks of entities instead of individual ones, and it seems like adding Disabled as a chunk component doesn't work
am i missing anything? is there any workaround?
yes, it shows up in the entity debugger
Hey guys, should I ask about Unity Physics here? Or directly in the physics channel?
I'm searching for a GetCategoryBitset (or at least number) functionality. Too not hardcode the layer used for my raycasts.
I'm searching around PhysicShape, because the editor know about the layer names, but I can't find the asset loading :/
do you mean the collisionfilters?
Yeah and to find the right category value, like if I was using LayerMask.NameToLayer.
I dont know if there is anything like that but theres the PhysicsCategoryTags for constructing a collision filter
var filter = CollisionFilter.Default;
filter.CollidesWith = collidesWith.Value;
filter.BelongsTo = belongsTo.Value;
return filter;
well I can simply add the asset into my settings, but I don't get how unity load it from anywhere 🤷
So just to be clear for other people, I'm wondering if there is an "utility" to get the category tag of Ground in this example. This asset can be anywhere but Unity will find it so I don't know how. But for now I'll just add it to my settings and query the category tag from it.
i dont think there is? you should ask on the dots physics sub forum because im almost positive they will answer this(and there should be a way)
Right ! Thanks 🙂
@gusty comet so if you can get the asset there's helper methods/properties on it
But getting the assest is the annoying part
But also it's only meant to be a editor helper I think
Might get strippedm from builds
Yes so manually referencing the asset can lead to use another one than unity use
maybe
check where the code is
if its in a Editor folder or has #If Editors it will get stripped
I don't think there is a need to have several of these assets, but you know, to get a clean structure
I read the rest of the chanel, i havnt really got a good answer for not hardcoding your layers
Tried but failed x)
all mine ended up as consts in a file somewherre
I'll tell you if I got an answer then ^^
I've started with lots of code gen recently and that might be a good answer, just code gen out a file
i must have been thinking about something else physics layer related sorry, no methods or anything usefull on it
I would say just stick the CategoryNames asset in a Resources folder. Then you can access it with var names = Resources.Load<PhysicsCategoryNames>(nameOfAsset) and build your own NativeHashMap of names->values that you can stick in a system for easy access.
ew Resources.Load 😛
wow, build caching with the current alpha saves a hell of a lot of time
Is anybody using tests with ECS? I am trying to setup tests but I cannot get ECSTestFixture to work as there seems to be a problem with referencing this asdmf
@pulsar jay haven't tried recently but i remember that working, what's the issue?
I found a workaround. Seems I am not the only one with this issue: https://forum.unity.com/threads/addressables-in-editor-unit-tests.543543/
easiest solution is to just copy the files
as the assembly reference deos not work correctly
I figured out that when i convert gameobject with sprite renderer component, conversion produces entity with all this nice components like companion link, hide flags and SpriteRenderer itself. But if gameobject has some extra mono components like Sorting group, or Light2D, or my own custom mono, then final entity wont have any of this components, even campanion gameobject wont have it.
Can i somehow make it automatically added like sprite renderer? Maybe write some special ConversionSystem?
@frosty siren You can write a MonoBehaviour with IConvertGameObjectToEntity, which will add the managed components for you.
yes, but this leads to every time i want my mono be added to entity i must write special authoring that will attach it
@frosty siren try "ConvertAndInject" mode instead of AndDestroy ?
already tried
i'm getting really random lag spike caused by rendering
no clue where i went wrong
does anyone have any clue what might be the cause of htis
it says GC.Collect is running for 57.91 ms
so something is producing garbage in RenderMeshSystemV2 and is causing the garbage collector to free up used memory
Well it looks like the sorting function used in that system is the cause
might want to look there?
where exactly? sorry i'm not very knowledgable about this
RenderMeshSystemV2, find something called Sort Shared Renderers
https://forum.unity.com/threads/rendermeshsystemv2-gc-spikes-in-profiler.781502/
i just found this short thread though
gonna try profiling in a build later i guess
thanks for pointing out the gc.collect though
Hey guys, hope all is well, I need your expertise with blob assets.
We're trying to do "nested" blob assets. Basically we're converting scriptable objects to blobs, but they can reference other scriptables (and thus other blobs). What would be the best strategy? We used to use, for example, BlobArray<BlobAssetReference<Foo>> and it worked fine, but this raises errors in the latest versions of entities.
@eager jungle can you have a seprate 'dictonary' blob
only make 1 of them and all your blob assests 'add' themselfs to that blob, and use some sort of ID system to reference them
either that or you could copy all the referenced data into the blob that has the reference somehow
Has anyone tried storing a burst FunctionPointer<T> in a IComponent or IBufferElement?
@ocean tundra thanks for the suggestions! Copying the data is probably what I'll end up doing... but it sounds a bit counter intuitive... About having a dictionary, yea we have one already... that's not ideal 😢 Since the data in blob is immutable I was hoping for a way to reference blob assets inside blob assets...
yea but again since data is immutable copying the data isnt a huge risk
will probably get you faster reads too
yes certainly, hopefully my blobs are not too big. But what if they were??? and referenced many time
Unity.Physics.CompoundCollider are hacking their way it seems. Because compound collider has an array of blobs in it...
yea physics is doing tons of little hacks
🥳 PSA the master branch of the graphics repo now has deferred universal, and hybrid v2 works with it! 🔥 shadows and point lights for urp dots at long last
@safe lintel yesss deferred means unlimited lights right?
pretty much 😀
just select deferred from the drop down in the renderer asset and done
Sweet
im guessing its not due in a package till the next one, version 11?
didnt have to do anything for hybrid either, though I was already running it with v2 enabled
well i just upgraded my project to 2020.2alpha, and it auto updated the renderpipeline to v12.0. i grabbed the cloned master from the repo and it still shows as 12.0 so not sure what the eventual version will be
nice
hopfully that will be soon
but I guess i could just add the repo directly if i need it
i did notice that it didnt build with il2cpp, had to switch to mono, so not sure what the issue there is, need to test it a bit more
I always seem to have issues with il2cpp
like i love the idea of it
but so much pain
Does any of you use Unity.Animation? Do you think it's in any condition to be used or should I wait before digging into it?
Depends on your game and timelines 😛
Personal, no timelines :p
personally im going to wait for another version or 2
Without it I assume there's no way to handle animations without hybrid entities?
i can survive with T poses for now 😛
That's what I'm thinking lol
i think there are 'ways' to get animations going but the effort is kinda high
Would you know why in runtime, my meshes lose their rotation?
In editor my character looks fine, right scale and rotation, when I press play and it's converted it rotates 90 degrees and scales up, it's weird
Lets rule out the simple stuff 😛
Any Custom Conversion Systems?
OR IConvert...s on your gameobject?
using subscenes or Convert and Inject?
can you pause on frame 1 and see if your charactor has changed?
No custom conversion, subscenes (although my understanding of it is limited), I'll try pausing 1 frame that's a good idea ;p
@bright sentinel @karmic basin I find an answer for my question in https://gametorrahod.com/game-object-conversion-and-subscene/ (greate author). I can write my own GameObjectConversionSystem in which i will use AddHybridComponent(myMono). As a result i will have "hybrid" entity with component object and also gameobject won't lose it's component.
It had an animator that gets deleted during runtime, stoopid me ^^
Is there any downside to making entities entirely in code (EntityManager.CreateEntity, I believe?) other than making it more complicated to configure?
I'd assume it's faster but it's a pain in the ass to configure
Have anyone had success with importing models directly from .blend files? I seem to lose my rotation & scale during conversion
ive been using animation(mostly tests)
currently statemachines only seem to exist as tests, so you are kinda limited in functionality to using the graph setup to achieve things. its fairly hard to even get something as simple as if condition play animation (performantly).
the next release may(or may not) have visual scripting with it, the current one integrated the ui (but its missing nodes) so im hoping the next release adds a ton more functionality.
@vivid lotus @fluid kiln Actually i think it would be slower making via code
depending 😛
Thanks for the insight, I'll wait a little then :p
if its a nomalish entity your making then your stuck using objects (eg meshs) meaning can only make via main thread
but if your making 10000s then you can use the batch APIs and that would be faster
also @fluid kiln im assuming this is the problem
finally subscene conversion is in editor instead of runtime, so you dont have the same performance cost of creating those entities
axis chart
Well Unity handles the blender axis using GOs, I'm assuming it doesn't in entities
Hmmm
lol unreal off on its own 😛
i keep things to fbx personally
Might've to do that, one more step in the workflow :p
yea same, keeping to a common export format can be annoying but worth it
for me its for automated build/play servers, they can build the unity project, but if theres any .blend files you need bleander setup on it as well
Haa I see
also means new team members dont need to also setup blender 😛
Y'all working in teams with DOTS? Do you have an employer or is it just group projects?
ha planning ahead :p
daydreams and wishs 😛
im hopfull in a month or so will have some packages released tho
Just gotta do something decent enough for a kickstarter and then you can hire artists ha ha ha am i right
😛 im hoping to get the asset store to fund me for a bit
but i expect the DOTS community is still too small and weirdly too expert
😛 thats what i want to hear
im hoping to do a basic 'free' tier of good quality and then a 'pro' version with a few extra features
like editor support for entity buffers 🙂
what thats all ready in?
tho i hate the UI control for them
all that paging is super annoying for me (my buffers get HUGGGE)
This is for making the entities dynamically (think like an RTS), so scenes aren't really an option in my case I don't think.
oh but they are 😛
How so?
so I too am aiming for a rts
i have a 'prefabs' scene
all my unit/building prefabs in it
I make a custom IConvert... which adds the Prefab tag to the entity
i also have a sepreate ID system so i can find those entities again
(which is probably the worst part)
So you make entities once from the scene and clone them essentially?
yea
Why wouldn't you use prefabs instead?
all a prefab is in DOTS is a entity with the prefab tag
- a linked entity group if there are children
so you can take any entity and make it a prefab
Moddability mostly, thinking of trying to read entity configuration data from an easy-to-edit file outside of Unity.
The point is to build a robust and easily modifiable editor representation of your entity via prefabs
😛 @vivid lotus we should talk
I'm building a modding package and would love your ideas
If you're not doing that you're giving up on the whole "editor" part of the unity editor for no reason
Well, there's a reason in this case.
Ahh I see
yea my first attempt at RTS + Modding was much like your describing, i would load the files and do my 'own' entity creation
The Unity Editor is great for the first party making the game, but not so great for third parties editing the game.
Yeah I'm just starting down this path so I'm trying to figure out best practices.
Do you mind if i PM you?
Sure, though fair warning I'm a total DOTS novice.
sounds like your exploring the same stuff as me and would be happy to share
Is there a way to swap out an entity's material inside an ECB's SetSharedComponent (in this case, on the RenderMesh) while spawning the entity?
Essentially, I'm trying to set rendering information on an entity as I spawn it from a job (through an ECB), but having trouble figuring out how to get the material in there to use it:
protected override void OnUpdate()
{
var commandBuffer = bufferSystem.CreateCommandBuffer().AsParallelWriter();
Entities
.WithName("SpawnSystem")
.WithBurst(FloatMode.Default, FloatPrecision.Standard, true)
.ForEach((Entity entity, int entityInQueryIndex, in SpawnComponent spawnerFromEntity, in LocalToWorld location) =>
{
var instance = commandBuffer.Instantiate(entityInQueryIndex, spawnerFromEntity.Prefab);
commandBuffer.SetComponent(entityInQueryIndex, instance, new Translation { Value = new float3(0.0f, 0.0f, 0.0f) });
"vvvv PROBLEM HERE: vvvv"
commandBuffer.SetSharedComponent(entityInQueryIndex, instance, new RenderMesh { mesh = spawnerFromEntity.Mesh, material = spawnerFromEntity.Material });
"^^^^^^^^^^^^^^^^^^^^^^^"
commandBuffer.DestroyEntity(entityInQueryIndex, entity);
}).ScheduleParallel();
bufferSystem.AddJobHandleForProducer(Dependency);
}
Where SpawnComponent looks like this:
public struct SpawnComponent : IComponentData
{
public Entity Prefab;
public Material Material;
public Mesh Mesh;
}
But Material isn't blittable, so I can't store it in there, right?
Any idea how I'd accomplish this? I'm trying to swap out the mesh and material during creation using an ECB if I can, or at least partially using an ECB where possible.
Shared components can't be used in burst
That will work if you change it from a struct to a class
Then call your spawn job WithoutBurst
You can still use an ECB but shared components don't work with jobs/burst yet, so anything that uses them needs to be main thread and not bursted
I remember in the forums that someone said there would be non-managed shared components
Yeah in the source code it says they intend for them to be unmanaged eventually. But it's said that for like two years now
I wouldn't expect it any time soon
Wonder why. It seems pretty useful
RenderMesh is managed then, I take it?
I would guess because hybrid renderer still relies heavily on managed components (materials and meshes) and SCD is tied heavily into the hybrid renderer
Yeah
As mentioned it stores meshes and materials so it has to be
Gotcha.
If you clone an entity with a RenderMesh, can that be done with burst?
That is, Instantiate with the other entity as a basis.
Yeah, as far as I know instantiating an entity with managed components works fine and can be done in burst
Doesn't setting shared component data force jobs to complete?
As long as you're not directly referencing anything managed in the code
Not if you're using an ECB
Shame there isn't an ECB for SCD with entity queries
So in that vein of cloning existing entities to get around not being able to set shared components, is there a good way to make a lookup table of entities that I can access in a parallel/burst context?
Let's say I pregenerate entities for each "type" of thing I want to make, and then just want to clone them going forward by some index.
I assume by "not being able to set shared components" you mean in a bursted job specifically?
Yeah basically I'm turning sprite sheets into pregenerated entities, but I'd like them to live in a list somewhere so I can quickly clone them as I add things to the game that use those sprites.
When I needed to do that before I made a normal component version of my shared component. I would write to that in a bursted job. Then I'd have another system with something like
Entities.WithChangedVersion<NormalComponent().WithoutBurst().
ForEach((SharedComponent shared, in NormalComponent normal)=>
shared=normal;).Run()
(The sprite sheets are loaded at runtime so I can't make them prefabs or subscenes, AFAIK.)
Is there no way, within a burst job like what I posted here: #archived-dots message to access just some read-only global lookup table that goes from int -> Entity?
Sure there is, you could make a blob asset for it, or just use a NativeHashMap<int,Entity> in a system
Or even attach an Unsafe hashmap to a component
Ah perfect, I'll look into those, thanks.
I'm a DOTS novice so if I'm asking obvious questions I apologize in advance, haha.
No worries
