A highest-performance C++ template-based data container for high-modification scenarios with unordered data.
#archived-dots
1 messages · Page 117 of 1
Oh wait so it’s an array with holes implementation like from that one that bitsquid blog?
its stronger
but yeah its array with holes
you insert something, and it gives you a handle (for when you want to delete it). But the pointer never changes
Does it use a bitfield for free list indices?
its a freelist too, but does bitfield to speed for the jumps
And I imagine to keep iteration from reading data wrong or writing to the free indices
extremelly useful when making graphs. You allocate the nodes on this thingy, and then connect nodes to each other through normal pointers
I wonder if that would be good for smaller pathfinding grids
for small, pushing the nodes on a dumb array and keeping indexes is easier
Being able to iterate with consistent striding but also skipping big areas of nothing could be nice
i wonder if unity has something similar to this on the NativeStuffs
Could probably make one using native arrays at least
What I’d really love to see from Unity is opening up our ability to do allocating
Like a small allocation slab system and a large allocation buddy system would be amazing
We kinda have void pointers now via some of their extension stuff
i havent heard of such things, how is it more useful than malloc'ing stuff
More specialized, so better in some cases and worse in others
Stack, slab, pool, free list, ring, buddy, there are just a lot of different allocation methods and it’s really case specific whether you’ll get more out of one than another
@mint iron frame-based allocations
you could have an allocator that just autoresets every frame
the idea being that whenever you need "temporal" allocations, like to do an algorithm, you use this thing
allocating is literally doing ptr += alloc size
deallocating is "ptr = 0"
Slab allocation is great for specific sizes of allocation you know you’ll be using a lot of, and that you’ll be using the entirety of, and (among slabs) that you don’t care about the fragmentation of.
once you try going into the more complex ones, it kinda stops being useful
well, ECS uses a pool allocator for the chunks
thats why all the same size
Makes sense
Buddy allocation is a nice compromise for large allocations of varying sizes
And benefits from no external fragmentation
Meaning you just have one big reserved allocation, and keep splitting it. And it may get internally fragmented, but it won’t mess with the rest of the heap
And any time two adjacent blocks become free, you merge them into a bigger one
Keeping internal fragmentation generally pretty low
As i understand it some system has given you a ptr and promised a size from that onwards is yours to mess with. When you free it, said system knows that area is available to be given to someone else. that correct?
Yeah, any allocator is just a system for reserving some number of bytes and then freeing those bytes again for another reservation
And yeah, by that metric if you’re doing stuff within an array you’re kind of using an allocator
so are those things you're talking about - pool, freelist, ring etc are a layer on top; ie. reserve a large piece, and build your own system to distribute smaller pieces of it more intelligently?
Yes and no. They are very often used to reserve the space within which you’ll be placing and organizing data with additional structure, but you can use them for whatever
Same could be said about arrays
Or a byte
“I need to store some information, where do I put it and what happens to the location when I’m done?”
Is about the size of it
ok, i guess where i'm confused is that i've put all sorts of crazy containers on a space i've used malloc to acquire. And im not sure if thats the level you're talking about, or if these allocation systems are lower level than that like windows core level.
It is the same level
Really we just have one block of memory, and the OS is already doing something with some of it, so we get some memory through the OS and do...something with it
Any time you have something you put somewhere in memory, that’s memory management
Static variables are memory management, you know exactly what they are and where they need to go and that will never change
ty i appreciate your patience 😄
A C# list is memory management, you’re using some but not all of an array and then you might use more so you get a bigger array
You want to get memory to store your information, you want that memory fast, you want it close to memory you’ll access with it or right before or after it, and then you want to get rid of it fast when you’re done and make sure that it’s usable when you need it again. And you want to make sure you’re not fragmenting memory so that the effective space you have to work with is less than the total space
There is only so far you can get trying to get all of these things at once in one solution built for every use case, so to get better performance you use memory allocation strategies that fit your use cases
that makes sense. when i try to find info on what malloc does all i can seem to find it what its used for and how it operates. Also i know this is totaly not he place for this sort of discussion 😄 but yeah, its kinda frustrating i don't know where to learn this.
ahh nvm "malloc is part of the standard library and is declared in the stdlib.h"
this seems to clear up a lot for me: https://en.wikibooks.org/wiki/C_Programming/stdlib.h/malloc#Implementations
Malloc uses allocation dependent on the OS, unless someone overloads it haha
Getting memory from the OS has extra expenses
But fundamentally it’s doing the same stuff
whats the correct way to fix this:
it happens when I update unity
first time it happened, I removed havok physics and added unity physics. and that fixed it
but this update I remove unity physics and re-add it and the errors are still there
any ideas?
and this one is new:
it might be that the newer package requires a newer version of the editor; burst was particularly bad for that sort of thing.
Hello. Does anyone knows how to use [ReadOnly] on the parameters of Execute method inside IJobForEachWithEntity. I'm trying to use it like this examples, but I cannot find the namespace of that attribute type. https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/entity_iteration_job.html
Or what is the current proper way to mark a component as readOnly in IJobForEachWithEntity?
Nevermind, I found it.
I updated all my packages before that screenshot. maybe they havn't quite updated it all yet on package manager
@slim nebula can you show a screnshot of your package manager for tab "In project"?
also, do mention which Unity version you are using
okay so i have this piece of code in a MB
var recruitmentFleet = entityManager.GetBuffer<FleetRecruitmentReserveBuffer>(data.entity);
var playerFleetBuffer = entityManager.GetBuffer<OwnedFleet>(CampaignManagerMono.instance.campaignPlayerEntity);
var playerFleet = playerFleetBuffer.ToNativeArray(Allocator.Temp);
for (int i = 0; i < recruitmentFleet.Length; i++)
{
var recruit = recruitmentFleet[i];
var index = playerFleet.IndexOf(recruit.ID);
if (index >= 0)
{
var playerShip = playerFleet[index];
playerShip.Amount += recruit.amount;
playerFleet[index] = playerShip;
}
else
{
playerFleetBuffer.Add(new OwnedFleet { ID = recruit.ID, Amount = recruit.amount });
}
}
playerFleetBuffer.Clear();
recruitmentFleet.Clear();
playerFleetBuffer.AddRange(playerFleet);
What does this do is, this is called by the button in UI. Basically player recruits ships from the station
if i do AsNativeArray, instead of ToNativeArray in playerFleet, it gives me error saying that this native array has been deallocated
I was just wondering why would it be like that
"You can only access the native array as long as the the buffer memory has not been reallocated. Several dynamic buffer operations, such as Add(T) and TrimExcess() can result in buffer reallocation." from the docs
@opaque ledge So the AsNativeArray is a reference to the same data that the buffer is referencing, while ToNativeArray makes a copy of the data
And changing the buffer will break the reference that AsNativeArray gives you
I have a Component CreateMesh which I add to some entities. Then some systems run over these entities and do stuff. Afterwards I just want to remove the component from all the entities that have it, the best would be if that would happen without copying them around
is that posssible?
In your system that runs over them, just delete them with the EntityCommandBuffer
wouldn't that copy each entity one by one from one chunk to another?
or does it realize that the whole chunk just lost that component?
Hm, I'm not sure if you can do structural changes without copying
Maybe some chunk job can help you, but I haven't used them before
Ah yeah
Oh, nvm
"Although chunk components can have values unique to an individual chunk, they are still part of the archetype of the entities in the chunk. Therefore, if you remove a chunk component from an entity, ECS moves that entity to a different chunk (possibly a new one)"
yeah I also just read that
there is this method in EntityManager and command buffer cs .RemoveComponent<T>(EntityQuery entityQuery); 🤔
my bet that this is the one of the fastest way to remove component from a lot of entities🤔
ah i see thanks, i guess adding to buffer causes that
does anyone see why this
Entities
.WithName("RemoveCreateComponent")
.WithAll<CreateMesh>()
.ForEach((ref Entity e, int entityInQueryIndex) =>
{
commandBuffer.RemoveComponent<CreateMesh>(entityInQueryIndex, e);
})
.WithoutBurst()
.Run();
gives me invalid ForEach signature?
@warped trail oh and thanks for the suggestion
You can do this and continue working with your createMesh, maybe some other systems will want this component too and you will be sure that next frame all this components will be removed 😅 👍 ```cs
BeginInitializationEntityCommandBufferSystem m_StartOfNextFrame;
protected override void OnUpdate()
{
var commandBuffer = m_StartOfNextFrame.CreateCommandBuffer();
commandBuffer.RemoveComponent<CreateMesh>(queryWithCreateMesh);
}
oh thats also a good tip
is there anyway to make a const size array global?
I just want to add a global to my Globals class that is a 6-element int2 array (known at compile time)
Hmm, what's the simplest way of doing this in dots?
void Deactivate(){
rb.isKinematic = true;
collider.enabled = false;
}
void Activate(){
rb.isKinematic = false;
collider.enabled = true;
}
likely removing the phyics component
to change body from dynamic to kinematic you can simply change PhysicsMass
inverse physics mass i think
just look at PhysicsComponents.cs
@dull copper as requested
there's more checkboxes under "all packages" that dont show up in "in project"
I think that's everything
yeah, those should be up-to-date
oh sorry the unity version is 2019.3.4f1
Does anyone know a better version of this that can be used in jobs:
public void neighborValues(NativeArray<T> ret, int2 loc, T offMapValue)
{
var neighborOffsets = new NativeArray<int2>(6, Allocator.Temp);
neighborOffsets[0] = new int2(0, 1);
neighborOffsets[1] = new int2(1, 0);
neighborOffsets[2] = new int2(1, -1);
neighborOffsets[3] = new int2(0, -1);
neighborOffsets[4] = new int2(-1, 0);
neighborOffsets[5] = new int2(-1, 1);
//..do stuff with neighborOffsets..
neighborOffsets.Dispose();
}
neighborOffsets is a simple, 6 element, always constant array which I need in that function
fixedlist?
an alternative would be to have it as a static and always mark it as readonly and pass it into the function
but that also seems utterly complicated for a global all-game constant
Oh - if you want to use that - you can the SharedStatic<> option in the BurstCompiler
https://docs.unity3d.com/Packages/com.unity.burst@1.2/manual/index.html#shared-static
was just looking at it
hmm but I guess you want immutable 🤔
otherwise maybe an entity with a FixedList or a BlobAssetReference to a struct w/ BlobArray and you pass that into jobs
yeah thanks, that looks interesting but I do not need mutability
But is that really the simplest solution? I mean I can have global const variables, and as soon as I want a global const fixed-size small array I have to always pass that into the function?
FixedList is some new kind of small arrays that can be inside of structs/components?
Have your guys update Entities to 0.7.0? There is a error about burst.
Not sure - but I remember seeing a few messages here about that - you might have to scroll up to take a look
@south falcon
yeah there was a lot of discussion about that earlier I think
but I didn't have the problem so I didn't follow
and thanks @coarse turtle
i don't have this errors🤔
Are you using unity dots physics?
yes
That's confusing
i remember there were some errors, but then i deleted Library folder and errors were gone
I have tried deleted library, but error still
if i'm not mistaken it is the recomended thing to do, if you upgrading your Burst package🤔
Now I am trying to downgrade everything 😂
@warped trail What is your Unity verision? 2019.3.4?
2020
🤔
Is it possible to use SystemBase for everything? Does it replace the JobComponentSystem? I don't have InputDeps.
Dependency is new InputDeps
yes, JobHandle is Dependency property now
Oh great so full SystemBase then
Is 2020 now the latest version of Unity with respect to DOTS (and other preview/experimental packages)? I remember someone from Unity saying once that 2020 alphas didn't have a lot of the stuff 2019 betas did.
next Hybrid Renderer will require 2020🤔
Does ecs and the hybrid renderer work with URP?
it kinda works😅
kinda works is good enough for me!
just turn of SRP batcher
thanks
there are many burst/job related improvements in 2020, but not any differences between packages
you can read alpha's last release notes if you want to know
Haha better be. "Kinda works" the DOTS M.O. right now
why there is no beta now?
Hmm ok. I'll give 2020 a shot tonight.
ikr Druid, i think its something with 2 tech releases per year
and iteration times are killing me. Create script file wait for 10 seconds to compile, then 6 seconds to reload, press play and there is another 4-5 second to update scene for what ever reason after first Entity instantiation🤬
of course i disable domain reload
and i like this new feature with timer, it shows exactly how slow things are😂
maybe something to do with closing subscenes ? i had something like that, i forgot to take subscene out of edit mode so it was taking like 12-13 seconds everytime i went in play mode
its taking 1 second now
Tho i destroyed my subscene, it.. isnt really useful for me
going into play mode is very fast
ah, nothing you can do about recompiling except asmdef, which i really dont know how to setup
I'm creating some entities programatically. how do I set the equivilant of Transform.Parent on the entity? I dont see any field on LocalToWorld there...
[EDIT] disregard, I found the Parent component to add to my entity
Note: Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
Does that mean no NativeArray in ISharedComponentData in the future?
ok so shared NativeArrays should rather go to static global classes for example?
well that is what I am doing 90% of the time anyways 😄
oh yeah you talked about a constant global array access right ?
have you checked shared statics ?
Well - i think native array will still have those safety checks (disposal sentinel) - but you could easily swap it with your own unsafe implementation
unless they removed that recently 🤔
@opaque ledge yeah, I checked them since @coarse turtle also recommended them but at a first glance they also seemed like an overkill (and also not readonly)
but maybe I'll check them again tomorrow
can someone help me. I'm trying to programatically create a child entity. and I just dont know what APIs to call. Is there some example somewwhere? My problem is that my prefab has a prefab. When I instantiate the top level prefab, the child prefabs aren't being instantiated. I'm not sure what I"m doing wrong 😦
[UpdateInGroup(typeof(ServerSimulationSystemGroup))]
public class GoInGameServerSystem : ComponentSystem
{
protected override void OnUpdate()
{
Entities.WithNone<SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
{
PostUpdateCommands.AddComponent<NetworkStreamInGame>(reqSrc.SourceConnection);
UnityEngine.Debug.Log($"Server setting connection {EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value} to in game");
var ghostCollection = GetSingleton<GhostPrefabCollectionComponent>();
var ghostId = ContinuanceFaultGhostSerializerCollection.FindGhostType<PredictedPlayerSnapshotData>();
var prefab = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value;
var player = EntityManager.Instantiate(prefab);
EntityManager.SetComponentData(player, new MovablePlayerComponent { PlayerId = EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value });
PostUpdateCommands.AddBuffer<PlayerInput>(player);
PostUpdateCommands.SetComponent(reqSrc.SourceConnection, new CommandTargetComponent { targetEntity = player });
PostUpdateCommands.DestroyEntity(reqEnt);
});
}
}```
^this is basically a copy of the sample
[DisallowMultipleComponent]
[RequiresEntityConversion]
public class MovablePlayerComponentAuthoring : MonoBehaviour, IConvertGameObjectToEntity, IDeclareReferencedPrefabs
{
public int PlayerId;
public GameObject PredictedObject;
public GameObject RubberObject;
// Lets you convert the editor data representation to the entity optimal runtime representation
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.AddComponentData(entity, new MovablePlayerComponent
{
PlayerId = PlayerId,
//RubberBandingData = new List<RubberBandingData>(),
//HistoricalPositionData = new Dictionary<uint, HistoricalTranslationRotationData>(),
});
var prefab = conversionSystem.GetPrimaryEntity(PredictedObject);
dstManager.SetName(prefab, $"Primary {dstManager.GetName(entity)}");
dstManager.AddComponentData(prefab, new Parent { Value = entity });
//var predictedEntity = dstManager.Instantiate(prefab);
//dstManager.SetName(predictedEntity, $"Debug {dstManager.GetName(entity)}");
//dstManager.AddComponentData(predictedEntity, new Parent { Value = entity });
//dstManager.AddComponentData(entity, new Parent { Value = predictedEntity });
//conversionSystem.DeclareLinkedEntityGroup(PredictedObject);
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
referencedPrefabs.Add(PredictedObject);
}
}```
^ I'm not sure what I can do here to make sure PredictedObject gets instantiated when my ghost is instantiated
I'd prefer not to instantiate all child objects in the GoInGameServerSystem
I feel that MovablePlayerComponentAuthoring should author the MovablePlayerComponent children
I've spent hours on this looking up tutorials and I"m totally confused and lost.
@junior fjord at first i thought the same 😄 the example in documentation might seem like an overkill but its just a matter of copy/paste 😄 and dont care about not being read only imo, its a quick way to reach some info that you set in MB that you want to use it in bursted jobs, they are quite useful, i use it for all kinds of stuff, especailly for Random(so whole game will use this random) and some other info that could be hard to describe with component datas and buffers.
I dont know about the performance however, never had a time to test it tbh
I did it!
var leg = dstManager.AddBuffer<LinkedEntityGroup>(entity);
leg.Add(new LinkedEntityGroup { Value = entity });
leg.Add(new LinkedEntityGroup { Value = prefab });
yeetsus
is netcode good enough for mmorpg yet
Never remembered to ask, for each frame, does Update in MB happen first or OnUpdate in SystemBase?
@lusty otter i think mb's Update runs before simulation group and LateUpdate runs after simulation group and before presentation group
Thanks!
netcode isn't good enough for anything yet
not surprising considering it is a alpha/beta/gamma release
@lusty otter With the EntityDebugger, you can show the full player loop to get the whole picture of where ECS fits in.
@gusty comet Eh, I wouldn't say it that drastic. It's good enough for what it's made for.
but it's certainly not made for MMOs
it was made for a demo... 😄
It's a bit more complicated, the demo was made to show it off.
Netcode is currently just made for FPS games though
So no MMO support yet
I doubt unity will make a specific mmo implementation for netcode, i think rts is on their list though
FPS, RTS and fighting is the current plan
Any idea why the breakpoint on continue hits but the output on the right says the entities are different?
Hm, seems Rider is messing up my breakpoints...
Never seen this...
If you are doing it on parallel job there will be some issues
@silver dragon https://www.youtube.com/watch?v=nou6AIHKJz0
Quick guide and some additional notes on the new native debugging support for Burst. Available from package version 1.3.0-preview.4. Timestamps are below for convenience.
Timestamps:
[0:13] Quick guide to debugging
[1:29] Current Limitations
[1:33] Threaded Debuggin...
Even if burst is disabled?
yeah probably
since there is no determinism between what thread will finish first, it might show you info from multiple threads
Shouldn't be the case as there is only one entity the system processes (for debugging purposes). Anyway, will have a look at the vid, thx for the link!
oh hey Tiny 2D
Ooo, anyone got a link?
@bright sentinel tiny forum
docs should be in the pinned
same with project tiny examples repo
that repo got two new examples to demonstrate 2D features
I spammed something about this last week here: https://discordapp.com/channels/489222168727519232/497874303463850004/685415283669729466
that webasm build was nicely tiny
2.5 megs for the match-3
how do they compare out of curiosity? or is there a comparison written up somewhere?
I'd guess that the other has decent editor tooling 😄
It's wild that you can make a Unity exe below 10 MB now
Yeah - i wonder if they're also going to have addressables integration
Playing with UI Elements runtime, but I'm not getting it to render.
https://i.imgur.com/Vyp2xOn.jpg
I guess I need to set target texture and panel transform?
I didn't see them do that in the UI Builder video
@remote coyote add defaultUSS to stylesheet list
and yes you should set panel transform as well
not sure what target texture does but i didnt use it and it works well
also disable enable live update imo, right now that takes too much time when going to play mode
@remote coyote not correct channel for this question, but you don't need to set panel transform or target texture 😉 What you've done wrong is to set your style sheet as the "Unity Style Sheet", which should be the Default.uss. Yours will be imported automagically.
anyone getting assertion errors when using Mesh as the physics shape type in the editor? I dont really recall this happening before but if you make a blank project with the phys package(and auto dependencies) and just test it out, it errors constantly 🤷
ah that was it, thanks CyrlyOne and Jaws! My heroes this evening!
what the heck is going on with deltatime vs actual physics simulation time
if I set the top value to 0.2, then my Time.DeltaTime is still 0.016666, but it changes the physics processing to perform 0.2 worth of physics
the result is that shit is moving 20x faster than the code is expecting
Should I just not use deltaTime? what should I be using?
or how do I configure the physics to behave
even now it's set to 0.01, but I'm getting 0.0166 deltaTime values
does the physics engine just not process a physics frame until enough time has elapsed?
You want UnityEngine.Time.fixedDeltaTime
ok I will try that, thanks
is there something I have to do to get my system to update on fixed frames instead of delta frames? (if that makes sense)
UnityEngine.Time.fixedDeltaTime seems to never be different than 0.01, but the system is being called every ~0.016 seconds still, so it's still desynched
do I just track the difference myself? do additional frames or skip a frame if needed? or is there some mechanism built in that I can use?
im so confused
am I not using UNITY_DOTSPLAYER ?
aha standalone dots vs hybrid
still not sure how it's magically doing more steps when needed
2 frames would be 0.032, which should mean 3 physics frames
DOTSSample does not appear to use fixedDeltaTime
which I guess is fine because their player controllers only interact with static objects 😩
this sample is such a hack job at every turn
oooooooo this looks promising
thanks sark!
I will work on this tomorrow (bed time for me now)
EnableFixedRateWithCatchUp is broken btw, or i'm doing something wrong with it😅
Hello, I am back with a new question on the ConvertGameObjectHierarchy method. Would you mind check the thread I opened for the same reason? https://forum.unity.com/threads/is-this-the-valid-pattern-to-convert-a-gameobject-now.843754/
When i tried to dispose blob asset store right after i converted some gameobjects editor crashes, now i instead dispose of it in OnDestroy method and it is working fine so far.
yes this is what I have experienced, but there is no official answer. no good
Is the Dots Netcode something more special or what should I be googling to find tutorials?
I have found it very hard to find anything I can work with properly.
Anyone got an idea?
there's not much in the way of tutorials yet at all
I worked from looking at the dots sample
and coded things myself from how I understand it after watching that
otherwise there is a get started example in their documentation
Okay thanks I will look into the get started example
good luck!
@static remnant The docs also has a getting started guide
It's slightly outdated, but should be easy enough to fix
I wish you could create a truly empty gameobject (like without a Transform). Then I could author entities without including unnecessary data.
You could always create entity thru code 😄
i think @scarlet inlet was working on something like that, not sure if he found the answer
oh for sure. Just have wanted that for a while anyway before DOTS (ie manager scripts that just need a host gameobject)
Thats probably will come with full DOTS editor, no idea when that will come tho 😄
I was trying to make a "create entity" menu item last night, where it creates gameobject and then destroys Transform. Impossible of course.
I think the only way right now is an authoring component that strips the transform component data off after conversion
yep pretty much^^
but i remember Sebas doing the same stuff, for simple gameobjects that can work but i think it wont be pretty if you try to convert a prefab with nested stuff and try to remove unncessary stuff
I don't think Transform is a necessity for hierarchy
but I agree that Unity will probably not do anything to GOs as we know it. Likely a separate authoring object if anything.
You're talking a special built-in? Because that's possible in user land already, right?
I think that's fine, but I think the optimal solution would still be a blank slate, where the workflow is that you're only adding components at conversion time, not removing.
But I understand the limitations in regard to how scenes work
This feels pretty low down priority-wise to me - given the current to-do list? It also seems related (at least in my head) to how code-generated entities will correspond to in-editor representation in the future?
oh absolutely low priority. just a wish list thing for me.
another option would be to override the Convert method
of built-ins
don't know how feasible
and also would be problematic if you wanted different conversion per entity. eh nevermind
Is the conversion thing gonna stick, or will it eventually be some other editor to put it togeather?
If you mark it as static it at least reduces the the amount of work done on it. But yeah, being able to make a non-transform gameobject would be great even outside ECS, just for organizational purposes
People have wanted it for many years
yeah, I like the conversion workflow
It would be useful to be able to organize related scripts/objects hierarchically without having it be tranform-related, for organization purposes in the editor
Having things in a hierarchy you can easily enable and disable in a click without it having any performance implications
I remember a blog post by a studio where they had almost all their go's nested for organizational purposes. They actually had a quite noticable performance improvement just by un-nesting their game objects. That's just silly. And organizing things in the editor hierarchy that way is quite common, it's not like some unusual use case
the real issue is conflating transform hierarchy with view logic
I've asked this before and gotten no response, so I figure I should ask while there's activity on the channel: Why does ConvertToEntity maintain the entity's name in conversion while SubScene does not?
even when I make a special NameAuthoring component, it does not convert :\
entity's name is more like debug thing i guess🤔
right, and I want that debug thing.
don't need it in build, just want to know which entity I'm inspecting in the debugger.
the real issue is conflating transform hierarchy with view logic
@sour ravine
Like I said doing it that way is quite common. Responding with "well they shouldn't do that" is unfortunate and pretty indicative of why people get frustrated with how Unity responds to common issues people bring up.
Getting pretty off topic at this point though so whatever
Gonna go put that question on a milk carton
lol I kinda do
but I can also be happy with the fact that I'm not insane and this isn't supposed to happen
Sorry, just a small somewhat unrelated question, how new is Asset DB v2?
as in, how long has it been in place
Ryan had let me know that my asset referencing issue was effectively unworkable due to how the build process works. I'm just curious if that is an issue that could be changing
well that is irrelevant then, even if it did change I'm not lucky enough to be on 2019
Ok, I think I'm tracking at a high level. But in that case shouldn't this still work?: ```using Unity.Entities;
using UnityEngine;
public class NameAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public string debugName; //Set to "Test" in the inspector
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
//dstManager.SetName(entity, gameObject.name); <- Ideal authoring workflow (other than automatic of course)
dstManager.SetName(entity, debugName);
}
}```
no😅
why not?
because they "don't serialise names"
NameAuthoring in subscene -> Converted -> Serialized -> No names
debugName is just a string, not the name field of a gameobject?
so you're saying that convert runs before serialization and gets stripped before seeing it in the debugger?
ugh
subscene is already converted and serialized data, so when you load subscene there is no conversion
so when I click "Close" on SubScene component, no conversion takes place?
for just a single instance where you need a name you could just make a one time component tag that has the name and filter it in the debugger, but obviously this gets less convenient for multiples
it converts and stores converted data to disk
yes, you can set name from systems, that will work
so I'd have to store the name as a true IComponentData and set the name through a system
You could set it during conversion. They dont serialize the editor names. They will serialize your component.
its interesting that in the new tiny samples
they dont use the automatic authoring conversion
for creating authoring components automaticall
Hi! Am i right understanding that new 2d entities feature is available only for DOTS Runtime / Tiny project? So there is no way to use it with some existing Unity dependent code?
no Unity engine code in Tiny😕
And there is no way to import 2d entities with 2d physics to Unity, right?
I think 2D entities has tiny dependencies
so probably not
yeah tiny deps, so no go for hybrid-ecs projects
Ok, thanks. Hopefully that will be fixed.
I'm working on a multiplayer 2D WebGL project. It's a weird spot to be in right now, because Tiny is the future of WebGL builds. And I didn't have 2D until about a week ago. And now I still need netcode. Just a bit of a waiting game right now.
And learning. Waiting and learning.
Currently lookng at the AngryDots example of converting GameObject Prefabs to Entity Prefabs in my own project and running into this error: ArgumentNullException: A valid BlobAssetStore must be passed to construct a BlobAssetComputationContext Can't seem to find anything on Google and the AngryDots example doesn't have this error so a little confused right now
manager = World.DefaultGameObjectInjectionWorld.EntityManager;
var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);
redEnemyPrefabEcs = GameObjectConversionUtility.ConvertGameObjectHierarchy(redEnemyPrefab, settings);
I think you just make a blob for null, and then dispose it after ie var blob = new BlobAssetStore() then at the end blob.Dispose();
an unity staff posted a link about SIMD in forums if anyone is interested about it
Day 115 of coding on Handmade Hero. See http://handmadehero.org for details.
that's pretty good video, he has few others on the topic too
watched those when they came out myself
@digital scarab 👋
Trying to convert a game template to dots 😅
Going to have another stab at it tomorrow to see where I'm going wrong with the conversion API
Does anyone have an example of how to spawn an entity with a mesh at runtime without using a Prefab? I was under the impression that I'd only need to add LocalToWorld, Translation, Rotation and a RenderMesh, but looking at the entity debugger of an existing entity, there's a lot more (like RenderBounds, ChunkWorldRenderBounds, and a few more). Do I need to add all of those manually?
@fallow kraken short answer - yes - I'm wondering if you can just use DeclareReferencedPrefabs and have the already converted prefabs
be readily available to instantiate
ok lemme google DeclareReferencedPrefabs first 😉
yea - it should be an interface - I haven't exactly used it yet so far but it might suit your needs
hmm but DeclareReferencedPrefabs assumes there's a prefab, right? which i don't have for that particular entity. i basically have a mesh and a material which gets generated runtime, and a position obviously.
Ah - I misunderstood - okay since that set up is similar to mine - yea I think you'd have to add those components manually
you can create the archetype and instantiate an entity with the said archetype and fill in the data as you go
yeah but i have no idea what ChunkWorldRenderBounds is for example... and i have the feeling that these will change in future Entities versions... they seem pretty low-level anyway
but i can dig into the authoring classes, maybe that gives me more clues.
I think that might be used to help determine culling - it's been a while since I used the hybrid renderer
alright, thanks! 👍
hmm, actually i can just create a game object and use GameObjectConversionUtility, that should work runtime, no?
(it does)
i am using World.GetOrCreateSystem to create a system, it seems to add it to the world and run oncreate but not onupdate and doesn't show up in entity debugger, is there something obv i'm missing?
also tried with [alwaysupdate] so it's not that
also shows up correctly in vs debugger when checking world's systems
also this is in editor at edit time
maybe ecs doesn't update systems at edit time? but other systems seem to (SceneSystem etc) without appearing to do anything weird that i can see
Is it a data dependancy issue where you don't have the required entities to operate on?
how do I define something so that a package is compiled with said define?
like a #define
If you mean an assembly definition in a Package for package manager, you just use the Define Constraints
nah
I think I found it though
project settings > player > other settings >scripting define symbols
um
UNITY_DOTSPLAYER is what I was trying to define
does the standalone dots player exist? or is that just something unity has for internal development
causes a bunch of errors for me
tiny uses it
the dots physics system runs every graphics frame and using the fixed timestamp... I'm not sure how I can work-around this...
so basically framerate dependant physics
I dont want this
who/what is tiny?
I dunno if im stoopid or if this is nor available yet, but I cant fine any download link
I see source for samples but I don't get it
does it still just use unity editor?
is it just different packages in the package manager?
yup ok
thank you!
update on my systems in editor issue for those interested
[ExecuteAlways] attribute works same way for systems, is required to get it to update in editor (apparently Rett mentioned this to me before but i forgot)
editor doesn't have a fps cap tho so it runs a lot
which is prob fine in most cases but i don't want to risk editor responsiveness so looked to cap it anyway
seems [ExecuteAlways] works on ComponentSystemGroup too so made an editor systemgroup, and apparently you can use UpdateCallback to define if it should update so am currently using that to make it update at a fixed rate
might use same way to update runtime systems at a fixed rate, dunno what the cons of that are
if it's that easy i wonder why it wasn't done already (since plans for fixed rate simulationgroup was mentioned like a year ago)
Anyone here ever tried to implement a state machine as a set of state-associated tables, like in the Data Oriented Design book?
Finite State Machines
For reference ^
Been struggling with the idea, because organizing data into tables, when that data is also mapped externally, means there needs to be some amount of indirection and/or copying and/or sorting, and it’s a bit hard getting a handle on what the common sense approach to take is
And I realize it’s context specific. What is the actual system or set of systems, what does the data look like, etc
But just inherently, it seems a little complex.
Actually I guess the issue is less FSMs and more operating on tables that map back to some ID-mappable data
I think a slot map data structure might be worth looking into
if you want the idea of like a 'graph' like data structure that is associated with some id mappable data
http://CppCon.org
—
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2017
—
We already have array, vector, and unordered_map, what other data structures could we possibly need?
As it turns out, there are a...
Is a slot map much different from something like a sparse set, or a hash map, or a free list with a parallel skip field?
it uses a free list to help build the structure
Well sparse sets do too, as does Unity’s entity mapping to chunk offsets
Does this try to keep data packed? Or keep it sparse but provide a way to locate the indices in use?
I think he describes a period where the data get compact if you do an insertion/deletion to the data structure
so it looks like it tries to keep it packed
Sounds sparse set-ish then
I love sparse sets as a data structure, they’re really useful for keeping data mappable, iteratable, and fast to insert/delete
One issue though, when you’re using multiple sparse sets as tables to map back to some original data array
When you insert and delete, the “swap back” behavior kind of jumbles up your iteration order of the original array
And you can sort, but that can be expensive too, especially since you’ll be potentially getting plenty of cache misses anyway due to not every table mapping to every data index
I don’t think there’s a way to “have it all” with perfect iteration, insertion/deletion, ordered access, etc when trying to maintain external maps to different subsections of a data array
But since there are multiple strategies for creating, updating, and changing those maps, it bothers me that I don’t have a good sense of what an okay default would be.
I think determining that might be hardware dependent - as in you want to optimize for the range of target devices that's acceptable and runs consistently - but that's my take since that's my primary goal
What would you say for something like Durango then?
You’re targeting Xbox, and for whatever reason you have a ton of FSMs to convert because they are all thrashing the instruction cache constantly. Out of order execution isn’t helping much
You have a scene with a bunch of characters, and there aren’t many additions/removals of these characters so character-normal data is pretty consistent. The data associated with the FSMs is character-normal, and used in enough transforms that you don’t think it’d be worth it to de-normalize it from the other character data for the purpose of making the FSM management easier
In a given iteration of your game simulation, the mutually exclusive state-based transforms will be reading from/writing to that character-normalized data, and potentially writing to state transition buffers for removal from/addition to FSM tables as well as state-transition-specific transforms
Assuming there’s a fair bit of state transition per frame (10% let’s say), where would you start with your tables?
One idea that came to mind for me was giving the original data an extra int map. That int would keep an index reserved in a free list, and when I wanted to add the data to a state table I would use that reserved sparse index to allocate a dense index at the end of a second array, like a Sparse Set.
The dense array of each table would point back to the correct offset of the original data array.
The original data array would also be backed a free list with a parallel bitfield, so its “allocated” indices would never change, meaning I wouldn’t have to use an additional indirection for if it moved.
The weakness here is that while table insertion and deletion would be fast and so would table index iteration, each index would not have data, and I’d have to eat the cost of the indirection. And in addition, with lots of table insertion and removal, those indices would start to scramble in order, meaning I couldn’t count on the cpu speculatively loading the next line of the original data array in order
So... with that said, how decent of a strategy is it? As a default strategy? Are there alternatives that work better as a default strategy for something like this?
If you wanted to do “data oriented” FSM with state tables, what would your first attempt look like?
guess what just got merged to SRP master?
Finally here 😄
it'll still take a good while to propagate to actual releases
Yeah, but at least it's closer 😛
@spring hare Hey just saw this - I think my first approach is an array which typically just store a tuple of the transition between states and what data the index element points to in some secondary array or sparse set .
[ (5, a), (3, b), (0, c), (2, d), (1, e)] -> store the transitions between each state and what data the state points to
[ a, b, c, d, e] <- stores the data for the fsm (indices denoted as letters instead of #s)
Yeah once you start doing a bunch of insertions and removals from this fsm you start to get this unordered set - but I think this is good as a starter approach
how can i store Entity in subscene without any default stuff like SceneSection,SceneTag etc.?🤔
@coarse turtle thank you, that’s really helpful
Editor has been crashing a lot lately when I go into play mode, for seemingly no logical reason.
For example if I add unreachable cases to switch statement, when entering play mode it will just hang when entities are being created. However if I build apk and run on an actual device, it runs all fine (as it should, because all I'm doing is just adding unreachable cases).
Do you guys know anything that could be causing this? It's killing my efficiency.
@spring hare https://www.plflib.org/colony.htm I came across this the other day but I didn't look too heavily into yet
A highest-performance C++ template-based data container for high-modification scenarios with unordered data.
Haha yeah I was looking at that one too. Was linked in this channel earlier in the week.
Ah lol didn't know that
@lusty otter might be some safety check on the editor side? Maybe something in the Editor.log says something?
There's no log I think?
For the unreachable cases, it doesn't actually crash it just hangs, I can close it but none of the editor UI works.
Oh - wait I have the same issue but it wasn't consistent 🤔
yeah idk - I typically just restarted unity without thinking too much about it - maybe I'll file a bug if it happens again - see if I can reproduce it
Sigh.
I've encountered reproducible crashes when I've had safety checks disabled and an exception thrown in a bursted job I think - but I guess you've already made sure safety checks are enabled
On MacOS it's 50/50 for me if I get a crash with DOTS or not.
which makes it pretty unusable.
even with simple examples
On my windows box it's much more stable, but it makes me uneasy..
Oh also.. rapid debug.log's reliably crash Unity for me (2019 & 2020) independent of machine - setting editor to vsync helps slightly but it's still not very tolerant
not sure if anyone else has found that
Which version of the editor+burst are you on?
me? every version in the past year and a half 😅 - windows
I mean, are you still crashing on the newest versions of each?
For me, latest 2019.3, all packages are up to date, I tried turning off job debugger, leak detection, disabled burst compile altogether, and it still hangs.
Hm, maybe the next version of Burst will fix that
Or so I've heard 👀
Not too sure about MacOS though
If I comment out the cases, which is not even being used, editor play mode runs all fine.
I guess it is a preview package after all but oh boy, this is frustrating.
I recommend to just report a bug and let them fix it
Is the built in bug report upon crashing the way to go?
I shall do 👍
My unity editor crashes now and then. I save a lot so I dont care, but I tried clicking the submit crash button and it kinda implied that my crash report wouldn't be looked at because it's not like I did something reproducable. Should I still submit crashes even if I have no idea why it crashed?
or is that just noise if my report quality is like 0....
I would hope that there is some stack trace they could look into, but I dunno if they just ignore it because the editor is scriptable
If it's not reproducible and you can't explain exactly how it happened then there's probably nothing they can do with it
ok
re: 2020 alpha, there is beta coming out any moment now
b1 have existed for like a week now
how stretched in time this moment is? 😅
there's https://unity3d.com/beta/2020.1b page but it still points to a25 which was released almost 2 weeks ago now
and https://unity3d.com/unity/beta/2020.1.0b1 page exists but isn't set to public yet
How stable is the 2020.1 compared to 2019.3?
it probably boils down on what you use with it
in my experience, even alphas tend to be quite stable unless you couple with them with other preview packages
but the bigger issue on alphas is the package compatibility, they might not always be compatible packages for the new version at that point
things like that start to get better during betas
Yea, that's why i had to update to 2019.3 initially lol
I think they said next Entities version is 2020 only
hybrid v2 is probably relying on 2020, yes
and you already get some things on 2020 that doesn't work on 2019, like debug draws inside jobs
(debug draws still don't work with burst)
I tried to read those v2 patch notes someone posted, but it was like reading a different language rofl. I have lots to learn I guess
SerializeReference has various issues in 2020.1
is it 2020.1 issue or just issue with the latest serialization package?
because last package definitely wasn't compatible for me
uh, well I didn't install any packages to test it, is it included by default?
if you haven't manually upgraded that specific package, it's not it
Also, SerializeReference is new in 2020.1
ah
lets you serialize non-UnityEngine.Objects by reference
SerializeReference is in 2019.3 as well
their example is where the problems actually come up wtf
I need to investigate this
well, the issue is specifically, if you have a class which has itself as a member, Unity will automatically populate thing new elements with the previous element data, which is typical unity behavior, but in the case of SerializedReferences can cause infinite update loops which kill unity
I haven't tested on a25 yet
party hard 😄
I recently learned that Unity is moving towards an ECS paradigm and I'm wondering if it's worth using for production in its current state. Would it be worth the time to make a pure ECS game in the next LTS release?
I think that depends on your needs - see if the things you need are supported and if they're not is it okay for you to develop your own custom implementation?
ECS won't be in LTS for a long time I think
A few people are using it in production but I think right now it's pretty rare, the API isn't even stable yet
My current project is very suited to ECS so I might actually try a custom system. How much Unity functionality do I lose by doing this?
yeah, you lose every functionality 😄 you gotta do hybrid
You can model your systems to use gameobjects while you transition. But you may not see much performance gain until you use burst and jobs, which greatly restricts the types you can use. No reference types or mutable static data.
IE no gameobjects in jobs and burst.
well shit
Unless all you need is rendering you can certainly get by using it
Guess I'll hold back on Unity ECS for now lol
okay maybe unless is a big overstatement - but rendering is something that's currently supported via hybrid renderer but ppl have had issues with it from what I see
You can still get huge performance gains by isolating your logic into ECS and then writing it back into gameobjects after processing, but it's not very smooth at this point in time
rendering/shader stuff is definitely the biggest thing I need from Unity
there are certainly conversion systems which you can use to help transition gameObjects into their entity formats
I currently do this for my own 2d game
@terse matrix This is a good presentation on how you can try to utilize ECS and dots in an existing gameobject-based project without having to remake your entire project at once https://www.youtube.com/watch?v=BNMrevfB6Q0
In this video, learn about what's involved in migrating existing game code to the new Data-Oriented Technology Stack (DOTS), which comprises the C# Job System, the Entity Component System (ECS), and the Burst Compiler. You'll also gain an understanding of the performance benef...
@terse matrix if you want just the perf benefits, you can just put the perf crucial code into burst jobs and forget about the ECS part
that's way less risky if you need this today
burst + jobs are production ready
ECS isn't
and DOTS packages definitely are not
but burst and jobs are part of DOTS😅
@terse matrix You can do some ECS stuff with gameobjects, and do it gradually. The simplest is to use jobs, where you can offload some of your functionality to those. They are multithreaded, and are really good for things such as procgen or pathfinding when you have a lot of objects. These jobs can be scheduled directly from monobehaviours.
If that's not enough though, you can also utilize entities, by converting some of your stuff to ECS. Usually this would be where you have a lot of the same types of entities (e.g. enemy agents, similar buildings etc) that are then ported to ECS. You can also move your physics simulation over to ECS to leverage the performance gains frm that.
Finally you can of course do a full ECS build (except the rendering currently), which I don't really recommend for production. But the first two approaches are already being used in some productions
yeah, I kinda mean stuff like engine components by dots packages, like physics, animation, rendering
job/burst system is 👌
glad that it's ready to use
also jobs is in the unity core, the package you get on packge manager is just some small helper package 🙂
job system documentation is also on regular unity docs, not in the package one
as for the rendering, we might get quite substantial improvements on it soon but it's too early to tell how much better the hybrid rendering v2 will be
expect to hear more about that in coming weeks as Unity reveals their GDC content
Something I should probably mention is that I work with 2D
will Unity be improving rendering for my needs?
I wouldn't expect better rendering with DOTS in a long time, unless you need some brute force stuff like hundreds of thousands sprites at one 😄
we are currently at a point where people would be happy to first get similar functionality than without DOTS
there are compatibility issues with current hybrid rendering approaches
and then there's separate rendering for project tiny as well
for 2D, you'd probably want to be using URP as it has quite nice 2D renderer
Also pretty rare that a 2D project has actual performance issues. The only case I can see right now is ad games, in which case you'll have to wait for Tiny2D to be production ready
@digital scarab btw since you are around, you wouldn't happen to know if there's already some way to define code to run burst with different code based on the currently selected SSE/AVX extension?
I guess not as it would probably break the determinism
I was kinda thinking I could help burst a bit by feeding it double precision math 4-wide out of the box on AVX but it wouldn't really help at all on SSE4
yes
oh, that's cool
yea I agree with @bright sentinel about 2d - my game doesnt have heavy performance issues if it was in monobehaviours and the reason why it's in dots was that it was easier for us to reason about and change data manipulations and if we wanted to change the high level direction of the game (but sprite rendering is still done by the SpriteRenderer)
IsAvxSupported
I was more of like thinking of just defines here tho but I guess I could do this as well
this adds extra check now
also thanks for pointing to the right direction 🙂
"Evaluates to true at compile time if AVX intrinsics are supported."
hmm, I guess that doesnt really help after all
I can't branch SSE and AVX implementations with that
yeah, because not every windows machine there supports AVX
but SSE is supported by all
and burst picks the implementation on the fly on the client computer
On a side note (and being sort of new to ECS/DOTS), is branching seen the same way here as they are with shaders? Or are they fine to do?
"Evaluates to true at compile time if AVX intrinsics are supported." makes it sound like it just sets that true when I compile on this rig 😄
oh, basically Burst itself can swap between SSE and AVX on the client computer
that works already
but what I would have wanted to do is provide different code for AVX and SSE
but apparently that's not a thing
and considering the determinism, it's probably not worth it
well, I can test it 🙂
yeah 😄
it's bit hard to test properly here tho as all my computers actually support AVX
and if you set the SSE4 as max supported on build, it doesn't tell if I succeeded or not
I could test this on avx2 though
because that's definitely not supported by my old i5
@digital scarab Huh, I've never really thought about that. Do you have any resources I can read up on? Preferably targeted for non-compsci people like me
@bright sentinel new math lib has select option that lets you bypass some branching if's
and it's definitely faster than the if
it's one of the things Unity has mentioned you can do to make burst compiled code run better
from: https://forum.unity.com/threads/math-selects-performance-vs-inline-if.532282/#post-3505501:
The main interest for using select is on SIMD types and more specifically on float4, as it is more naturally mapped to a SIMD register. It will typically result in using dedicated instructions instead of performing conditional move on each components.
For example, a math.select(float4, float4, bool4) without SIMD would generate the following scalar code (note that you can't generate currently this code in burst using math.select as it will always generate the following SIMD version instead):```
Oh my that is already out of my league haha. Guess I'll leave optimization problems to actual compsci people if I ever get to that problem 😂
But no prob @digital scarab seems pretty complicated anyways
I think i started learning it when I was fiddling with g++ and using the step debugger to see how asm instructions worked 😅
Day 115 of coding on Handmade Hero. See http://handmadehero.org for details.
This can help you for simd stuff, Unity also has some videos in their youtube channel
But i feel like its something i should try to learn after everything works correctly 😄
Oh, that might be useful. I tried watching one of the Unite talks about performance with SIMD instructions, but I didn't understand much. This might be a bit more on the educational side, so thanks!
And yeah, I don't want to be optimizing performance before it's actually a problem 😛
tbh, ECS by default (with power of burst) already provides with insane performance, but if you want to go for a real massive worlds i think thats when instrincts will come to help you
this is of course from a peasant point of view 😄
maybe there are some pro people out there that says "my life is not complete without instrincts", who knows 😄
Hmm - I think there are use cases - was reading a tweet thread by folks at binomial who do image compression and want to support wasm simd instructions the other day lol
it's pretty cool that we can do intrinsics via Unity.Burst.Intrinsics now
this is new in burst 1.3 or just not documented before it?
👀
Olento is this true, you suppose to keep track of these things 👀
(just a joke btw)
does anyone know, is NetCode prediction based on time, or is it based on frame number (tick). It must be based on time right? Does that mean the prediction system might skip a tick on the client if the FPS is low, and process the same tick multiple times if the FPS is higher than the server?
@slim nebula Pretty sure it's based on ticks, but the server is on a fixed rate
So it's based on ticks which are based on time
but the client isn't on a fixed rate though
I've seen delta times that are not 0.016
Yeah, but that's what the prediction system uses to predict.
It looks at the ticks it received from the server
oh I guess the prediction ticks on the client dont have to line up with the server ticks, as long as the oldest tick is at the right time then the client can predict whatever
this makes sense thanks
Yeah, there are some docs about this on the package docs
oh? any chance you could link me to that? I've been finding it hard to google this stuff 😦
or you mean it's in the actual package somewhere?
once I get it from unity package manager?
or this
I guess I should read through all that
cool thanks a bunch. appreciate it
@opaque ledge new 1.3 burst too
How should I go about rotating a 2d entity right now? Using quaternion just makes the entity dissapear
such a small note for something thats such a huge quality of life improvement "Added the following new types: LegacyJointConversionSystem" 😍
and it works too https://gfycat.com/legitimatesnarlingdogwoodclubgall
yeah, that's pretty much what was supposed to be the main highlight for the new package 🙂
they still don't have breakable joints
also no joint motors
both will arrive later on
I've been waiting for this release specifically in hopes I can get rid of the old joint scripts from physics samples
i can do ragdolls without stumbling through the math myself though 😄
@gusty comet rotation component?
getting this now Assets\Scripts\Modify\ModifyBroadphasePairsBehaviour.cs(80,53): error CS0193: The * or -> operator must be applied to a pointer
but I'm sure the sample repo is going to be updated any moment now
yes, im using the rotation component
## [Burst 1.3.0-preview.5] - 2020-03-11
### Fixed
- `MemCpy` and `MemSet` performance regression in Burst 1.3.0.preview.4 (as was spotted by [@tertle](https://forum.unity.com/members/33474/)) has been fixed.
- Fix a crash when loading assembly with PublicKeyToken starting with a digit
- Better handling of MonoPInvokeCallbackAttribute: no check for the namespace, don't print message on Mono builds
### Changed
- Improved error message for typeof usage```
not going to put physics packge changelog fully here as the list is kinda huge
basically they changed a lot of runtime API + added that LegacyJointConversionSystem
what do you mean by that?
the renderer?
also about that Burst update, I'm now going to do mono builds only to get rid of that spam 😄
yes
" Better handling of MonoPInvokeCallbackAttribute: no check for the namespace, don't print message on Mono builds"
if you use 2d cant use 3d, and reverse
2D not being able to do 3D makes sense but you'd expect sprite support on 3D too
maybe they just haven't added it yet
hmm
they actually didn't add joint authoring components at all(?)
I only see the legacy joint conversion system
anyone played with the dots jobs particle system?
and the Physics_joint.cs that has these joints
@stable fog there's a dots particle system?
or you mean the job system support for shuriken particles?
if so, there should be sample code snippet for it on the docs
so the old shuriken thing
https://docs.unity3d.com/ScriptReference/ParticleSystem.GetParticles.html has small code snippet
there is no havok update😕
that's hardly surprising considering there's been 1(!) havok package update so far
and even that barely changed anything
they mainly removed the time limitation for the early preview version
I'm pretty sure Havok are not putting as many resources into Unity Havok as Unity are putting into Unity Physics
Doesn't make much sense
At least at the moment
Havok team is doing Unity Physics as well tho
Wait really?
basically anything on the physics solvers is done by Havok
Unity only does the DOTS conversion stuff and DOTS integrations
anyone figured out how to do new foreach collisionevents and triggerevents ?
here's Joachim's response when I asked about it:
of course nobody really believed Unity Physics getting out of preview on Q3 2019 but I like their optimism 😄
@bright sentinel ^
if you look at the unity forums discussions on unity physics package, there's a lot of replies from Havok guys directly
also... crap
since the joint conversion system requires physx components to be used, you have to put old rigidbody components there too for it to work
can't use new physics body ones
how they could not just make new authoring components while they were at it?
heh, someone was arguing with me about the dots and burst performance, and I was like even the havok guys said burst was impressive
apparently thats not good enough though
yeah I guess I thought that they would also add some updated joint authoring components to go along with this update, but at least for characters using rigidbodies is good enough
you could do ragdolls with the old joint scripts already
pretty sure the ragdolls from unity physics samples did this
btw, 2020.1 beta 1 is out now: https://unity3d.com/beta/2020.1b
swapped the link to one with unity hub link
i did do ragdolls previously, it was based on the samples but the samples ragdoll is a custom script, not using the joint authoring components. it just means your joint limits(well mine in this case) had to be figured out with math, and I am just terrible at math
like arm/torso joints that had no limits, spinning like a ballerina when dead 😄
ah, so you use some wizard for that normally?
that builtin one does the trick for simple chars and my own uses, to convert it and get similar results would be good enough if it converts properly.
just to add, when attempting to set limits and not knowing how to set those limits with the right transform points would sometimes lead to exploding or self propelling joints flying off into the sunset
oh its actually up now sweet, they changed the page and it was real confusing
THank unity for unity hub, managing installs is so much better these days
Should i upgrade to Beta right away 👀
I just did... but according to a lot of people I have very dangerous upgrade habits
I love living on the bleeding edge
in that case, public 2020.2 alphas should start soon ;D
they are already at 2020.2.0a3
I know I'm quite excited 😄
have they talked about .2 features yet?
still no Kinematica :*(
i just want the new hybrid renderer 🙂
I doubt there's much new functionality at this point
Kinematica is supposed to be part of one of these releases
or perhaps, released in a preview package along side of**
HDRP team lead said like half a year ago that they'll address HDRP perf regression on DX12 for 2020.2 but we'll see
StepPhysicsWorld still uses😑 cs float timeStep = UnityEngine.Time.fixedDeltaTime;
that could mean anything too, as 2020.2 release is set to Q3/Q4
are they running behind this year?
I doubt it
I thought .3 was supposed to typically be released in december?
no I mean, they just removed one release from summer
there's only going to be two tech releases now
oh, so .2 is the last release before LTS?
IMHO, they could just do one tech release and keep adding stuff till Q2, stabilize it for release on Q3 and then polish it to LTS
it would make way more sense to me
ultimately you have 1 release per year that actually matters which is the LTS
anyone not doing experimental R&D doesn't want a potentially* unstable client
yeah, that's my point here really
I mean, its not relaly true, I know a company who is working on moving from 2018.3 to 2018.4 LTS right now just because it makes sense to do so
2018.3 to 2018.4 should be trivial tho
as there's no feature difference between the two
same api, same feats, LTS just may have more up-to-date SDKs and more fixes
is really moving from version to version a huge task ?
they are doing it specifically because its easy and because you should theoretically have more stability on LTS
@opaque ledge it really depends
on how much of the Unity API you're actually directly consuming and whether or not that API changed between versions
I donno if Unity is using Semantic Versioning, but per Semantic versioning, movgin from 2018.1 to 2018.4 should be a trivial change, as the API should not change
however, if you were relying on some bug or quirk of a feature that got fixed, then you're going to have trouble
btw, i was just doing some test today (maybe you saw the party hard video 😄 ) so i spawned 4k 'ships' in total and a TRSToLocalToParent or smth was taking like 20 ms
is there anyway to reduce that ?
avoid parenting things? 😄
there was a bug that constantly triggered that system, shouldve been fixed in 0.7 i think
but 20ms sounds a lot more than what the bug did i think
yeah thats probably not going to work well 😄 i have this 'nose' capsule to show where my ships are looking at, probably thats the one causes it then
i did note that when spawning a prefab with a parent child setup, it seemed like it had to do work when spawning it in, which I thought would already have been done through conversion as it was an entity prefab
but that was a while ago, when it was entities 0.2 or something and i just got rid of a hierarchy for those situations
4k ships, LTP taking 20ms sounds quite wrong... unless you have like 100 children per parent?
nope, just 1
safety checks off? burst enabled?
have you removed the nose to double check that's where the time is spent?
Are all or most of your ships in the same chunks?
yeah
i should probably check soon to see
or actually tomorrow, i am slacking rn 😄
@dull copper can you convince the devs of the game I'm modding to move to 2020.4 instead of 2018.4 😄
I really want like, UIElements, and SerializeReference
2020.3 LTS you mean?
oh right
or 2019.4 LTS?
yeah, I donno whatever the final LTS release is for 2020
yeah, that's a long wait now
its a year away, gives them plenty of time to get started with 2020.1 😄
[Feature] Compute skinning using DOTS first version: https://github.com/Unity-Technologies/ScriptableRenderPipeline/commit/819f02c223f75113f66bbbf6e8c4ebb22e72e2ee
i refresh bintray occasionally and am totally in control of my habits and behaviours 🙂
.
does anyone know if theres a way to convert a transform straight into a localtoworld?
ConversionAPI?
or you can just grab the transform.localToWorldMatrix and set it to LocalToWorld? 🤔
Mat4x4 will implicitly convert to float4x4, so yeah
I tried that it says cant convert matrix4*4 into localtoworld
localToWorld.value
nice thanks I'm always getting stuck on the silly things
@stable fog I got few links bookmarked which I poll occasionally, mainly bintray and SRP repo tho
been thinking I should write an app that does all the checking for all things I follow in the internet
now there's just so many different things to follow, like RSS feeds, forums and stuff if you want to keep up
Here’s a little something to spice up your week: Unity.Physics 0.3.0-preview.1 is now available to download via the Package Manager! Here are some of the key features you can expect to find in this release:
* Authoring support for Legacy Joints. Old-school gameobject based joints will now be automatically converted to Unity.Physics based joints when a ConvertToEntity component is attached, or if they’re placed in a subscene.
* The Physics Simulation can now be optionally stepped with in a single threaded mode or immediately. This is much more performant for simple simulations where job management costs more than the simulation step itself. See the '6. Use Cases/ImmediateMode' sample for example changes.
* New Collider Shape re-sizing handles. These will allow one to resize the collision shapes directly in the scene view, if that’s your cup of tea.
* Dependencies have been updated. Unity.Physics now has explicit dependencies for Burst, Collections, Jobs and Mathematics, in addition to Entities.
* Bug fixes!
* Performance improvements!
The Physics Sample has some changes as well, including fixes for a few issues, as well as updated dependencies (LWRP, Input System, DOTS Editor, Hybrid Renderer).
that being said, they really haven't updated those physics samples yet
Ok, what am I not understanding here:
private void LateUpdate ()
{
var translations = _query.ToComponentDataArray<Translation>(Allocator.Temp);
var rotations = _query.ToComponentDataArray<Rotation>(Allocator.Temp);
if (translations.Length <= 0) return;
var rotation = rotations[0];
var translation = translations[0];
transform.SetPositionAndRotation(
Vector3.SmoothDamp(transform.position, translation.Value, ref _smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime),
rotation.Value);
translations.Dispose();
rotations.Dispose();
}
Unity complains "InvalidOperationException: The NativeArray<Translation> GatherComponentDataJob`1.Data.ComponentData is allocated with Temp memory. Temp memory containers cannot be used when scheduling a job, use TempJob instead."
... but this is not a scheduled job. It's a MonoBehaviour, trying to read some data from a few entities (to move a camera object).
It works with TempJob allocation, but that can't be the answer 😉
I'm literally disposing the array 5 lines later.
JobHandle job;
var res = ChunkIterationUtility.CreateComponentDataArray(_QueryData->MatchingArchetypes, allocator, componentType, this, ref _Filter, out job, GetDependency());
job.Complete();
So unity thinks it's a good idea to make this a synchronous temporary job, meaning my LateUpdate will finish when-the-xxxx-ever?
I'd like to read some entity data synchronously and immediately in my MonoBehaviours, please. 🙂 It doesn't have to be fresh, but the read needs to be instantaneous, synchronous, and non-blocking.
I'm not 100% but pretty sure you can't use "Temp" allocators on the main thread in the same frame that you schedule a job. As in anywhere in that frame.
Yeah but I don't need a job, I need to read some data.
If you're scheduling a job during that frame the only time you can use "Temp" is inside a job
It gets completed immediately
my vague understanding is temp is auto disposed inside of jobs so you can allocate inside jobs and then not worry about disposing
tempjob expects to be disposed though so its use in this case is correct even if it isnt a job
But you have to pass TempJob or Permanent as the allocation type
Is that the correct way to do it then? I was thinking of maybe making a system that copies data out, into some volatile data or synchronized (how's that even called in C#, I haven't touched Java in a decade and still speak like it) structure instead, that my monobehaviours bind to.
Thanks
How do I know Job.Complete() immediately completes, it could be waiting for a huge dependency chain. I always understood it as something akin to Thread.Join()
It blocks the main thread
THATS NOT IMMEDIATELY haha. 🙂
That's blocking 🙂
Also fine, but thanks for the clarification ^^
There's a big difference in my head with hoping to weasel in between a few dozen systems repeatedly locking a concurrent native container on access, or waiting for all of these jobs to Complete and then to read said data.
If you want to wait until the job completes you check jobHandle.IsComplete. You still need to manually call Complete once that condition is true, for the safety system.
I do most decidely not want to wait for the jobs to complete in a Monobehaviour.
This is an example, it would be similar for UI where I display data that I would prefer to not duplicate, but take directly from the components and entites bound to the UI
Duplication would be acceptable only if that means I can read without waiting for any job dependencies.
I'll look into NativeQueue.ToConcurrent
or the atomic writing attribs etc
NativeArrays are already safe to write concurrently, assuming you're not overlaping indices. And they're safe to read concurrently as long as they're not being written to
I define concurrent to be safe for reading and writing at random.
literally, there would be a copy job shoveling over the ComponentData into a native container, while at any opportune time, something from the main thread or even another job could peek or consume items in it.
Ok. That's bad. What does NativeQueue<T>.Concurrent do, then. I thought it's like a queue that has a Mutex protecting non-atomic operations until they are complete.
It lets you write to it concurrently. Then you read from it after you're done writing. This is true of ALL containers, concurrent or not.
hmm
I don't want to wait till I'm done writing, because I can imagine various scenarios where I don't know how long I'll be writing for.
(pathfinding?)
There's no magic solution, like I said, it's the entire point of the safety system to prevent reading and writing at the same time.
NativeStream might be useful here?
I'd rather want my deadlocked threads back. 😄
You could copy all your data into a nativestream, all the same rules apply though
yeah, doesnt help.
This is why they made ECS the way they did, they manage all the dependencies, we only have to worry about logic
Then I think perhaps @warm panther you might be misunderstanding something? Obviously it's unsafe to write to something in parallel at any time?
it's not if access operators are atomic.
lock(_underlyingStructure)
{ // do the work here
}
And in native code, similar.
I don't know much about this tbh but do atomic operations rely on interlocking? My understanding is that it's pretty slow?
and you can have fancy scoped locks so you don't block the entire array (like NativeSlice)
It's slow to spin and wait for a lock, yes, so you need to design your code so these spins are 0 or 1 for the majority of the time. Most processors have optimizations for these cases.
Anyway, I will need to figure out how to bind data to things like UI for a start.
What's wrong with just reading the components from a query?
how is locking a section of an array while you write, different to a system with a defined start and end writing to it? Because you can work with sections and individual elements rather than an entire array? Which you could do with either an archetype or worst case copy after work complete? Out of my depth here most likely
What's wrong with just reading the components from a query?
@zenith wyvern that starts a new job, and waits for all the jobs that might have dependencies associated with these components.
@amber flicker I don't know... I'm more of a C++ guy, so C#'s threading model is a little alien to me.
But your code needs to agree on where these cordoned-off sections are, and then that's where your synchronization problem sits.
I'm pretty sure that's what NativeSlice does, though
If you're only accessing the components a read-only it would only be waiting for write jobs to complete. All reading will happen concurrently
Except it blocks the main thread.
reading doesn't
Since it knows there's no write jobs happening it knows everything is reading the same data
Than don't do it through the MB 🙂
But I need to move my camera and I sure as hell don't want to write authoring components for every UI element.
sure, except I see data as two things.
stuff that's not bad if it is wrong one frame
Make a standard managed list of your components and a system which applies the changes at the end of the frame
and stuff that syncs
I suppose.
Then I need to inject my monobehaviour into the System, I wanted to avoid that. 😉
That's how i do all my presentation updates
That's how I got here.
Why would you need the MB in the system
Just access your components through an entity query. You don't need any connection between your systems and your MB
But the _eq starts and ends a job and holds memory for 4 frames
or something
But that was my naive approach in the code sample above, and it only works if I allocate TempJob memory.
You decide when your components get written to in the system. When you call ToComponentDataArray in your MB it will ensure any write jobs are complete, if they haven't been yet. You can do your level best to ensure they ARE complete by deciding WHEN you write to components.
What's wrong with allocating tempjob memory?
I don't know, that's why I asked.
It's fine, just make sure you dispose them before they leave scope
So most of my preparatory work has to be done writing during PreLateUpdate systems group
I can do that.
You can also add a ChangedFilter to your query and exit early if your components haven't changed so you're not allocating when you don't need to
Then the MB will instantiate, start, and complete a Job, but it should have pretty slim dependencies.
Changefilter is a great idea for this use case (it is for camera targets)
so if everything is in a job, when do I get to use Allocator.Temp ... I guess when I need to process data that's not ComponentData
You use it inside a job. My understanding is that it's VERY fast. And you don't need to dispose it, it automatically gets disposed at the end of the frame.
And that's a good point, I never thought of that, I guess that's why you can't use Temp with ToComponentDataArray, because it's technically scheduling a job to create the array
cool
Just to check - you don't want something like this right? just psudocode obviously ```private void SmoothMovement : SystemBase ()
{
void OnUpdate()
{
Entities.ForEach((CameraTarget targ, in Translation t, in Rotation r) => {
targ.transform.SetPositionAndRotation(
Vector3.SmoothDamp(transform.position, t.Value, ref _smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime), r.Value);
}
}
_query = _manager.CreateEntityQuery(ComponentType.ReadOnly<ControllableTag>(), ComponentType.ReadOnly<Translation>());
How do I specify the type specializations for _query.ToCompoentDataArray<...> with this readonly query? the docs don't provide a concrete example for especially this case.
Just to check - you don't want something like this right? just psudocode obviously ```private void SmoothMovement : SystemBase ()
{
void OnUpdate()
{
Entities.ForEach((CameraTarget targ, in Translation t, in Rotation r) => {
targ.transform.SetPositionAndRotation(
Vector3.SmoothDamp(transform.position, t.Value, ref _smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime), r.Value);
}
}
@amber flicker No I don't, that's fine for other purposes. I would like my camera and especially the UI to live in Mono space, at least until DOTS editor has a few more features to actually touch and find entities.
There's a clear 1:1 relationship, but I wanted to avoid using Singleton entities.
(just for clarity, CameraTarget in the above example is a MonoBehaviour - so just wanted to check you knew you could do that) - you want to keep the systems in the MB though?
Because it's also a 1:n relationship, but the state "which n" is much easier to handle in Mono in these cases.
What do you mean by type specializations?
the stuff in the brackets <....>
var translations = _query.ToComponentDataArray<Translation>(Allocator.TempJob);
this doesnt work readonly
var translations = _query.ToComponentDataArray<ComponentType.ReadOnly<Translation>()>(Allocator.TempJob);
this doesn't compile
(kind of obviously 😉
but here I am.
var translations = _query.ToComponentDataArray<Translation>(Allocator.TempJob);this doesnt work readonly
@warm panther
What do you mean it doesn't work?
@warm panther
What do you mean it doesn't work?
@zenith wyvern InvalidOperationException: Trying to get iterator for Unity.Transforms.Rotation but the required component type was not declared in the EntityQuery.
Because it's the readonly type.
It's saying you didn't include Translation when you created your entity query
Err rotation
_query = _manager.CreateEntityQuery(ComponentType.ReadOnly<ControllableTag>(), ComponentType.ReadOnly<Translation>());
//laaaater
var translations = _query.ToComponentDataArray< Translation>(Allocator.TempJob);
var rotations = _query.ToComponentDataArray<Rotation>(Allocator.TempJob);
lol
ok
yes.
_query = _manager.CreateEntityQuery(ComponentType.ReadOnly<ControllableTag>(), ComponentType.ReadOnly<Translation>()); I don't see rotation
these are getting too long
I really hope Entities 1.0.0 will do something about API brevity, this guy has the right idea: https://www.youtube.com/watch?v=SQ7GJFL8ttE
rambled into a mic and then edited it
It doesn't help that you're trying to mix MB and ECS, it really wasn't made for that. I understand you have a good reason, but yeah
It's not really mixing.
But I'll think some things over.
I've worked a lot with Entitas, where you usually have Views in gameobject land, and references to these views in ECS land. But it doesn't native-compile, so everything is pretty "normal" and C#, except for the components and entities that are pooled.
I like Entitas' extension syntax, where you can do entity.hasTranslation etc. In Unity ECS, I need to talk along a insanely long message chain, which is a capital code smell:
World.DefaultGameObjectInjectionWorld.EntityManager.HasComponent<Translation>(entity);
Sure, I can store an EntityManager reference but pracitcally, Entity should expose this info, but this might be the 1:30 am talking 😉
(I'm not saying Entity should contain the info, but expose the accessors)
As of the latest entities update inside a systembase you can just do HasComponent. Even inside a job, it will automatically be compiled to the "GetComponentDataFromEntity" bit, outside a job it gets compiled to EntityManager.HasComponent
Yeah I noticed that and it is a big improvement
But yeah, the API definitely needs a lot of work right now. But it feels like they're moving in the right direction
it's nice and fast enough to got me to start with it
if they shave 5 or 6 syllables off of most identifiers, I'll be happy.
And oh, as nice as Entities.ForEach() is, I haven't figured out how to make it work with a method/method group instead of an anonymous function. I really don't like how these read or indent, or debug, refactor, or anything, really.
you're not the only one who finds it verbose... but as Sark says, when you can work with ECS and the newer stuff, it's actually often pretty succinct I think - esp if you compare it to classic mb's and include having to find references to components on gameobjects, check they're not null and such - but it is early days
Still a bit boilerplate, but it took Entitas a long time to reduce the boilerplate, and their ReactiveSystem still is a bit of a mess (and actually ECBs are a much nicer way of dealing with this, kudos, Unity)
Heyo, this might be a very broad question but, I'm wondering if I should use DOTS/ECS, if so, why?
If you're a hobbyist and you want to get in on the ground floor, then yes. If you're in production, probably not yet
ECS is the future for Unity as far as I know
Yeah because I'd have to rewrite a lot of my game to make it work with it
The normal way of doing things will be around for years yet I think, so there's no rush
Yeah I'm prototyping a hobby project. In my day job, I run a studio of 13, and using SRP and addressables was already a hairy affair for a game we began in 2019 😉 Game turned out nice, though.
ECS is absolutely the future.
And it works, for the most part, exactly how my brain, which is awesome.
Alright, was just looking into some optimization for Texture2D or Threading and stumbled across this
I don't like having to letterbox everything through the native APIs, takes away a lot of the expressiveness of C# - I would rather have a domain specific language for Systems, then.
You can always ignore ECS and just focus on jobs for now. Just learning how to use jobs properly can give you massive performance gains
But... it's not bad. It's a huge improvement already.
Yeah, but ECS really lends itself to how I think about games.
Yeah having some problems learning Jobs :p
It's Jobs that throw me off, probably because I always think they are just a wrapper for java.lang.system.Thread
PTSD, srsly.
I got Jobs working once but it seemed to have slowed down my "world creation" which is what I added it for, so I guess I was doing something wrong.
So yeah, guess it would be healthy to get cozy with Jobs
Well if you have any specific problems or code snippets, feel free to ask here or on the forums
Thanks for your help, everyone.
Yeah so, what I'm trying to do is optimize my 2D world creation, currently it takes 200ms to generate the whole world on a Texture2D. Thought I could try and reduce that with Jobs but I'm not sure it works in the way I want it to
as I said I did get it working with Jobs once but it pretty much just made it take 800ms instead, so I was probably doing something really wrong
What did you try? I assume you have color data that you pass to a job to be processed, then write it to the texture when the job is complete?
Yeah you pretty much summed it up there, the main problem was probably that I was creating a new Job for every "tile" on my map, which is 40,000 tiles.
Not sure though
Yeah that is definitely not right
In that case you would probably want to use an IJobParallelFor that does the per-tile work on each index of an array
You can tweak the batch sizes to decide how much work gets done on each thread
Interesting, I suppose I'll try and learn that then 😅
Yeah you pretty much summed it up there, the main problem was probably that I was creating a new Job for every "tile" on my map, which is 40,000 tiles.
@odd cipher You should be a politician, you will definitely get elected after creating so many jobs.
Okay that's funny
@zenith wyvern Still having some problems with the Jobs system, dont fully understand it. everything is going wrong 😅
What's wrong specifically?
I dont really know to be honest
Well if you can give any more details we can try to help. What's not working - are you getting errors, is it not doing what you expect, are you not understanding the syntax?
I suppose I just dont understand the syntax
Have you read this page https://docs.unity3d.com/ScriptReference/Unity.Jobs.IJobParallelFor.html ?
Yeah, currently getting this ```
IndexOutOfRangeException: Index 1 is out of restricted IJobParallelFor range [0...0] in ReadWriteBuffer.
ReadWriteBuffers are restricted to only read & write the element at the job index. You can use double buffering strategies to avoid race conditions due to reading & writing in parallel to the same elements from a job.
It's saying the native array in your job has a size of 0
So you haven't constructed it properly or you forgot to pass it to the job
Either that or you're trying to write to an index other than the index passed in Execute. To avoid race conditions you can only write to that index in an IJobParallelFor
Blegh, I don't think Jobs will work for this
Why not?
I just cant figure out how to make it work at all