#archived-dots
1 messages ยท Page 119 of 1
I'm still confused on why planetEntities needs to be readonly and damagableEntities was fine not to be
well otherwise you unity thinks you want to write to it, in that case you have to put [NativeDisableProtectionForParallel](or smth) Attribute to your field
@remote coyote I just tried 2020.1 and I immeadiatly got errors in an empty project
and every time I clicked one of the errors a new one appeared ๐
do any other system updates damagableEntities ?
Not yet
yeah thats the reason ๐
Many errors usually fix if you close unity, remove assemblies and packages, and start again
This is the first system to use both
once you put it, it will give you an error just like with planet tags
Which componentdata here
@mystic mountain ah ok thanks, I'll try that
includes this info here
is the changelog for entities 0.8 anywhere to be found?
yes i posted it above, or just check your packages if you have updated it
wasnt there a specific component for Gravity ๐ค
PhysicsGravityFactor
Hmm, interesting
@opaque ledge how do I check my package? when I click changelog in the package manager nothing happens
from your project files
might show up if you change it in the authoring component
instead of Assets go to Packages
no need to add component if you can assume 1
yeah, same thing goes for scale component i believe, if its 1,1,1 it doesnt actually add scale component
Oh, that component wasn't being added if you keep it at 1 or 0 apparently
I'll add it then, thanks
@opaque ledge Ah, thanks
did you get hrv2 working @opaque ledge ? I'm getting RenderMeshSystemV2 could not be found - am I missing a package or smth? 2020.1.0b1 - hmm, don't think ENABLE_HYBRID_RENDERER_V2; is needed maybe we need to wait for 2020.1 proper?
@opaque ledge so I should search in Packages->Entities?
@fallow mason re: https://discordapp.com/channels/489222168727519232/497874303463850004/688010724668342276
static methods are fine, problems come from static fields. I would not however recommend using World.DefaultGameObjectInjectionWorld in this situation (this kind of use was the whole reason they changed the name from World.Active)
oh the new packages ๐
why not?
what happens when I do CreateEntity(MyGameArchetypes.PlayerArchetype) from a system that is not in the default world?
ok, lets testthe hybrid v2 now:D
Please report on the URP support if you happen to use it ๐
where is this HybridURPSamples ?๐
you need this
ty
that has both hybrid v2 changes for upr and hdrp + samples on testprojects
hmm does that mean no longer any support for ~~universal ~~legacy/builtin with the new hybrid renderer do you think?
also need to change the test projects manifest since those point to "com.unity.rendering.hybrid": "0.4.0-preview.7",
instead of preview.8 which we got
also need to remove the custom registry path from it
it points to some internal unity registry
@amber flicker i am getting the same error
@junior fjord yes
it should be in that folder, look for CHANGELOG.md
anyway, I'm opening this here now, will report back once I get this running
would expect these testprojects to just... work
they'll work after we've found all the bugs!
ENABLE_HYBRID_RENDERER_V2 && UNITY_2020_1_OR_NEWER && (HDRP_9_0_0_OR_NEWER || URP_9_0_0_OR_NEWER)๐ค
๐ฆ
just works tm
tbh, I haven't yet found a test scene that would make much sense to me
I guess we're too eager as usual
well
didn't realise they'd be dropping support for the built-in pipeline with the new renderer though.. that's a bit sad
technically this branch is for 9.0
so it's meant for 2020.2
I'm testing it on 2020.1.0b1
also they will definitely backport these samples for 8.0 too
so I dunno if this is related to the crashing or if the editor version we got is simple not new enough for required functionality
how can i get URP_9_0_0_OR_NEWER? ๐ง ๐
?
lol i thought the same thing ๐
what does wip stand for
meaning, it's not released yet
work in progress
basically this is a work on progress branch that hasn't even been merged to SRP master yet
ah cool
so... don't expect it to be functional and you're good
only reason to check it now is to do early testing & see how they setup this here
Seems weird for them to release it if the URP stuff isn't even ready
it works ok in HDRP?
Maybe it was an accident
basically, we'd officially need a new 8.x release for URP and HDRP so that this new hybrid renderer v2 would be officially functional
@warped trail still trying to figure this out, I'm testing HDRP samples here
hmmm, they probably still are going to release separate HybridHDRPSamples & HybridURPSamples somewhere
I don't think they refer to these SRP testprojects with them
as these are more like meant for internal testing (but can be often handy when trying to figure out how to use some feats)
this is very cruel joke๐ญ
Hybrid V2 needs 2020.1 beta 3 and HDRP/URP 9.0 preview
it was on hybrid package itself?
that would explain it
I'm testing on HDRP 9.0 with hybrid changes here
but this is definitely not fully functional on beta 1 ๐
its not, I have that confirmed from a source ๐ I was very exited too to test it out.
at least, I don't think that is supposed to happen
hmm "Sample projects are using Hybrid Renderer V2 and require Unity 2020.1.a025 or later and SRP 9.0.0-preview package." in the released docs.. I'm not sure if that is true or not
I was told it needed beta 3
beta 3 sounds logical to me
btw did you read the hybrid V2 docs yet? the feature sure is quite nice ๐
not yet
New features in 2020.1 + hybrid.renderer 0.3.6:
- Official URP support (minimal feature set)
- Support for non-ShaderGraph shaders
- Motion blur (motion vectors)
- Temporal antialiasing (motion vectors)
- RenderLayer (layered lighting)
- TransformParams (correct lighting for inverse scale)
- Hybrid Entities: Subscene support for Light, Camera and other managed components
- more ๐ material overrides etc
Is it me or does no one seem to use ECS without converting game objects to entities? I'm trying to find examples and look into loading models and setting up physics with pure ECS but damned if I can find much.
yeah, I knew about the movecs
I'm personally more interested on what all "full" HDRP featureset really includes
@loud matrix Most people have moved away from that workflow yes. Convert prefabs to "prefab entitites" and then instantiate as needed
because I'm still super skeptical that this would work with say, HDRP DXR
Once this is out Im sure they will quickly add more support as needed
btw, the test projects only had this on player settings: ENABLE_HYBRID_RENDERER_V2
@flat talon Moved away from pure ECS you mean?
yep you still need that
well, I'm not really as hopeful
@loud matrix mostly because unity decided adding real editor support is too hard/costly
quickly can mean anything for yet another year or even multiple years
so the conversion hack/workaround is the official thing
@loud matrix Yes, there wont really be a "pure ECS" for some years. All authoring will be via gameobjects, but they are converted so if you use a subscene no gameobjects are ever instantiated
I wasn't born yesterday and have seen how certain things take their time with Unity ๐
lets see next week, unreal gdc streams, with the rumors for unreal engine ecs
and btw, with editor support XD
that will be interesting
oh boy that would be great ๐ but Im skeptical, Im not sure Sweeney was buying into DoD
its a whole paradigm change so I would hope it wouldn't be rushed
epic engineers contacted me and another guys a year ago about ecs stuff
I doubt I would use Unreal still, it's just too massive for hobbyists imo
the whole actor->subactor and actorcomponent setup in UE4.. yeah, Im not a fan ๐
its shit
its basically a flawed concept
it automatically makes games create hypermonolythic character/game classes
totally agree. And it gets even worse when you have to deal with network replication.
gears of war character.cpp is 50k lines
well the main issue it is the bloat and overhead
oh it actually works crazy well with networking
framework itself is quite nice
its just how much it bloats and overheads
Hell yeah dude, 90s style
vblanco with networking actor instantiation order becomes a big issue, and it you use "sub actors" that quickly becomes a nightmare mesh of missing references ๐ฆ at least last when I did work there around 2.5 years ago
its workable
the real issue is the separation beetween actors, scene components, and actor components
sure, I shipped a game with it.. but it was shaky AF, and hard to maintain and debug
ive generally seen much worse being done with unity
due to it being "more freeform"
lol, yes ๐ definitely
If you give a person a rope...
on unreal it breeds bloated character.cpp type stuff, but the "structure" of projects is a lot more standarized
oh totally ๐ we prototyped EVE Valkyrie in Unity and then migrated to Unreal. Structure was a lot better after that
kinda the point of ECS itself is how easy it is to "architect"
have you checked the samples?
the new tiny ones
they are all super easy to understand
not recently no, was kinda waiting on the next release with 2d support.. but it seems that is out now
I would wait still. They are very close to a major update to make it compatible with the latest entities version.
It seems like they just backported the 2d stuff into .22 to let people mess with it until .23 is ready
the tiny samples are actually the best way to undestand ecs
its the best samples unity has atm for dots
yeah I love what I've seen with Tiny so far, its the most "pure ECS" so far. I really want to make a simple game with it to learn, a simple shmup or something
It seems awesome, the problem is just getting your project set up correctly right now is horrible
Very arcane
how so Sark? Just not in line with latest Entities packages?
yup^
Yea the FPS sample was so hacky
@flat talon look in the forums
how so Sark? Just not in line with latest Entities packages?
@flat talon
That and you need to manually set up very specific settings in the "BuildSettings" asset and make sure you import the correct versions of packages (ie not the latest versions), or import their custom made example project. Otherwise everything just fails miserably.
its bad enough that the tiny guys say that the best way to create a new tiny project is to copy one of the samples and just customize it
never update a package in a tiny project...just don't do it
@vagrant surge they did come up with template for it
it's pinned on this channel too
well, for 2D anyway
I so look forward to Entities 1.0 shipping and getting some stability. The current DOTS Animation package is also throwing warnings with latest 0.8 Entities package
A quick question on the 0.8.0 release notes, * Added missing dynamic component has API: ArchetypeChunk.Has(ArchetypeChunkComponentTypeDynamic). Are these dynamic components a special concept? Or does this just mean components added to an entity post-creation?
They said the next Tiny version will be compatible with 0.8. Along with runtime dynamic mesh support I will finally be taking a serious look at Tiny then
personally i think tiny should be more compatible with "not tiny"
you should be able to run tiny projects on the desktop runtimes
with proper play-in-editor working well and similar stuff
You can build Tiny as standalone, or is that not what you mean?
@opaque ledge btw you can use "md" (markdown) formatting for those changelog quotes, if you use "cs" etc, it'll highlight those programming keywords ๐
@zenith wyvern i mean about having tiny essentially work the same as "desktop" ecs stuff
not about standalone build, but about full editor support and the likes, or using tiny with extra non-tiny stuff for "normal" games
basically have tiny as the "pure 2d" mode of ecs
@stiff skiff basically 'kind of component you get from a variable'
I would like to be able to make 3d games using Tiny though
Which they are supporting
@stiff skiff Those ArchetypeChunkType/Buffer etc structures are 99% about capturing the TypeIndex from TypeManager before it goes into burst context. I have been changing the component type dynamically in jobs by just putting any appropriate value of T (to get the other values populated, global version etc) then switching the TypeIndex undernearth inside the job. So i believe this Dynamic version is supposed to be that scenario, for people who just want to be able to specify the index/behavior themselves.
// Unity.Entities.ComponentSystemBase
public ArchetypeChunkComponentTypeDynamic GetArchetypeChunkComponentTypeDynamic(ComponentType componentType)
{
AddReaderWriter(componentType);
return EntityManager.GetArchetypeChunkComponentTypeDynamic(componentType);
}
// Unity.Entities.EntityManager
public unsafe ArchetypeChunkComponentTypeDynamic GetArchetypeChunkComponentTypeDynamic(ComponentType componentType)
{
return new ArchetypeChunkComponentTypeDynamic(componentType, SafetyHandles->GetSafetyHandle(componentType.TypeIndex, componentType.AccessModeType == ComponentType.AccessMode.ReadOnly), GlobalSystemVersion);
}
Ok so i have a "how the hell should i do this" question.
I'm building a basic space sim game, Player controls a ship, there will be many NPC ships each deciding what they wanna do based on a simple utility AI, space stations to dock at and trade with, players and NPCs can make more stations. So I'm gonna end up with a database of locations and ships that will need to be spun up into entities. In my head I'm thinking the best way to do this and enable things like game saves and multiple scenarios easily would be to have a JSON file or similar that just keeps track of their data, position, rotation, current action etc. And on game load read all this in and create my entities of the required type and feed that data in. Which I can do easily enough. But I can't think of a good way to manage loading in the models and physics for this. Would I be best off doing something like creating prefabs and then creating game objects that I then puppet from the entities?
@sour ravine @mint iron Thanks, clarifies things
@mint iron interesting that answers my question about those missing apis
I'm still on 0.1.0, so trying to keep up with all the changes from the logs has been interesting
I'm not sure what you'd actually use that for in a serious game
debugging aids, maybe
i guess the latest update always adds a companion gameobject for the camera?
hmmmm
I tried enabling that hybrid v2 on my dots proto project
it does seems to work there
ah good call, I forgot to test the camera in subscene. It should use a "hybrid entity" now
at least it says it's enabled and it renders HDRP properly
same with lights
@sour ravine its relevant to the package im currently working, creates events from the new InputSystem, so you can create a mapping of InputAction to Component and then they show up as events in ECS. So all the all the creation of the entities, components and setting the data has to be done in a generic form without knowing the type.
I'm testing this on latest SRP master
can i add 9.0+ urp from manifest.json?
subscene lights seem to be working now
@warped trail no the package isnt out yet. I believe @dull copper is grabbing the source from Github
๐
@warped trail yeah I'm using this from github SRP
well, DX11 HDRP did render on hybrid v2
when I enabled DX12, converted meshes turned invisible
did you try the sample scenes yet? or any of the features that weren't supported before
I don't think the official samples are even out
I did test the testprojects for these tho
and those were bit wonky
yeah samples arent out
Having trouble trying to work out why adding an Entities.ForEach into the OnUpdate function has stopped the whole job from running: https://hastebin.com/bokayizepe.cs
@opaque pilot if the query returns 0 entities it skips the update
I'm frankly bit bummed about that DX12
yes on that system
if you leave the update empty or without the lambda it runs as before
there is also an attribute and I believe a method you can override to override the default behavior of this
look at the SystemBase docs
Thanks, that explains a lot
@mint iron that sounds like something I might want to use - is there a repo I can follow?
yeah https://github.com/jeffvella/UnityEcsEvents but im working in develop branch for now, its not really ready.
what happens when I do CreateEntity(MyGameArchetypes.PlayerArchetype) from a system that is not in the default world?
@worldly pulsar I don't know. I was trying to create my own world to test, but was unable to figure that out. My guess is that it would not work as I believe I've heard that cross-talk between worlds can't happen. So, sure, you want to make certain you're creating the archetype in and from the same world. Not necessarily a condemnation IMO, but a caveat ๐คทโโ๏ธ
speaking of, has anyone created their own world yet?
I was only referring to the usage of World.DefaultGameObjectSomethingSomething, so something like
static EntityArchetype MakePlayerArchetype(EntityManager em) => em.CreateArchetype(/*components*/)
is perfectly fine if you want a common place to have the player components list in code
yeah, that would absolutely work
I tend to put this kind of stuff in a project-specific system base class, but I have very few archetypes I create from code and need in multiple places, usually only one system is interested in creating entities of a specific archetype
referencing the default world in the static property was silly
you're right, just pass in the entity manager you want to use and it will work ๐คฆโโ๏ธ
@dull copper thanks^^
is there a way to find an entity or do an entity query in a monobehaviour to update things like UI?
World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntityQuery
Ta!
using Unity.Entities;
using Unity.Transforms;
public static class MyGameArchetypes
{
public static EntityArchetype PlayerArchetype(EntityManager em) => em.CreateArchetype(new ComponentType[] {
typeof(Translation),
typeof(Rotation),
typeof(Player)
});
public static EntityArchetype EnemyArchetype(EntityManager em) => em.CreateArchetype(new ComponentType[] {
typeof(Translation),
typeof(Rotation),
typeof(Enemy)
});
}```
using Unity.Entities;
public class EntitySpawnerSystem : SystemBase
{
protected override void OnCreate()
{
EntityManager.CreateEntity(MyGameArchetypes.PlayerArchetype(EntityManager));
for(int i = 0; i < 50; i++)
{
EntityManager.CreateEntity(MyGameArchetypes.EnemyArchetype(EntityManager));
}
}
protected override void OnUpdate() { }
}```
There, now they'll create the archetype in the world the spawner runs in for sure
man this camera change for the latest release is pretty frustrating, gotta love undocumented changes
what is the change ๐
a companion gameobject camera is made at the very least when using inject on the camera, means there are two cameras in scene, and it defaults to the companion one. it doesnt appear to add a listener if you happen to use destroy instead of inject, and it also doesnt have that postprocessing tickbox enabled by default, and from the api I am unsure if that bool is even accessible
ok mini crisis averted by enabling and disabling the camera which I guess sets it back as the main camera, but man just another silly hack on top of everything else..
I have my map covered in chunks, each chunk has a different mesh (allthough same material). Should I give each one a rendermesh component (but then each has an own archetype right?) or just use Graphics.draw to draw them?
HI. I want to disable auto generation of default world while Unity Editor Playing. Where should I put this pieces of code?
#UNITY_DiISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP
If I do new a world, how can I create those default systems as same as the default world?
hmmmm, there is some weirdness on this hybrid renderer v2 (which could totally be because we are still missing some native code changes on current beta 1)
it drops 2 of my wheel meshes every time and both the visible wheel and the inivisible one have 1:1 same components on entity conversion & runtime, even checkedthe Translation and WorldToLocal being correct on the missing ones
๐
@pallid raven Because your field horizontalMovement is a Vector2
Vector2 don't has velocity field. Only x and y
maybe it is "playerRigidBody.velocity.y"?
@pallid raven This is not a #archived-dots question. Please do not cross-post.
@pallid raven Because your field
horizontalMovementis a Vector2
@south falcon ุฆุงุถู ุณุงุฎุนู ู ู ูุฎ โ
what should i do*
You should move to #๐ปโcode-beginner
oh sorry
oh sorry
@pallid raven try replace thehorizontalMovementtoplayerRigidBodyin the red cycle of the picture above.
thx i will try
IJobForEachWithEntity is going to be removed in feature entities package??
Can I use local function inside Entities.Foreach now?
@south falcon am sooo thx for you're help forever
๐
@south falcon Not at my computer right now, but pretty sure you can do cs Entities.ForEach((Entity entity, ref MyComponent myComponent)=>{...});
@south falcon Not at my computer right now, but pretty sure you can do
cs Entities.ForEach((Entity entity, ref MyComponent myComponent)=>{...});
@fallow mason I just update Entities package to 0.8.0 and get obsolete information. The reason why I useIJobForEachWithEntityis that I can use local function insideIJobForEachWithEntityto organize my code but Entities.forEcah can not.
If use Entities.ForEcah, I have to write a ton of code inside it ๐
Ah I see. Can that local function be converted to a function in the system?
How large is this local function? ๐
Yes, the local function is the local function inside system.
And Dots consider those functions are reference type
Then I can't use burst and jobs
How were you using in IJobForEach? Same rules for burst and jobs apply there.
There are about 100s lines of code inside Entities.Foreach if I use that.
Yeah, I use IJobForEachWithEntity as same as Entities.Foreach. However struct MyJob : IJobForEachWithEntity, I can use functions inside MyJob
hi
๐
i have no idea how to code at all
How were you using in IJobForEach? Same rules for burst and jobs apply there.
@fallow mason Maybe I should tryIJobChunkin the feature.
instead of IJobForEachWithEntity
@south falcon why does it need to be a local function instead of a static one?
@south falcon why does it need to be a local function instead of a static one?
@worldly pulsar get a point๐ค
I have never thought of that
maybe give a try๐
@zenith wyvern So, I started changing my Tiles to structs but having this problem currently Tile used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer
lets see next week, unreal gdc streams, with the rumors for unreal engine ecs
@vagrant surge
I love that I went to check into unreal engine ecs and your posts come right up
intresting work
really hope they go all in and make a framework like unity's
battle of the ecs systems ๐
unity ecs is solid
I'd love for unreal to remove all the actor crap that was a nightmare to deal with
its good if you get it working, converting my scripts to work with Burst has been hell
I spent more time learning the Unreal wayโข๏ธ than actually writing the game
and its not even working yet so
I've already shipped my game fully on unity ecs
it was fully worth it for a sandbox game
my game is pretty much sandbox so I'm trying to get all the performance I can get but getting Burst to work is hell for me
you need to write things how ecs was intended to write
jobs, systems, value structs only
kinda wondering june how many ijobforeach's your game uses(with it being deprecated now)
~180
im about half that, maybe its for the best and I cant see it for now but I like ijobforeach ๐ฆ
I've still got some componentsystem's I need to update
the gc from them is disgusting
christ, I've only used one IJobParallelFor and I'm having issues :p
well Ijobparallelfor is a different beast ๐
well I think in your case you need to split what your doing and what you need to be doing more
jobs lend well to being small little operations
yeah, currently I've managed to reduce my world generation loop from 200ms to 70ms so it has been a worth-while time spent but I wish I could use Burst
well you have to sort our whats just dealing with data
and whats dealing with unity apis
like meshes, sprites, audioclips
yeah I do kind of have that going, such as a class for Tile, Terrain Types, Building Types etc but they are classes and not structs, if I want to change them to structs I have to rewrite a lot
well your gonna have to write code for this
your writing the equivalent of how it worked before, but in a data focused way
usually when refactoring I write in place next to it
then delete the old one after done
I suppose I just don't know if it's worth the hassle
is that 70ms killing the fun?
is it making your game a worse product?
does it matter?
@low tangle FWIW I'd love to see a blog post or two on practical gameplay problems/solutions from people with shipped games in Unity ECS.
e.g. a few weeks ago I stumbled upon this problem description: https://takinginitiative.wordpress.com/2019/11/09/more-ecs-questions/
and I'm still not sure how I'd approach it with Unity implementation
for me the first part that was hard to get used to
is the data is the gameplay logic you want to happen
its not objects
3 is far too low
expect more like 20+ in a real world case
Yeah.. I mean I do want to optimize that 70ms but I still have a lot to learn about how structs and reference / value types work.
alright think I figured out what they are asking
well, he has 3 transforms he cares about in that example. It's more the system dependencies I'm having a problem with (turret rotation system needs the transform system to get the chassis l2w, but then it also sets turret rotation which should be applied to its l2w before the secondary turret rotation system runs)
so the reason this is a pain, is because of jobs / async logic
so if you forget job systems, just main thread component systems
you simply need a order of operations, potentially calling the targeting system twice
once to get the base turret into the right location
then again to update the secondary turret to the correct location
I think you'd need both targetting and transform systems to run twice
well yeah, if your targets need to actually update the transforms?
you don't though, the targeting system can just be creating the ray in it
the transform system can just apply the final data afterwards in one pass
no, I mean the rotation of the main turret changes the position of the secondary turret
yeah right
I'm just saying you can make them calculate the actual matrix offset you need in this case
which can be derived from a editor created initial offset / socket on the start mesh, but thats just inital data which is easy to author
by handling the matrix yourself you end up ending the need on running a system twice
so your update order only needs to be
[targeting, targeting, transforms, ik]
so the first targetting writes directly to l2w (or the second reads parent position/rotation), essentially duplicating transform system logic?
just the minimal amount of logic you need to produce the matrix
transform system does a lot of compound extra math that you dont need
you really don't want your visual meshes driving the rest of your gameplay anyways is what I'm trying to get at
your targeting doesn't need to deal with the real mesh, ik at all
its discrete logic that should only depend on the physics / movement position
ah, so another thing that could help, you can run though all turrets and figure out how many turrets on turrets you have, to get the max depth, so you know how many times you need to run the targeting system to make sure all are corrected
yeah I was just thinking why does the second turret need to be dependant on the first
its mounted on top of the other one
on the real thing they would probably be on separate gimbals anyway surely
sure, but the positional offset would still be there
Meshes stay out of it of course, it's the "put the transformation system parent-child logic into the targetting system" that still feels icky to me ๐
(I had a somewhat similar problem where I had to do steps A,B,C on one entity and those steps produced more entities to run A, B, C on... a pain to express in the job system)
logic chaining was a pain at first yeah
I dont mean the whole parent child logic
I mean, what does a targeting system need?
base position of the turret, its pivot for the barrel, then the target float3
the base position your rotating is just a offset from the tank base platform l2w
so you just copy that over, or access it though a getcomponentfromentity
just details, then you correct your pivot, then create the ray from the point to point, with a up vector from the l2w
personally I would just treat them as separate and make it look like they are connected
the only thing you have to do is multiple runs of the target system based on turret on turret depth, which is really nothing
this system would take nothing to run with burst
how many tanks have more than one turret on one turret
yeah that's just bad design in general
more than one turret no, but then you have the tank moving, which writes to Translation/Rotation
right, which you update your targeting passes after transforms move
so the targetting system for the first turret needs to already take that into account
update transforms+physics, then update targeting, update targeting, ik pass, visual mesh update
the upper turret would have to nifty targetting systems no human could likely use if its at the end of turret pivot
talking about the mg at the top
which in a tank game would probably be aiming at the same target as the main gun, within turret rotation limits
So systems that run are:
MoveTank (updates chassis Trans/Rot)
Transform
Targetting1 (reads chassis l2w, writes to Main Turret l2w)
Targetting2 (reads MainTurret l2w, writes to Child Turret l2w)
?
the upper turret would be moving in a circular rotation when the main turret is moving
that would surely make it difficult to aim
@pliant pike real have those kind of turrets so I guess not that hard:
https://en.wikipedia.org/wiki/M1_Abrams#/media/File:Mounted_Soldier_System_(MSS).jpg
that looks as if its in the center of the turret though
there is another one behind it, at an offset
[Turret, Targeting]
[Turret, Targeting, Parent]
[TurretStackMax]
(MoveTank)
(Transform+Physics)
(UpdateMaxStack)
0-TurretStackMax
(UpdateTargeting)
(UpdateTargeting)
//Can now be assumed all [Turret, Targeting] are pointing at the right location
(UpdateVisualMeshes) - writes out the modified transforms which is just a quaterion from the targeting system
if you know that there will only every be up to n stacks, just hard code a constant
And (UpdateTargeting) have to operate directly on LocalToWorld, since there will be no Transform system run after this, correct?
update on the targeting which has the vectors / matrix / whatever you need in it
then have a system that runs after all update targeting
that writes the actual final L2W out
that way you can avoid running 1:1 extra passes you dont need
thats what (UpdateVisualMeshes) does
this whole update loop doesn't directly depend on each other, if you take any out, the rest work fine, except that the data ends up stale
oh I missed one system after the transform system
one that updates the data on the bottom turrets
just passes in the L2W to the [Targeting]
that way you have the updated base location
now that I'm thinking on it, I think theres some transform system stuff to utilize their DAG
Ok, feels like solid design for this situation
I was looking too hard for a solution where targetting systems only wrote to their translation/rotation and then let the Transform system somehow position everything correctly
I think there is actually a transform system thing for that
writegroups
need to fully think though it, but I think you could use these to create a align pass transform
hm dont think so actually
Hmm, only use I can see is to tell the transform system to skip turrets because we write their l2w ourselves
i use writegroups to apply custom 2D translation and rotation components to the LTW
completely cuts built-in out of the picture if they are present on an entity
yeah I pulled it up to read but I dont think it would work, I think in a tank game you should just solve tank logic yourself anyways
turrets have complex logic anyways
thanks a lot for the talk, gave me something to think about ๐
did unity's rendering package change by a lot since 3 months ago? the changelog just says they updated dependencies. the work i had before that displayed hexes now just displays a black screen after i updated and idk how to begin to figure out why
so what does this mean? Tile used in NativeArray<Tile> must be unmanaged (contain no managed types) and cannot itself be a native container type.
https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types
umanaged = (more or less) blittable
ah so my tiles cant contain any strings?
yes, like I mentioned yesterday strings are instant deal killers for Burst
I'm just not gonna use Burst
you can use fixedstrings
nah, I just wont bother with Burst
I would use it but I just find changing all my data classes into structs really annoying, and some parts I don't even know how to make work with Burst.
Well there's no shortcuts for the first part. If you want the cpu to go fast you need to structure your data properly. What is it you can't figure out how to make work with Burst?
Well, I figured out how to make my Tile a struct but a Tile also knows what World it is in, therefore I'd need to change the World to a struct, which doesn't work because how the World class works it cant be made a struct
Why would a tile need a reference to the world it's in?
for a function that checks its neighbor, which has to access the world's tiles array
I guess I could move that to the world itself instead of a tile
You presumably have the tiles array inside the job. Whatever's accessing neighbours can do it with the array rather than going through the tile
i think I'll move it to the world class itself and get rid of the world reference in the tile. that'll do
smells like oop classes in classes
it can be very hard to transition from OOP to DOD/ECS
how would you create a 2 dimensional array to be passed in job?
and yeah, its very hard but I'm trying :P
one of the things you could do is have a DynamicBuffer of a struct that has owner tile field and neigbour tile field, and you can inherit from System.IEquatable<Tile> so you can have a dictionary like access to DyanmicBuffer. when you read from this DynamicBuffer you can do Dynamicbuffer.AsNativeArray, and then do IndexOf(ownerTile) to get the tile's neighbours.
actually nevermind (I think) I found some calculation to get it from a 1D array
so, what should I use instead of a string?
FixedString if you want to put into a component
I dont use the component system
then use normal string
make a dictionary of int, string
hash all your possible strings
then in the job just use ints
wait so, can I use strings or not
If you mean for the key for your NativeHashMap just use an int or an enum
You can define your tile types in a static class like
public static class TileTypes
{
public const int Dirt = 0;
public const int Grass = 1;
// etc
}
Gives you nice code completion and makes it readable
And since they're const they can be used anywhere
In the code I just posted I'm pretty sure "Dirt" and "Grass" are names
are you using this strings to identifty tile type or to show in UI ?
What's the difference to you between tilemap["Dirt"] and tileMap[TileTypes.Dirt]
The point is you want to use Burst. You need to give up on the idea of reference types and classes. Forget them, you don't need em, don't know em, never heard of em
@opaque ledge UI
does this string change in runtime ?
You can use nameof(Variable) to convert a compile time constant to a string when needed
If it doesn't change then there's no point in having them as strings, just have them as ints and map the ints to strings when you display them in UI.
it does change
How does it change?
If it's just changing from one type to another, that's still a finite list of them and you can do the mapping as usual.
because the game is moddable
I'm pretty sure we already covered this. It doesn't matter how you represent it outside the job. Inside the job you can't use strings, period.
you still just hash them to id's up front
Regardless of what the are outside the job, you need to convert them to a Burst-friendly format.
@zenith wyvern it does matter because a Tile has a Terrain Type and a Terrain Type cant contain a string because its used in a job
What is the job accessing inside the tile
I still don't see why you can't solve it by storing it internally as an int, and map the int to some display string when you need it for UI.
Even if it's moddable, the mod adds a "new tile", you just add "new tile" to your mapping and give it a new number, then internally represent "new tile" with that number.
if you post the part of the code thats using strings, chunk of generation whatever is causing you trouble I'll rewrite it
It's not just about Burst, when you store a piece of information why store it as a string if you can store it as an int.
You seem to be way too caught up on this string thing, if you want help you need to better explain exactly why you need strings in your tiles. We've offered you plenty of alternative ways to represent your data
Yeah.. another problem is that the name of sprites for the terrain is also a string and not an int
but thats also because each terrain type has multiple sprites for different positions such as N, S, E, W and so on
what is your job doing exactly ?
selecting the correct sprite based on the tiles current position. Though to do that it accesses a dictionary with the key being a s t r i n g which is a problem of course
how do you represent tile's current position
x and y ints
so how do you get the string that you use as a key to get correct sprite ?
with the terrain types name plus the string it came up with : for example "Dirt_SGLE_N"
how do you assign that "Dirt_SGLE_N" to a tile ?
it doesnt; its just the rendering
So your dictionary values are tiles and your tiles contain all the variants?
I agree with Sark's suggestion above.
https://discordapp.com/channels/489222168727519232/497874303463850004/688280201632809017
Or every variant is a single tile in the dictionary?
the dictionary has a key which is the name + variant and then the value is the Color32[] array
What does SGLE mean?
just short of single
Meaning a tile with variants would have a larger array?
so like; if the top and both sides were a different terrain type and bottom wasnt a different terrain type then it would be a SGLE_N
I still don't understand what the "single" means in this context. Like a single side?
I just couldnt find a better term for it
I'm not trying to nitpick the name, just trying to understand how you're representing the data
ill just draw something real quick lol
so if the top and the sides are different types and the bottom is the same type then it would be a SGLE_N, theres probably a way better way to do this that you probably already know
I think you would normally use a bitmask
So you do a bunch of if logics and based on that you create an access string and access your dictionary's key's values ?
So what i am trying to understand is, how do you know the type of the tiles around ?
Read this. Not gonna lie it's a bit complicated, especially if you're not great with math. But it's exactly what you want
It massively simplifies this exact problem
This is basically the "correct" way to do what you're trying to do
Alright, Ill take a look
Anyway, general idea on how to handle strings in your data inside a job is mapping an int value(this could be Enum or Guid etc.) to a string, and instead storing string to your data, you store the int
also what June said is very important, you probably dont even need to handle strings in your job since they are generally used for UI
yeah thats my end goal to be honest
also, completely unrelated; what would be the math for getting value in a 1D array with 2D values (x, y)?
Also I need to pass out soon but - once again the goal is to get your data in an array. Dictionaries are usually not needed, and definitely not needed in this case. In your case there are at most 16 variants. If you combine that with the code I posted above where you assign each of your tile types to an int, you can get the index of any variant by TileTypeIndex * 16 + variantIndex
That will make more sense once you read the article.
@odd cipher cs i = x + y * max_x + z * max_x * max_y; x = i % max_x y = ( i / max_x ) % max_y z = i / ( max_x * max_y )i use this for 3D to 1D๐ค
Thank you Sark! This will work good (I think :P), Only problem is my lack of Math skills! :D
The article does a good job of explaining it step by step, just keep re-reading it until you get it. I believe in you!
@zenith wyvern I'm thinking of using an int2 for this, the X of the int2 would be the terrain type ID and Y would be the all the stuff from that link
so all possible directions
actually not sure that would work
dont know really
still not really sure :P
๐
It's a little werid because you cant just set an int to 0000 or something like that
i guess it could be bools but not sure on that either
@low tangle on that whole targetting thing, it smells to me of huge over-engineering
this thing is solved by mainBody->GetTargetPoint()->direction and you do a ray there. So... you can try to do the same on entities
make sure that the transforms of the target point are updated (is it possible to tell unity ecs to update transforms in one place?) and then just access the target point and do your raycast
he was asking for a ECS only way of doing it
only though systems
I would just do it linear if I was in a hurry and not worry about it yeah
Is this a place to ask about Unity Jobs system as well?
@runic spire I'd say yes, people here are probably most experienced with it
Alright, I'll move my post over
A little confused... I'm very new to the Unity Jobs system and it seems as though my IJobParallelFor is only running on the main thread in the profiler?
All workers are idle
I'm running the job with ```
JobHandle jobHandle = moveCalcJob.Schedule(GameData.starlets.Count, 100);
jobHandle.Complete();```
in Update()
Doesn't doing jobHandle.Completemake the main thread wait for the job to complete?
Yes
You have to let Unity'
Unity's internal system complete the job
And then next frame (or at the end of the frame) read the output of the job
wouldn't .Complete() be the same speed as checking at the end of frame? I mean... I really have no clue what I'm doing with this
In terms of how Unity handles everything
What are other methods of running the paralleljob without waiting for it to complete?
@runic spire its about blocking execution or not
with a job system you want to avoid any sort of sync point. specially a main-thread sync point, so its better if you can do a lot of jobs and just check them next frame
That makes sense, I just am at a loss because I don't know how to use the jobs in that way
I guess I'll keep looking for documentation
@runic spire The thing is that you can schedule the job at the start of the frame, and then complete it at the end. It might have completed meantime, but you have to call complete on it before you use the contents
Does that make sense?
That makes sense
The job system will automatically execute the job when there are resources available, unless you call Complete on it, in which case it will complete it immediately if not already completed
so you only have the amount of time that the main threat executes to complete the job before the job holds up the main thread?
assuming you are Complete()ing on the same frame
Basically yes. But at least you're not executing all that work on the main thread, but split it into the various threads
I'm not sure if Unity will also use the main thread if available though
How can I make sure it starts at the beginning of the frame and and completes at the end of the frame?
im only using tempjob allocation
for my nativearrays
I'm clearly misusing jobs since it is literally slower with my usejobs boolean set to true when comparing speeds
@runic spire You can use script execution order
jobs doesnt make your code run faster tho ๐ค Compiling with burst does ๐
I do compile with burst
Decently yes
I mean, I probably need to rethink what I want to do with it
because it gets exponentially more taxing
are you using any reference types inside your job ?
is there any System.Tuple alternative?
yes, a struct ๐
Not using any reference types
Blegh of course, those structs ๐
it should be insanely fast then
I'm sure it's something absolutely idiotic that I'm doing because I don't have any idea what I'm doing
i felt the same btw pengweng ๐ not being able to use reference types which includes value tuples are kinda annoying, but its something we have to deal with it ๐
well not sure Danon, no one can guess why this happens if there is no code to inspect ๐
should I make my own struct for all the data? I'm using multiple nativearrays of different types right now
hmm probably not, it shouldnt matter
i dont think it matters
Does your job actually moves the tranforms ? (since its named movecalc)
well, thats where your problem lies then ๐
well I'm not actually accessing the transform
there is a specific job type for manipulation transforms
I guess I misunderstood
I'm editing a float3 and setting the transform equal to it on the main thread
once the job is completed
i mean if you are only calculating where transforms should move by manipulating float3s, then there is something going wrong, that shouldnt take 20ms AT ALL.
are you sure your burst complition is active ?
yes, but I realize now that it is probably just my main thread creating the horrible performance
although I don't know of a way around it with my goal in mind
basically, I have a list of circle objects, and I want to iterate through all objects that are within it's radius
I'm using Physics2D.OverlapCircleAll to get that list, but I can't use Physics2D functions inside of a job
so I'm stuck doing it on the main thread
iterating through all circles and calculating distance would be worse I think, even if I used jobs for that
because each circle would have to check every other circle, and more circles keep getting instantiated
Would manually calculating the distance with jobs actually increase that performance over Physics2D.OverlapCircleAll on the main thread?
yeah probably, since it will be bursted
The thing is i never tried doing jobs in monobehaviours so i am not really experienced but perhaps this example can show you some good pointers
Ah, that's a good example of how to split the job between update and lateupdate
@runic spire Also, you might want to think about whether you really need all of this to work within a frame, or if you can delay it for a frame. The answer is in most cases that you can actually delay it, as the player will probably not notice it when running 60+ FPS
Manually calculating the distances on the jobs instead of Physics2D.OverlapCircle massively increased performance. I'll keep working on it with this info
you guys were a huge help
I'll probably spread it out over frames eventually since the circles move slow, so it would definitely be unnoticeable
if I correctly start the jobs at the beginning of the frame, then use lateupdate to read the values it should be much better
trying to copy a dictionary to a nativemultihashmap but it seems to copy in the wrong order somehow cs NativeMultiHashMap<int2, Color32> _colorTerrainTiles = new NativeMultiHashMap<int2, Color32>(colorTerrainTiles.Count, Allocator.Persistent); foreach (KeyValuePair<int2, Color32[]> kvp in colorTerrainTiles) { for (int i = 0; i < kvp.Value.Length; i++) { _colorTerrainTiles.Add(kvp.Key, kvp.Value[i]); } }
or its the loading part that gives the wrong order ```cs
public Color32[] GetSprite(NativeMultiHashMap<int2, Color32> src, int2 name) {
Color32[] colors = new Color32[terrainSpriteSize * terrainSpriteSize];
int i = 0;
bool found = src.TryGetFirstValue(name, out Color32 item, out NativeMultiHashMapIterator<int2> it);
while (found)
{
colors[i] = item;
found = src.TryGetNextValue(out item, ref it);
i++;
}
return colors;
}
or is there a better way to do this
order of keys is undefined. Pretty much same with Dictionary, they dont preserve order
well I mean the order of the color array in the Dictionary
if you need to ensure a specific order you could have the dictionary provide an index into two arrays
I don't know.. it seems that the color array is just upside down
oh hmm ๐ค
i never cared about the order, but maybe it appends to values instead of add as first ?
I'm not sure myself on that but in this case yeah, a order on the color array is needed
so the sprite isnt flipped :P
I need a break by now anyway, I've been trying to refractor my code to work with Burst for the past 15 hours straight so
I have my map covered in chunks, each chunk has a different mesh (allthough same material). Should I give each one a rendermesh component (but then each has an own archetype right?) or just use Graphics.draw to draw them?
Okay, I've gotten to the point where the code that initializes my job's native arrays are slowing down the game. Is there a better way to get pre-existing data from a list without iterating through the entire thing every time?
maybe I need to switch to actual dots...
you can allocate with Persistant and fill it and use it on your job everytime
the only issue is that my amount of objects is dynamic
and removing the correct indexes can become tricky...
if I used nativelists, that is
well if its changing then you have to create it everytime
if only I could efficiently access static fields from inside a job
I would never have to iterate through my static lists on the main thread
you can capture it locally, tho they need to not to have any reference type
I wonder if I could create a secondary list of the value type field im trying to get and do that instead
although I'm exactly not sure what "capture it locally" means
can I directly set a nativearray's data in the initialization?
without iterating through and setting each index?
sooo.. is your list changes during runtime ? or is it static ?
well, it's changing during runtime. I just meant that it has the static keyword (irrelevant to issue)
I'm accessing it from another static class
i mean if it changes then you have to create your native array everytime right ? you cant just make single initialization and send it to your job.
correct, but NativeLists exist, I just don't know how to use them. I don't know how applicable it is in my situation
it doesnt matter i think, you will be still iterating thru your list
if you can explain your case maybe people can help better
I was thinking that I could have a NativeList of float3s, add my positions I want to access to that float3 NativeList, then use that NativeList as a parameter of the new NativeArray constructor by using NativeList.ToArray
that way there is no iteration happening
although I don't know how those functions work behind the scenes
so it might just be the same thing
what are you iterating right now exactly ? You iterate your list to fill your native array/list right ?
yeah
I was just wondering if there was a way to bypass the for loop iteration that fills the native array
something like what I described above
yeah but on that example you will be still iterating your list to add values to your native list
it doesnt bypass loop iteration
no, because a NativeList you can just use .Add(new data)
and I would use this overloaded constructor for my NativeArrays
NativeList has a .ToArray as well, so that's what the array parameter would be
Well i am sorry, i didnt understand your problem, but hope that works out for you
also you can use AsNativeArray i think instead of ToNativeArray
no problem, you helped a lot getting me to this point already
Also, I didn't really have a "problem" per se, I was mainly throwing around an idea I had incase somebody already knew it didn't work. It would take quite a bit of refactoring just to try so I was just trying to save some time
You want to copy a subsection of your array to another array without a for loop, is that right?
I have an array of instantiated classes, and I want to copy just a certain field from each copy of the class into a new array of just that field's type
Right now I'm just doing this
readPositions being:
Yeah I don't think there's a better way to do that without restructuring how you're storing your original data
https://docs.unity3d.com/ScriptReference/Jobs.TransformAccessArray-ctor.html maybe you can access the transform access array? ๐ค
Sadly I also need another field that isn't part of the transform
so I'm doing two fields at once, I'm just using the position one as an example
public Vector2 targetDir;
I also need this from every copy of the class in the list
Right now you're working with your data in an OOP way. That's fine but it's definitely not going to be burst compatible. Ideally you would have separate flat arrays with your different kinds of source data (position and targetdir). That may or may not be practical for you so if you need to stick with an Array of Objects then what you're doing seems like the right way
if you want to edit some properties at runtime, how would you do that (for testing). In vanilla unity I could just edit the script variables on my gameobject. Should I now do the same and then use OnValidate to somehow propagate the properties to some systems or entities?
I think right now the idea is to use subscenes for tweaking things through the editor
Unfortunately they're very poorly documented right now. https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/ECSSamples/Assets/HelloCube/3. SubScene
there is a "trick" you can do with this. Do not copy data
@junior fjord You would use livelink with editing mode
leave it on the native arrays, and have getters/setters for it on your monobehavior stuff that just access the nativearray
It will take a while for me to figure everything out if switching to dots is the best alternative, but I'll explain my situation. I want (hundreds - thousands) of, essentially, boids that have a form of local avoidance on them. I have never worked with dots before this project, but that seems like something dots would be able to handle at high framerate. I just have no idea how monobehaviours interact with entity objects
Oh interesting, so the MB is like a proxy for the actual data in the native arrays
hmm I never used this livelink
I just have no idea how monobehaviours interact with entity objects They don't, pretty much
have no idea what it is ๐
yeah, I'm very used to monobehaviours so I just went this route when trying to implement the job calculation
@vagrant surge yeah that is the idea I also had
@zenith wyvern indeed. That is a classic
the monobehavior stores its "index" on the arrays
and on its getter-setter, it accesses those
While you're transitioning you might want to just design your system to work directly with your monobehaviours. If you use "convertandinject" on your monobehaviours you can access them directly in systems like
void OnUpdate()
{
Entities.WithoutBurst().WithAll<SomeTag>().ForEach((Transform t)=>
{
t.position = wahtever;
}.Run();
}
This will give you an idea of how things start to work once you use entities directly
Performance will not be great but yeah
alright, I can also create some dummy projects for learning purposes
the small amount of documentation doesn't help though, but it seems fairly straightforward once you get it
Imo trying to force performance out of MB is not the right approach, better to just use the systems to operate on your MB then go from there
So an entity cannot have any form of monobehaviour controlling it at all?
Technically you could, but it would be horrible code and is entirely contrary to how you're meant to do things
I guess I'm just confused at how an entity relates to a gameobject. Like, in what way can I access any sort of gameobject data like a trailrenderer component (for example)
You should just treat your monobehaviours as entities until you're comfortable with the workflow, then you can transition to entities
If you do the ConvertAndInject like I suggested above all your components on that gameobject get attached to the entity behind the scenes. So you would access your trailrenderer in the same way you access the transform in the code I posted above
alright, that makes sense
You pass it as an argument to the lambda
Does anyone know if this is the way I normalize a float3 in a job? math.normalize(Bezposvelocity)
the output doesn't seem to change
if your input vector can be very small you better use normilizesafe๐ค
yeah I'll try that thanks, and as usual I'm being an idiot
just noticed it returns a value
I don't suppose anyone knows why I get this error when trying to schedule a job
The previously scheduled job BezeirtestJobComp:<>c__DisplayClass_OnUpdate_LambdaJob0 writes to the NativeArray <>c__DisplayClass_OnUpdate_LambdaJob0.Data._lambdaParameterValueProviders.forParameter_moventy._type
is there more to it ?
there's another error Missing Profiler.Endsample
probably 2 jobs accessing same nativearray and they are not in dependency chain๐
or you have to disable protection for parallel thingie, depending on what you are trying to do
It's a safety system error. Look at which jobs are accessing your component and where
yeah I thought it might be something like that but one is only using a readable translation and the other readable rotation
they are both reading from a blobasset but that shouldn't be the problem surely
it says you are writing to some NativeArray
It's telling you what the problem is - the first parameter of your lambda
Whatever that component is, you're writing to it somewhere and the safety system can't resolve that dependency for some reason
you mean this Entities.WithAll<TestMoveojbectTag>()
does that tag have to be readable ๐ค
are you using JobComponentSystem or SystemBase
JobComponentSystem
Are you properly returning your job handle? Do other systems that access that component do so properly through a query?
the code is kind of a mess, theres a ton of commented out code 
i think it must be a conflict with one of the GetSingletons, I had it on Alwaysupdatesystem turned that off now it doesn't run at all
You should only call GetSingleton through an entity query
Otherwise yeah you can end up with dependency errors
I don't know if it's a bug but I've had that too where calling system.GetSingleton<Component> doesn't properly resolve the dependency for Component. Doing it through an entity query lets you properly declare the read/write access as well
yeah I guess its running before they exist and then creating errors because of it
@zenith wyvern how do you do it ? i am aware of that as well but was wondering how could i do otherwise
you make the entity query and do to entity array or something ?
entityQuery.GetSingleton
oh hmm ๐ค
@pliant pike Create the entityquery to access your singleton, make sure you specify the proper read access, and pass your query to RequireForUpdate inside OnCreate
what is the easiest way to add a component if not existent?
if(!HasComponent<X>(e))
ecb.AddComponent<X>(e);
?
This will prevent your system from running until the singleton exists
yeah, I'lll try that thanks
Err not inside OnUpdate
Inside OnCreate
RequireForUpdate only need to be called once
yeah I've used requireforupdate before
ah and also. Is there an easy way to make an entity follow a gameobject?
Basically what I am missing is something like transform.toLocalToWorldComponent, s.t. I can just use the transform of the MB to write the component of the entity
ah ok I can just use convert and inject GO
you can also use CopyTranformToGameObject or FromGameObject, depending on what you want to do
after I injected the gameobject, how do I get the entity that was created?
ah ok probably I have to write this own script that adds components to the entity or something on conversion right
I remember something
@opaque ledge ah ok that is also good thank you
anyone know what package this junk is defined in?
how how I can find out that answer on my own?
I guess maybe this wasn't supposed to be released and I should just downgrade back
0.8.0 works fine on 2020.1b
oh
I guess that makes sense... preview packages go with pre-release unity. Im dum thanks!
@slim nebula For now, actually most packages should work with 2019.3
Although I'm unsure if 0.8 was updated
it def doesn't work for me. I just grabbed 2019.3.5f1 and got those errors
it's fine tho, I can use preview unity. I assume it wont crash every 5 seconds
every hour or 2 is fine
Did you try deleing your library folder and restarting?
I know, it's stupid. But a sometimes it does fix things like that. Not all the time, but sometimes
would deleting my library folder make the class definition appear somewhere?
I'm not sure how this all works
Unity may not have imported the package properly if there was an earlier version existing
sorry if that's a dum question
oh ok
alright I can try that
thanks!
yeah looks like I still get the errors with 2020. I'll try the library folder thing
ยฏ_(ใ)_/ยฏ
I have no idea what I'm supposed to do here
deleting the library folder made it regen some stuff but problem still happens
any chance someone could put "IVisitAdapter" in their code, right click go to definition, then tell me what assembly it's supposed to be in?
Unity.Properties
thanks bud
I can't find that assembly
is that in a package? or should that be in the editor?
its a package, technically it should be automatically grabbed as a dependency
properties, i think its hidden but click the entities package it shows you what it depends on
im seeing 0.10.4-preview needed for 0.8
where/how do you see that?
how do I get to that UI?
this is from package.json in Entities package folder
but it should be installed automatically๐ค
but do you have this package installed? ๐
I tried downgrading then upgrading. maybe I try uninstall reinstall of the package
that checkbox should mean it's installed right?
i mean properties package
1.1.0
so... it's not updating it
and it's not in package manager, so... I guess I have to manually review the dependencies of every package I have and update some packages file manually with a text editor?
just delete the folder(not the entire library) and see if it reimports the correct version
shouldnt need to manually edit the manifest, also unity might just override them when you run it
yeah unity.properties is not in the manifest
the properties folder that is
yeah its not in mine either, its just a dependency of entities
maybe some other package requires some other version and it's picking that one
oh
1.1 is higher than 0.10

I'm not entirely clear on the dependency tree
i do think were approaching or in package dependency hell ๐
yeah
what does unity.platforms do
rofl I know I should know this if it's in my project
I think I need to downgrade this so other dependencies don't break
anywho
I think I have all the info to solve the issue now
thank you guys so much
i think platforms is related to building the project
kk
I"m thinking I dont need that right now
I can add it back once they merge the 0.10.4 changes into 1.1+
no wait
wtf
entities requires platforms 0.2.1p4
no that's right never mind
yeah platforms 0.2.1.x is fine
0.2.2 breaks it
yeah downgrading that made all the errors go away
unity automatically downgraded unity.properties

im so happy
yeah platforms 0.2.1.x is fine
@slim nebula thanks a lot! had the same problem and was looking through all the packages, somehow missed that one though!
still dont understand why my color32 arrays in a dictionary become "upside down" when transferred to a NativeMultiHashMap
Nmhm is unordered by design. Any order you notice might change at any time for any reason.
Basically it's not the right container to use if you need your values in a certain order
huh alright.. having this lil problem right nowg
when doing this cs NativeMultiHashMap<TerrainSprite, Color32> _colorTerrainTiles = new NativeMultiHashMap<TerrainSprite, Color32>(colorTerrainTiles.Count, Allocator.Persistent);
the struct is this ```cs
public struct TerrainSprite {
public int terrainID;
public int variantID;
public bool[] bitMask;
public TerrainSprite(int _terrainID, int _variantID = 0, bool[] _bitMask = null) {
terrainID = _terrainID;
variantID = _variantID;
bitMask = _bitMask;
}
}
Pretty much what the error says. You need to implement IEquatable for TerrainSprite.
@zenith wyvern If nmhm is unordered, then what uses does it actually have?
mmm do i need to explicitly dispose Temp allocations?
@mint iron You need to explicitly dispose any allocation in DOTS
Temp allocations should be disposed within the function call though
hmmm, this seems to suggest they automatically get disposed https://jacksondunstan.com/articles/5446
@bright sentinel When you need to store list of something you can access by key but the order of the list isn't important.
And no you dont need to dispose temp containers
They get disposed automatically at the end of the frame
so bools arent blittable? what do I use instead
A bool is blittable. An array is not
alright but i switched that array to a NativeArray
still doesnt work though
public struct TerrainSprite : IEquatable<TerrainSprite> {
public int terrainID;
public int variantID;
public NativeArray<bool> bitMask;
public TerrainSprite(int _terrainID, int _variantID = 0, NativeArray<bool> _bitMask = default) {
terrainID = _terrainID;
variantID = _variantID;
bitMask = _bitMask;
}
public bool Equals(TerrainSprite other) {
if (other.terrainID == terrainID && other.variantID == variantID && other.bitMask == bitMask) return true;
return false;
}
}```
never used IEquatable so that might be wrong
@zenith wyvern So the best option if you have a 2D array structure is that you would probably just flatten it to a 1D array?
A NativeArray is not blittable either. You cant have nested NativeArrays
so what else then
@bright sentinel Yes
If you're doing a bitmask, why not store as int instead of bool array?
Why are you trying to store an array of books in your Sprite?
Why are you all writing 'book'? ๐
Wow phones really dont like that word
well for the bitmask, but yeah I could use ints
Lol phone
or do you suggest just having a variable for each bitMask value
Yes any variant is a single value of the mask that's the point
So a single int should tell you which variant it is. That article explains how to calculate the value based on the state of a tiles neighbors
well you cant just set a int to "0000"
Sure you can: int i = 0;
ig
Just try going over the article again, you're on the right track
alright thank you, only one thing I want to solve before doing all that, the color array still seems to be added up side down
which I need to fix
Ditch nmhm, store your data in a collapsed array
Since you're storing colors of a bunch of tile varisnts it could end up being a very large array but the math to get the proper index is pretty straightforward
Tiletype * (TileSize * NumVariants) + (Tilesize * Variant)
Gotta go back to work, good luck
well the variant is not what you think it is; each terrain type has a secondary color array, which I get at random and then theres the bitMask, all the bitMask ones have some sort of transparent part which gets replaced with the variant
@zenith wyvern
but yeah, I should probably use something else than NativeMultiHashMap since its pretty slow
@zenith wyvern yeah I have to change to something else than a NativeMultiHashMap because it just picks it really randomly. both these sprites are the same (though different colors) but the NativeMultiHashMap has them rotated weirdly somehow
still not sure what to do about this
Like I said the order values are stored in is basically random so theres no point trying to reason about it. I'm not sure what the best alternative is, your variants are a lot more complicated than I thought compared to that first picture you showed.
yeah.. cant figure out a good way to store the colors where they are not random
There is no container that can hold other native containers or is there?
how it looks like with the NativeMultiHashMap
how it looks like with Dictionary
soo yeah
you could try adding your keys to native list, and when you are reading from native multi has map you could iteratave over that keys
something like multihash[keys[i]]
well you cant access a mutlihashmap with []
ah right i mean, multihash.GetValuesFromKey(keys[i])
also though its not the key part that gets messed up, its the colors in the values
well just reverse it then ?
create a new native list and iterate from orignal list's end to start
I'm guessing its this part that messes it up ```cs
public Color32[] GetSprite(NativeMultiHashMap<TerrainSprite, Color32> src, TerrainSprite name) {
Color32[] colors = new Color32[terrainSpriteSize * terrainSpriteSize];
int i = 0;
if (src.TryGetFirstValue(name, out Color32 item, out NativeMultiHashMapIterator<TerrainSprite> it)) {
do {
colors[i] = item;
i++;
} while (src.TryGetNextValue(out item, ref it));
}
return colors;
}```
seems fine to me
well then, I guess its the part what converts the dictionary to the nativemultihashmap ```cs
nativeColorTerrainTiles = new NativeMultiHashMap<TerrainSprite, Color32>(colorTerrainTiles.Count, Allocator.Persistent);
foreach (KeyValuePair<TerrainSprite, Color32[]> kvp in colorTerrainTiles) {
for (int i = 0; i < kvp.Value.Length; i++) {
nativeColorTerrainTiles.Add(kvp.Key, kvp.Value[i]);
}
}
that also seems fine to me
are you writing to it again somewhere ?
i will do some testing soon about this
alright thank you
by soon i mean it can take a while, since i am downgrading my project ๐
how long we talkin? ๐
well 10 mins if everything goes well, 2 hours if not xD
ah thats fine
in meanwhile, while you are retrieving values from the multi hash map, can you use GetValuesForKey(key) instead of TryGetNextValue ?
so get rid of the whole loop?
yeah, but ofc dont remove that function, just do GetSprite2 function ๐
yeah yeah, just commented :P
not sure what to do with this
tried just doing colors = src.GetValuesForKey(name); but thats a lil too simple I think :P
should be something like
var valueEnumarator = multihash.GetValuesFromKey(key);
int i = 0;
while(valueEnumarator.MoveNext()){
color[i] = valueEnumarator.Current;
i++;
}
yeah because it doesnt return an array, it returns a enumarator ๐
Yeah, I'm not quite used to the whole native thing yet
yeah, maybe they will make a function to return native array instead of enumarator
alright!
its either there is something weird going on in your code or order is not guaranteed in values of a key
im guessing its the order but can only wait and see your results :P
huh i found your problem i think ๐
This is actually kinda weird behaviour
if allocation size is exceeded then order is not guaranteed
if not then its guaranteed
@odd cipher
not sure what you mean
nativeColorTerrainTiles = new NativeMultiHashMap<TerrainSprite, Color32>(colorTerrainTiles.Count, Allocator.Persistent);
you are exceeding colorTerrainTiles.Count, just give it to some arbitary number, lets say 5000, then see the results if its fixed or not
nope, still the same problem
hmm are you sure ? well i am still getting reversed array, so its somekind of a FILO structure
This is when allocation is not exceeded
actually yeah, youre right, it does change but its still reversed
yeah its FILO
havnt heard of the term
so you have to reverse it ๐
First in Last out
have you ever worked with stack structure ? stack is FILO
And this is when allocation is exceeded
You did it! ๐ it works now
\o/
though I would rather not have a hardcoded size
yes ofc^^ but the thing is that allocation is for key+values i think, not just keys
yeah
so lets say, if you think you will have 10 keys with 10 values each, you should have 110 i think
well, i am going to have a happy breakfast now ๐
gl out there
so, I'd just do a loop to count, as this is only done at the start of the game I think that is fine
int count = 0;
foreach (KeyValuePair<TerrainSprite, Color32[]> kvp in colorTerrainTiles) {
for (int i = 0; i < kvp.Value.Length; i++) {
count++;
}
}
nativeColorTerrainTiles = new NativeMultiHashMap<TerrainSprite, Color32>(count, Allocator.Persistent);
foreach (KeyValuePair<TerrainSprite, Color32[]> kvp in colorTerrainTiles) {
for (int i = 0; i < kvp.Value.Length; i++) {
nativeColorTerrainTiles.Add(kvp.Key, kvp.Value[i]);
}
}
thatll do
little tedious I suppose
Even if it's moddable, the mod adds a "new tile", you just add "new tile" to your mapping and give it a new number, then internally represent "new tile" with that number.
@lusty otter heyo, wondering if you are able to talk more about your suggestion?
since I'm gonna need it
Anyone got entities 0.8 working? I'm having some errors after upgrading.
com.unity.entities@0.8.0-preview.8\Unity.Entities\Serialization\BinaryPrimitiveAdapter.cs(10,11): error CS0246: The type or namespace name 'IVisitAdapterPrimitives' could not be found (are you missing a using directive or an assembly reference?)
is just the first
so I guess there's some kind of package version alignment I've got wrong
is your platforms package 0.2.2 ?
yes
downgrade to 0.2.1 ๐
this is like.. 2nd this happening, for some reason latest platfroms package isnt actually compatiable with current packages for some reason ๐คท
yeah, its the downside to all these packages
hopefully they'll figure it out
they talked about a verification/testing thing that would ensure we got correct version compatibility
I've seen some threads that they are quite aware of the package problems that are present and are trying to figure out a way to solve this
But it will probably take a bit of time before that solution is rolled out
only one more thing until I can use burst with my code, and thats the fact that I use string names in the Terrain Type / Building Type / Item Types