#archived-dots
1 messages ยท Page 198 of 1
DefaultEcs has some API docs fwiw
what are you trying to do anyway with hybrid?
convert and inject should generally simple enough to use with physx
I'm thinking of using untiy ecs for the architecture rather than the speed boost.
if i use conver and inject, I essential have 2 cubes for 1 convert and inject.
one as an entity and one as a gameobject.
if I try to use Hybrid Rigidbody the entity doesn't get updated w/ classic Physics
So I'm left with trying to wrap my head around other ecs frameworks just so I can use classic physics
Default scene with one cube. URP not Hybrid: 2.7ms update. URP with hybrid: 6.5ms update. What the fuck? Where is my performance going?
Hrm, dont convert the camera into an entity. From 6.5ms to 9ms update time. Literally rendering an empty scene.
i dont know if you want to keep using the rendermesh on the entity or the renderer on the gameobject but it wouldnt be too hard to make a conversionsystem that strips them from entities, to just have a basic mirrored entity transform setup
also classic physics should work fine if you manually add the rigidbodies in your authoring class when using inject
Does anyone know what's going on with dots recently? Haven't read anything about it for a while in the patch notes
I was told to not use the Hybrid Renderer, I assume due to performance issues? Is there any validity in that?
Hybrid renderer is great for large numbers of entities that share the same mesh/material. Not at all good (yet) for procedural meshes or lots of unique meshes or materials
Supposedly there is a substantial team working on it. We usually get dots package releases every 1-3 months. Last release came out recently
btw @deft stump
unlike unity DOTS
svelto ecs is actually used in a game
svelto is what drives Robocraft game
also unlike unity DOTS, it has samples that work XD
default ecs seems to be an ecs made to make an ecs, not used in any game, which is very much a terrible idea. Needs to be boostrapped
ok... duly noted...
Hey has anyone got experience messing with textures in DOTS? I am making a bullet hell game and I wanna make the background scroll to show movement. I've put a starry texture on a quad behind everything and want to make a system change the offset every frame, is there a better way? Can this be done via DOTS? ty
To move it, you would just do change it's Translation. imo this doesn't sound like the kind of thing worth doing in DOTS though.
Scheduling continues to be frustrating. Run: 0.75ms main thread, ScheduleParallel: 0.45ms x 24 threads, total 11ms. ๐ญ
ISystemBase using IJobEntityBatch fwiw
your not using nativelist are you?
nah, just iterating some entities with a few test tags & basic ICDs
is it a new bug or unoptimised, or just the general overhead of starting a load of new threads
overhead that's always been around.. just hoped by now it would be better.
yeah, hopefully they can get it down, it makes using multiple threads almost pointless depending on what your doing
So you would recommend go hybrid? I want the quad to stay in the same position, just its texture to move though.
Unless I was trying to make it completely DOTS or unless I was trying to tie the scrolling in with other systems, I might just do traditional monobehaviours. Otherwise you could do hybrid or "pure". In which case I might look at scrolling UVs for which I think you'd want to use material overrides or something (haven't played with that myself).
anyone know how ecb's are handled when serializing a world? like if you schedule an ecb command at the end of a frame for an ecb that executes at the start of next frame, then serialize and deserialize, does that command just get lost?
Are you sure it's bursted? I thought only IJobChunk was working with ISystemBase right now. You need [BurstCompile] on both the struct and the OnUpdate function
If it was bursted IJobEntityBatch shouldn't even work yet afaik
yea all bursted - seems IJobEntityBatch works if things are kept simple - haven't worked out exactly when it does & doesn't work - I posted with a quick example here: https://forum.unity.com/threads/future-of-scheduling.1048502/
lmk if you see anything glaringly wrong
@amber flicker From the code you posted it doesn't look like you have [BurstCompile] on your OnUpdate function
wait it needs to be on there too? ok cool lemme try
That's my understanding at least
well if I add it, it no longer compiles and then I have to change it to IJobChunk.. but once I've done that the timings look the same
rip
hmm maybe slightly better actually.. kinda hard to tell without setting up a proper test which I'm too lazy to do - looks a little closer to 0.4/10 than 0.5/12
yeah one thing is to make sure it says burst in the profiler
I swear it seems random sometimes for whether systems are bursted or not, I have to like select enable compilation on and off to get it work correctly sometimes
think the profiler only shows if the job is bursted - which it was - this is specifically the Update
it should be highlighted in green instead of blue
Only when the job isn't bursted. Here the job is bursted, the OnUpdate isn't.
which at least in 2020.2.1f1 looks identical in the case OnUpdate is also bursted
Interesting I did not know that ๐ค
I have an excruciating physics problem.
I have judder, even with body smoothing on.
This is with no Physics interpolation
its not bad once you get use to it, but its extremely structured, there's basically one way you have to do everything or it wont work.
This is with interpolation on; and only if Unity recorder is running, the judder goes away.
is that burst of speed at the start intended?
Proof I'm not just seeing things... at 120 fps, I get these (still kinda strong) judders.
Yes it's a smoothly following camera.
so it seems to be related to application framerate.
the recorder would force the framerates to be in sync?
Seems so.
So yes if I set the recorder to variable fps, judder time again.
The judder is sometimes stronger, sometimes weaker, sometimes unnoticeable.
(this is following a dots physics body, ofc.)
The physics velocity is not insignificant but also not outrageous, the ship is ~1 unit long and the top speed is around 5-6 units per second.
I should create a reference object to show the smoothness of the camera's actual movement.
(if I pin the camera directly to the ship, photosensitive seizure warning when going into each curve at enough speed ...)
turning vsync on makes it somewhat more tolerable.
(but it's not gone)
Correction, it's unrelated to vsync.... whaaaa?!
seems like a different system overriding positions
Yeah the back and forth made me think this too.
It also does occur with unity recorder, just depending on resolution, it's not noticeable. The closer the framerate is to perfectly steady, the less it happens. So I wonder if the physcis rigidbody smoothing is really this bad? It can't be... I checked my other systems and I generally don't set a position; I just set a physicsvelocity.
can you try disabling a bunch of other systems one by one with the debugger or something to ensure its not another system trying to override the pos?
ive never seen stuttering that bad in my own use of the package
Wow there's... zero drift?!
This is (sum of fixedDeltaTimes - Time.elapsedTime) - always 0; then timeStep, and Time.fixedDeltaTime (which is by default set to the same).
I guess they rewrite elapsedTime in FixedStepSimulationSystemGroup.
(will take some time to do the debugging you suggested, great idea!)
those ships are looking cool, looking forward to when you show that project off for real
what is dots
Okay, I ... pinned the camera onto the ship again (no sole system seems to cause this), but...
Absurdly, it judders. As if the camera system didn't execute every frame.
Change is good. I can now rebuild my mental model of what's going wrong.
Cool looking ships, indeed ๐
So I have a mostly pure DOTS game, in which I want to manipulate the camera, specifically change it between orthographic and perspective mode during play, is there a way to access the Camera game object from a system?
The world judders more, but the ship in itself shouldn't possibly be capable of jumping ~0.01 to 0.05 units in distance when the camera literally copies its world position.
Wow, I love me a good mystery, but I am finally closer to a solution.
(this problem persisted since my earliest experiments with dots physics almost a year ago)
You totally can, just make an Entities.Foreach().WithoutBurst().Run().
these camera switches are very rare, I take it (less than 1x per frame), so the sync point is not gonna cause you any trouble.
๐ป I think I saw a ghost, I mean, my ship jumping backwards. HOW EVEN. Wow.
indeed
thanks but what function do I use to get from the Entity in a Foreach to the GameObject or its Camera component?
Apologies if it's a stupid questions ๐
Entities.ForEach((Camera cam)=> { }).WithoutBurst().Run();
You have to mask sure you convert your camera to an entity first though
It might only "automatically" work if you have hybrid renderer installed. Otherwise you might need to manually add it in a conversion script with conversionSystem.AddHybridComponent
I just use Camera.main or search for the gameobject in OnCreate, and cache it.
(or I have my injector class do this for certain non-scene assets but it's a hack :D)
Camera.main is no longer slow, you can use it with impunity anywhere for a long time before that comes up on any optimization checklists anymore.
The camera transform is literally zigzagging in space, that must be that waveform quantum stuff everybody keeps talking about.
Well at least I'm getting close.
But the entity, at least as inspector values are concerned, is going straight.
Okay, I really suck at maths. Let's put these things back together... yup. Works. 
Here's the bug: ๐
var distant_position = camera.position + camera.forward * 100.0f
var distant_direction = (distant_position - target_translation).normalized;
var goal_position = translation - distant_direction * _distance;
// and all the smoothing in the world can't reliably get rid of this jitter
//...
The new mouselook system doesn't need this value - it's basically camera.forward; but the old smoothing system used that to actually turn the camera in another step. The crux here is, it's not quite cam.forward, but rather nudged into the future just a little.
Now I just use camera.forward and it's butter smooth, and consistently choppy with no interpolation.
The old mouselook did some fancy shit with it but also suffered from the judder because... well of course there's judder, it literally calculates a significant projection through a new point from the camera, and uses that to place the camera again. (actually even more if I use the actual camera target, a child of the rigidbody)
Thanks for getting me to look at it from the other way around. It wasn't an entity getting moved incorrectly - and only by ruling that out systematically I was able to look at the object that I believed was 100% positively smooth.
Well. Of course not with that line of code. ๐
Now I can finally add CAMERA SHAKE!!!
๐คฃ
Well there's still some judder. I jinxed it. But I know this class of bug now.
ty
Hey, I'm trying to run some code in parallel using ForEach(...).ScheduleParallel()
Just for code quality, I have a few referenced functions within my lambda which gives me a compiler error asking me to use WithoutBurst() and Run()
Is there a way to do fix this without importing all the thick code into the lambda? Or is the best way to do it to set it up as a job?
@wary nexus not everything can be done with burst, what is it you're trying to do?
Oh I don't want to use Burst, I want to run a block of code across multiple threads. The block of code references other functions within the system though (since I want it to look better). Kind of high level code:
Entities.ForEach((/* Components here */) => { DoSomeThing(); }).ScheduleParallel()
Where DoSomeThing() is a function held somewhere else in the system.
Cheers, will give it a go!
That worked perfectly, thank you very much ๐
I'm used to doing ```
NativeArray<float3> verticeMap = new NativeArray<float3>(new[] {
new float3 (1, 1, 1),
new float3 (0, 1, 1),
new float3 (0, 0, 1),
new float3 (1, 0, 1),
new float3 (0, 1, 0),
new float3 (1, 1, 0),
new float3 (1, 0, 0),
new float3 (0, 0, 0),
}, Allocator.Temp);
however burst doesn't like the new[], is there different way i can make this work?
in the constructor you're supposed to set the size, and an allocator
then you loop to fill, or set at indexes
or clone or whatever
First time messing with DOTS rendering. I have 500,000 entities rendering static cubes. I'm getting about 30ms/frame. When I look at the Entity Debugger, the RenderMeshSystemV2 accounts for ~29ms of the 30ms. When I look at the Main Thread in Profiler, it shows that under Unity.Rendering.RenderMeshSystemV2 it's spending most of that time adding batches to render. I assume that is expected, but can someone with more experience tell me if that's normal?
did you enable v2? ENABLE_HYBRID_RENDERER_V2 in scripting defines if you havent
https://streamable.com/wcxawb I have this fairly optimised with rigidbodies, But i've heard about Dots / ECS. Would that be better suited for this type of game? I'm worried with more objects that are destroyable it'll begin to be very unstable and laggy. Any information would be greatly appreciated! ๐
should dive into the samples and see how you find it. though if you are fairly far along id suggest you stay with what you got, it looks solid and there are alot of limitations with current dots, and a fairly incomplete workflow for it so far, with many undocumented quirks and annoyances. documentation is lacking too.
Haven't touched Burst side of things in so long, I've forgotten about all the fundamentals.
Can you create a NativeArray from a managed array without duplicating the content twice in memory?
AudioClip.GetData/file reading don't have NativeArray overloads.
yeah, because you're using Hybrid renderer v1. v2 fixes this though. But for v2, first you have to update your project to URP if you haven't already.
have you tested it? Put 1000 or 10 000 objects in your scene and test it
@odd ridge if I have 3 or more of my cars in the scene. Noticeable fps decrease. Even without the rbs doing anything. They all are set to kinematic on start.
If i look in that general aream I go from 140 fps to 70ish
With more cube objects, it'll only get worse
There's no doubt you could get better performance with dots, but it's not something you can just easily switch to. And like baron said it's missing a ton of features compared to gameobjects
How do I pass a ScriptableObject to a component system? Its a class and compiler shows error that I use managed type
You have to convert it into an ECS friendly format. Typically you would do it during entity conversion
You can make it a blob or a component, or just reference it directly in your systems
If I use only one instance of this scripable object, does it make sense to convert it into shared component instead of non shared?
Only if you need to do it for filtering purposes - IE forcing your entities into the same chunk
Q: my systems initialize at a very different time in a build than while in editor playmode. Like, OnCreate runs before objects with tags can be found, for instance.
Show me your ways to inject references to gameobjects into AutoCreated Systems (avoiding as many null checks as possible, and ideally not using Singletons global variables or hitting a locator service in every OnUpdate..
Alternatively, can I make my systems initialize perhaps... a tiny bit later? Or am I really not supposed to hold any, any scene (in this case, i.e. cameras) state at all in my systems?
RequireSingletonForUpdate()
This is doubly tragic because I suggested just this to someone yesterday and I realize my advice was probably dreadful ๐
I think instead of OnCreate, I will use OnStartRunning as a test.
And the require singleton is sweeeeet, thank you.
any ol thing to control when you run
this allows groups of systems to be alive when things are ready or not
Very nice.
then use:
So I need to thread everything through the needle of Entities with managed components?
or aentityquery.Singleton_
(even if they're singleton entities?)
you should yes, you can also use managed singletons as well
but you have to first grab the singleton entity, then grab the managed component from the entity manager
GetSingleton<Camera> ? GetSingleton<MyScriptableObject>?
Ah ok.
Because injecting Scriptable Objects is one of my main hacks right now.
EntityManager.GetComponentObject<Camera>(cameraquery.GetSingletonEntity())
w/ RequireSingletonForUpdate(cameraquery) in oncreate
EntityManager.GetComponent<Camera>(cameraquery.GetSingletonEntity())
Again, what is this sorcery.
Getting a UnityEngine.Component from an entity?
GetComponentObject
Ah ok.
I've seen that one, now I know its purpose.
So I set my Cameras to Convert & Inject GameObject.
And then instead of finding them by tags, I have my injector service / monobehaviour set the singletons when the scene is ready?
if your using the hybrid renderer it attaches the camera component
if not you need to manually add that
Or, if I convert the camera to entity, is it going to be:
a) there when OnCreate runs
b) and OnCreate runs after Awake and Start?
don't think of it as when, or event like per say. think of it more as, its ready lets create some data in the ecs world that represents this. anything happening after is their problem
I'll try it out.
OnCreate happens much much earlier than that
thats why you want to use singletons to represent the state being there or not
yeah no problem
Singletons are kind of evil still.
But I think I can deal with it for the ECS world.
Yeah more per world.
its just a single entity that may or may not be there, but you can tie your system being alive only to when its alive, circumventing null data, and instance management
Which is valid, as my MainCamera is functionally a singleton like that anyway. There will not be a second one. (until there is ๐)
exactly
Ok I got my work out cut out for me.
which you just modify singleton checks to instead be cameraquery.count > 0 and do your work per each camera. rest of the system doesn't really change if you build with entity updates in mind
Well, this OnCreate is the most hacky block of my entire project right now, so serves me right to hit this roadblock.
||```cs
protected override void OnCreate()
{
base.OnCreate();
avatarCamera = Camera.main;
Debug.LogWarning("Hello World");
Debug.LogWarning(avatarCamera.name);
skyCamera = GameObject.FindWithTag("SpaceCamera").GetComponent<Camera>();
var sk = GameObject.Find("<Base Sky Camera>");
_skyCam = sk ? sk.transform : new GameObject().transform;
var ak = GameObject.Find("<Avatar Camera>");
_avCam = ak ? ak.transform : new GameObject().transform;
bubbleChanged = true;
Enabled = false;
_goalRotation = _avCam.rotation;
}
oh yeah, thats not a good way to do it
systems lifetimes are meant to be more, out there, not related to gameobjects or scene lifetimes at all
(I refactored two systems into one and I also use this...)
using Jovian.ECS.Systems.Control;
using Jovian.ECS.Systems.UI;
using Sirenix.OdinInspector;
using Tiger.Events.Concrete;
using Unity.Entities;
using UnityEngine;
namespace Jovian.ECS.Systems
{
public class Injector : MonoBehaviour
{
[Required]
[AssetsOnly]
[PreviewField]
public EntityChannel uiVesselFocus;
[Required]
[AssetsOnly]
[PreviewField]
public EntityChannel uiCameraTarget;
private void Awake()
{
var world = World.DefaultGameObjectInjectionWorld;
world.GetOrCreateSystem<VesselFocusManagement>().Inject(uiVesselFocus);
world.GetOrCreateSystem<CameraSystem>().Inject(uiCameraTarget);
}
}
}
And this injection event doesn't happen, so... yeah, got a clear task for today to get that part of the architecture cleaned up.
yeah I dont like to modify my systems or worlds like that from monobehaviours, other than a singular init to have per scene init values from a inspector
I learned that one for now. ๐
EntityManager.GetComponentObject<Camera>(cameraquery.GetSingletonEntity())
In this example, that means I need to have an IComponentData that identifies my camera, right? Or is there one that Unity creates for these?
no that is UnityEngine.Camera type
cameraquery though.
in this image you can see the query in the on create
That's a UnityEngine.Camera, right?
yup
I can double check for you, that the query works
starting to make me doubt my own knowledge lol
I trust you this should be easy enough to write. ๐
It wouldn't compile otherwise.
Wow dat UI scaling.
oh yeah 200% sorry
No I am envious, I have a huge screen setup and I still don't have the resolution to go beyond 1.5, and 1.5 is glitchy.
4k w/ 200% makes text real nice
Looks so nice.
I got 3 screens, 2x 1440p and 1x 3440x1440 only.
Something to aspire to some day, when 2160 ultrawides become available.
I was running 150% for the longest time till I read this article talking about how integer scaling is just way better on making text look sharp
Exactly.
How does the Camera become a singleton entity? I have 2 relevant and 4 total cameras.
Oh wait.
No. I don't see it. ๐
"Actually, since 0.7 you can mark Lights and Cameras (and some other things, I don't remember the full list) to convert and the conversion flow handles it for you. No need to manually add the hybrid components yourself."
But those aren't singletons, so do you run a custom authoring component that sets that status?
I think this is part of hybrid renderer
just tick the gameobject to convert and it will take those two managed components with them
without hybrid renderer you just add them with a IConvertGameObjectToEntity and use the input ConversionSystem parameter to .AddHybridComponent(thecamera)
But they're not singleton entities.
a singleton entity just means there is only one entity in the world
nothing else
you can actually place multiple of them into the world if desired, it will just assert that hey it only expected one, you sure about this?
This is interesting.
So OnCreate really happens very early.
Even before the AfterGameObjectConversionSystemGroup.
strange my 2 physics entities aren't colliding auto-magically...
what am I missing here?
And then before that hybrid render init even.
This has been most educational, thank you once more, @low tangle
yep, your welcome
no wait... I'm dubm
protected override void OnCreate()
{
base.OnCreate();
RequireSingletonForUpdate<TagMainCamera>();
RequireSingletonForUpdate<TagSpaceCamera>();
}
protected override void OnStartRunning()
{
base.OnStartRunning();
_skyCam = EntityManager.GetComponentObject<Transform>(GetSingletonEntity<TagSpaceCamera>());
_avCam = EntityManager.GetComponentObject<Transform>(GetSingletonEntity<TagMainCamera>());
Debug.Log($"<color=white><b>CameraSystem</b></color> using {_skyCam} and {_avCam}.", _skyCam);
_goalRotation = _avCam.rotation;
}
Damn. That's a lot cleaner. A little singleton-y but actually the first time an intrinsic DOTS pattern has caused me LESS boilerplate.
Wow, with OnStopRunning I can also make the Ui event subscription so much cleaner.

Hi all! I posted a topic: https://forum.unity.com/threads/netcode-issue.1048922/ would be really appreciated if people with DOTS/Netcode experience could check it out! Thanks a lot!
Hi guys!
I followed the Unity Netcode guide: https://docs.unity3d.com/Packages/com.unity.netcode@0.6/manual/getting-started.html
I have made all...
There's a bug nowadays with the prediction tick, you can find other topics on the forums. It's not your fault.
For the migrating from the PostUpdateCommands part, are you sure you wanna playback the ECB immediately ? Why don't you add to the end simulation one ?
I began migrating to SytemBase too, but didnt touched yet the ComponentSytems that had the PostUpdateCommands shortcut yet. To keep momentum in the project ๐
.
Thank you @karmic basin for your answer!
Why don't you add to the end simulation one ?
I just follow an example on google how to use the ECB
You're welcome, happy coding. Maybe someone will give a better answer on your forum topic
I am not actually sure of my implementation
and form the docs ?
Talking about the ECB it was made to answer to main problems
When you're in a job, you can't access the EntityManager.
When you access the EntityManager (to say, create an entity) you invalidate all injected arrays and EntityQuery objects.
The thing is now we can access the EntityManager from a System
So is it really still necessary?
I have made another test without ECB it works the exact same
(with the bug, I talked about of course)
You should in the main thread, if you .Run() immediately should work
see that
GoInGameClientSystem
protected override void OnUpdate()
{
Entities.WithStructuralChanges().WithNone<NetworkStreamInGame>().ForEach((Entity ent, ref NetworkIdComponent id) =>
{
EntityManager.AddComponent<NetworkStreamInGame>(ent);
var req = EntityManager.CreateEntity();
EntityManager.AddComponent<GoInGameRequest>(req);
EntityManager.AddComponentData(req, new SendRpcCommandRequestComponent { TargetConnection = ent });
}).Run();
}
without ECB
protected override void OnUpdate()
{
var ecb = new EntityCommandBuffer(Allocator.TempJob);
Entities.WithStructuralChanges().WithNone<NetworkStreamInGame>().ForEach((Entity ent, ref NetworkIdComponent id) =>
{
ecb.AddComponent<NetworkStreamInGame>(ent);
var req = ecb.CreateEntity();
ecb.AddComponent<GoInGameRequest>(req);
ecb.AddComponent(req, new SendRpcCommandRequestComponent { TargetConnection = ent });
}).Run();
ecb.Playback(EntityManager);
ecb.Dispose();
}
with ECB
Same for all the other Systems from the get started guide ๐
Yes I use run because they used ComponentSystem for their System in the guide which is the equivalent of SystemBase => Run() if I am not mistaken?
Where do you see that in the docs ?
I dont get the eason you need to playback the commandBuffer immediately. If I remember well, tehre's a sync point anyway just before the system that sends Commands to the network (would have to double-check that)
The first question is, Is the ECB really necessary?
Second question, should we Run or Schedule the system?
You could RUn, it's supposed to be done once, to join at start
We are on the same page on this one
and so use the EM ?
I guess ๐
Yeah I checked I didnt updated this part yet. But that's how I would begin with. The user wont see a difference
ok
For the SampleInputSystem would you rather Run() or ScheduleParallel ?
because it is sent multiple times
Run, there's only one to process, the player
Right. thanks for your help!
You're welcome, have fun !
This shouldn't need WithStructuralChanges() does it? Since there are no structural changes inside the lambda
Hey, can't quite find online an example of just playing a sound through DOTS
seems I can reference an AudioSource but idk how I would access the clip data from that, and use that to make a sound play from a Entities.Foreach in a SystemBase
It does ๐
Otherwise the compiler is complaining
Well you don't see the content of my lambda that's why I added "..."
so from what i understand, when unity loads a scene all subscenes will be loaded into a seperate conversion world, and moved into the main world after loading is complete
is there a way to mark that unity's systems need to wait before moving, so you can do some custom processing after load yourself?
or would it need to be like conversion world -> custom staging world -> main world
Ah right, I thought it was just the entity creation you showed in the snippet
I've never tried it but could you mark your system to UpdateAfter one of the built in conversion systems?
prob but it's something that can take multiple frames so ideally i'd just wanna be able to set a component to say when loading is done or something
to not stall main thread
@hollow sorrel Can't you use GameObjectAfterConversionGroup or GameObjectExportGroup ?
@hollow sorrel afair there is no conversion world at runtime (since subscenes are already converted) - entities are streamed into a streaming world and then moved to the main world as soon as possible, I don't think there are any systems in the streaming world.
I'd say for what you're doing, you may create your own staging world, load the subscene into it, do the processing and then merge with the main one. That is of course assuming you can't do that processing at conversion time.
ah
yea suppose staging world is the way to go, less reliant on unity stuff changing too
ty
Can I copy unity_DOTSInstanceData from one shader to another somehow, or even better, take my pick?
The data is already created but I want to use some of it in an override material.
The override material currently seems to get clobbered hybrid instancing data.
I tried to just replicate all properties from the one shadergraph in the other, but... that didn't work.
Is it impossible to use nested native collections?
I get error with this
public struct AtlasData
{
public NativeHashMap<uint, AtlasSample> UVs;
}
public struct AtlasSample
{
public byte TexturingType;
public NativeArray<Rect> UVs;
}
ArgumentException: Client.Dots.AtlasSample used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer
Any workarounds?
It looks like you have to use primitives for NativeHashMap
What you can do is have a NativeHashMap<uint, uint> where the latter uint is the index for another collection
Or something like that
Good idea. thanks
or NativeMultiHashMap with key uint2...
But why NativeHashMap?
Just using instead of dict in jobs
does anyone know of an example for the new input system being used in dots?
I've tried one method but I keep getting multiple outputs for one button press and can't figure out how to fix it
that's awesome, thanks @deft stump
I've got some weird problem with mine it seems like it's taking a single input and stretching it over multiple frames
are you trying to mimic GetKeyDown()?
yeah I've tried all the interactions basically I either get no inputs or still get like a random number 3, 4, or even 5 outputs
try installing the preview package of New Input system.
there you'll get the .WasPressedThisFrame() function like what you see in my code.
I'm on 1.01 I'll have to try that thanks
If I'm looking to create a 2D management game do I need the "Entities" or "2D Entities" package? And if I don't plan on using physics will I need the "Physics" package?
You'll need Entities (com.unity.entities). 2D Entities is for Project Tiny.
As for the physics, maybe? Probably. There's some dependencies that you dont need but Entities does.
@robust scaffold And Project Tiny is the package that shrinks file sizes correct? What if I plan to use that/ tinker with it?
I've got my basic package list trimmed to just this:
"com.unity.dots.editor": "0.12.0-preview.6",
"com.unity.ide.rider": "3.0.3",
"com.unity.platforms.windows": "0.10.0-preview.10",
"com.unity.render-pipelines.universal": "10.2.2",
"com.unity.rendering.hybrid": "0.11.0-preview.42",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0"
You can replace Rendering.Hybrid (Hybrid renderer) with com.unity.entities: "0.17.0-preview.41".
Project tiny is a complete rewrite of the basic Unity engine. I dont recommend using it. It can only do very basic things.
And it shows how sad my life is when I can write out the entire entities package line from memory.
Back here again because i didnt understand / not sure what to do. Would DOTS been good for type of game. To keep performance up ?
@robust scaffold I see, thanks for the help and that list as well
@robust scaffold What's the difference between HR "0.17.0-preview.41" and "0.10.0-preview.10" ?
DOTS performance is.... questionable. Entities, oh it's fucking amazing. Burst is literal magic.
Rendering the data though, Hybrid renderer is garbage. Worse than garbage, it actively destroys your performance. I'm working with it because I'm trying out some prototypes with DOTS physics which is ehh. Honestly stick with regular Gameobject workflow if you need any physics because no matter how good DOTS physics is, Hybrid renderer is worse.
Hybrid Renderer has "upgraded" a lot between version 10 (a year or so ago) and the recent version 17. With DOTS, you're on the cutting edge of unity development and you need to keep riding the wave of updates.
I literally have zero understanding what dots / entities is. So im going to need an explanation from ground zero
Let me add 3 more cars. and show you my propfiler
Profiler
Have you written shaders before? It's like a hlsl shader except you define what the vertices (entities) and pixels (components) are and you write the fragment shader (systems).
All in C#. You also get the fun of staring at compiled code (burst compiled output) to micro optimize to your hearts desire.
https://streamable.com/tiv14o Example @robust scaffold
@robust scaffold Is there a "thank you" system on this server?
Hrm, semi destructables colliders aren't really an region where DOTS can shine. Kinda but if you want performance, start writing compute shaders and calculating mesh deformations.
I bought an asset that can seperate a mesh into individual voxels ๐ญ
Nah, just words is good enough. DOTS is an entirely new way of coding so good luck. Took me months to figure out how to code in ECS format and I cant go back.
Oh boy, never buy assets. Terrible idea. Always good to code and learn things yourself. Here's a good guide to compute shaders and it's a giant rabbit hole from there. https://www.youtube.com/watch?v=EB5HiqDl7VE&t=532s
โ๏ธ Works in 2020.1 โ 2020.2
๐ฉน Fixes:
โบ Make sure your source mesh has read/write enabled in it's asset importer inspector.
Compute Shaders are scripts that run on the GPU! They're very powerful, allowing you to leverage the GPU's unique abilities and generate meshes to draw procedurally. There's not a lot of information on using them, so I hope...
And if you learn how to write compute shaders, you'll pretty much know how to use ECS in general. Not just DOTS.
@robust scaffold Yeah I want to learn something new and if data oriented is (possibly) the next big thing, that's where I wanna be. Or at least ahead of the others. Thanks again. I'll probably have more questions in the near future as well lol
Hrm, okay. You might be able to use it somewhere but for your specific requirement, destructable car racing with reasonable performance, it must be a compute shader. DOTS is more for data management and honestly agent simulation than anything like physics.
The cars are just for prototyping, It's going to be a 3D dungeon crawler. I just looked at that video and.... ๐ฌ
That sorta stuff is far beyond me
Yea, it's pretty intimidating from first glance but it's not too hard. Just apply writing frag shaders to arrays. Hardest part is defining the wave size. Plenty of guides and tutorials out there. Is this your first game?
It's not, But its my first game where im doing alot of things for the first time. Like shops and also this rigidbody stuff
Okay, then I recommend making smaller individual prototypes to focus on one new aspect of Unity at a time. One project to dip your toes into shops. Another brand new project to understand unity physics, a third to try out compute shaders, and so on. Then once you know them all, create a "final" project to use all the information you've learned through previous prototypes. You'll probably need to branch out more projects as you experiment without all the bloat of the actual main project.
thats the heirarchy of 1 of the cars, I can reduce the amount of voxels and that will be fine for more objects. But i just wanna get it as performant as possible before i go any further. Since i don't want to get to a point where the game itself is going well. But im getting bad performance because of this rigidbody shinnanigans
https://store.steampowered.com/app/1380400/Saving_Grace/ This is my previous project, So im branching out as it is. heh
Hrm, yea I seriously dont recommend using this voxel tool for any moving or even static objects. The amount of calls every frame to update game object positions is going to destroy performance.
๐ญ
I was thinking about adding a RB to the voxels on raycast hit (From gun), rather than them always being there. Would that be any better?
Since atm, on start they are set to Kinematic, and even then the fps is severely effected
Honestly Im the wrong person to ask about physics. Most of my projects are akin to fluid simulations and not rigid body physics. You'll be better off asking down below in the physics channel but I'm fairly certain DOTS will not help with your performance.
Well DOTS will help, just not to the performance requirement of a playable game.
May want to ask in #โ๏ธโphysics
I shall ask in physics, thank you
Is anyone using LODs? Is it possible for an LODs to share one material?
Also, having multiple LODs as child entities creates a lot of overhead for LocalToParentSystem, so is there any way around that as well?
Okay so none of my entities with mesh rendering components actually show up now that I added ENABLE_HYBRID_RENDERER_V2. Previously they were all rendering, but render batching was taking a long time. I've gone back and forth through the documentation for the hybrid renderer and I think it's got something to do with needing to create a shader and an IComponentData for the custom properties on that shader. But the docs mention pre-built property overrides and associated components. What's the bare minimum I need to do to get a mesh to show up in the Hybrid V2 renderer?
You may need to disable or enable SRP batching in the graphics configuration assets
Thanks Sark, I'll look at it.
Hmm, my tests with Bursted Systembase resulted in this: 95% of the performance boost is coming from bursted jobs. 5% comes from the bursted OnUpdate.
Is it worth converting everything to IJobChunk and all containers to NativeArrays just to burst OnUpdate? Definitely not.
Will I do it just to see a flat 0.0 on the systems tab instead of an occasional 0.1 flicker? Yes.
I think you need to check out the profiler to see bursted system costs, I read that the systems window wasnt reporting correctly
I'm planning to update to ISystemBase but so much seems to be missing atm
I was looking at the FPS counter for the game stats. Only one system and 100,000 entities randomly categorized into 3 groups by component value (static components and SCD filtering not supported by ISystemBase in general). Add by 10,000 / number of entities in group every frame. And yea, the system window from the new dots editor is borked.
Currently I dont recommend ISB unless you're willing to throw everything out the window. I can live with everything being IJobChunk, it's like IJobEntityBatch except with even less to input (no need to define number of entities per batch). The big problem is that all containers must be a NativeArray (or UnsafeArray) since that's the only container that allows for [DeallocateOnJobCompletion]. Unless you are willing to introduce frame dependency by calling CompleteDependency() in OnUpdate every frame, there is no other way to deallocate a temporary native container.
Sweet will definitely hold off updating
@zenith wyvern the problem was I had no idea how the URP worked and I didn't have a UniversalRenderPipelineAsset created and set in my projects SRP settings
But it's working now and I learned a lot in the process. Victory.
I'd been relying on the built in renderer and enabling that Hybrid Renderer flag caused it to look for URP/HDRP and I didn't have either render pipeline setup so nothing was rendering. Whoops.
in built-in rp, how do I change the color of the material?
I can do it in URP but I'm not too sure in built-in
How can I interact UI with Entities? through the EntityManager?
oh
IJobChunk has been superseded by IJobEntityBatch, which should be used for new code.
so I'm guessing I'm going to use IjobEntityBatch
How can be done logging app with DOTS and FireBase. So some system working om main thread not a problem but what can be done with another. Or some tips how can app be covered by logs?
That's not relevant IMO. Or I miss something. Yeah you can use Firebase's Unity SDK in a system main thread, same as you would without DOTS. What do you expect DOTS to bring to the table ?
Mass logging from Entities inside threaded jobs ?
Something like that system executed. If some logic mistake and somewhere didn't add/remove component and next system didn't match query. Or logs values used in components
Unless you want to start messing around with ISystemBase which doesn't support anything except IJobChunk
I'm not using ISB for now
but
I'm hitting a perf degradation though
so here's the scenario:
I have about 2500+ cubes spinning in X and Y axis and also jumping via dots physics
I'm getting about 30 fps
HOWEVER
I did it in classic unity and the perf there is higher
I'm confused why doesn't other jobs work with ISB?
because it's very unfinished
Oh ๐
Yea that's a valid reason lol
What parts screw up with ISB if you use another job?
will just spew confusing errors
@deft stump you disabled jobsDebugguer and safeties ?
O I should try and take a look. I've been using IJob without any problems so far
oh tbf I haven't tried IJob
renderer v2 is tired ? ๐
I didnt pushed yet com.unity.physics to 2500+ RB updates
But I wonder about those perfs myself, I'll have to at some point
I think for most intensive purposes with ISB (if you want to mimic SystemBase) you'd need to call SystemState.CompleteDependency() (eh I might need to check this up)
@karmic basin I can show you through a vid call
if you want to ofc
also enable v2 hybrid doesn't work
coz
I'm using built in
I would need to try that myself before I can help with valuable insight. I'll just make you lose your time at this point
Are you guys using jobs at all? I only use jobs for really expensive stuff that I know I don't need to complete in the next +50 systems. Everything else just seems to add more overhead than it's worth.
@karmic basin Going back on our yesterday's discussion. Adding RequireSingletonForUpdate<GhostPrefabCollectionComponent>(); into the GoinGameClientSystem.OnCreate fixed my rendering/spawning issue :).
I can confirm that I have now a working Getting Started sample Unity NetCode updated and using the latest unity dots changes (SystemBase, EntityManager in query lambda...)
Awesome ! But I don't understand why the client would need the ghosts collection to ask to connect to the server ?
Wait, are you trying to spawn ghosts from the client ?
No, but the issue is that the request of spawn by the client is send before the actual list of prefab has been loaded by the server system and so on... you see what happens.
I guess Tom from Unity told me to put it here and not in the GoInGameSystem to not actually send the GoInGame request because the list is not ready yet
there is no need to make a request if the mandatory stuff are not yet loaded on server side
And also it's added into GoinGameClientSystem because the request is done automatically at app launch and the component NetworkStreamInGame added to it. The problem is that even though the prefab collection was not ready and as the component added to the client, we will not retry a connection request next frame update ๐
Strange, didn't happen to me yet
What could have been done also, is in the GoInGameServerSystem check if the var ghostCollection = GetSingletonEntity<GhostPrefabCollectionComponent>(); is not empty if it is remove the NetworkStreamInGame from the entity requesting the connection in order in the next update to have a retry
this list sorry
var prefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection);
because the request is done automatically at app launch
I anticipated that and thought about screening it behind a login action from the player anyway :p
Is it because you have a huge amout of ghosts in your collection ?
nop
I wanted to say as the process starting directly at app launch, everything is going too fast and I faced the issue of a mandatory list not being loaded before it's actually used. On your side you could not see that issue because your process is behind a login action button, that's it ๐
yup
still protect it
You'll use server & client apps in the end ?
Yeah maybe just in case, but I aim for a headless server anyway
server will be up and running way earlier than clients
I am testing on all scenarios, client only, client&server and server only both from Unity Editor and Standalone
Everything works as it should now
sure
Yeah that's a nice edge-case you found there
@karmic basin I found my answer.
I will add the check
race condition* I mean
I'm being screwed over by dots physics systems
did you make sure you put [BurstCompile] specifically above OnUpdate() btw? It's only then that you see the issues.
it's not just on the systems, it has to be over OnUpdate as well
Latest com.unity.physics ?
yes
@karmic basin
It's even bursted!
yeah I dunno how to turn off physics debug stuff
I'll try with HRenderer v2 and 2.5k rigidbodies when I have the chance, for now I can't tell if that's expected or not.
1000 bodies give more reasonable results ?
hrmmmmmmm
I'll try
I hope I can delete them though LOLOLOL
theres so many without my editor choking
Damn's that a shame yeah I guess I get it too - those errors :/
GameObject conversion ?
yeah
FWIW I've noticed physics runs soo much faster at runtime. It's really really slow in the editor
so build and test
alright
we really need the option to disable phhysics debug systems or something
You can profile the build if you set it to "Develop"
Although.. I did notice I sometimes don't get the error if assign the dependency rather than complete. E.g. state.Dependency = job1.ScheduleParallel(someEntities, 1, state.Dependency); sometimes seemed to work
cool - I guess since SystemBase does internal tracking of dependencies - we'd need to try and replicate that into ISystemBase lol
I found setting World.MaxDeltaTime while in the editor helps combat the FixedDeltaTime death loop
Or maybe if (prefabs.Length == 0) return; right away ? We don't want any of the following anyway
and u need to remove the NetworkStreamInGame from the client otherwise u will not pass into the GoInGameClientSystem Update() method because of Entities.WithStructuralChanges().WithNone<NetworkStreamInGame>() I guess
But again this will happen only when the process starts directly from app launch, usually you have a login menu etc...
so better to protect it directly from the GoInGameClientSystem and not touch the GoInGameServerSystem
protected override void OnCreate()
{
RequireSingletonForUpdate<GhostPrefabCollectionComponent>();
}
what is worrying me though
is that this line did not throw any error even though the GhostPrefabCollectionComponent was not ready
var prefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection);
That means it returned 0 instead of null ?!
Not everything is clear
Oh yeah that's the first thing the system tries ๐
missed that one
hmmm supposed to be null AFAIK
ghostCollection yes in my case supposed to be null but why then no error was thrown when doing
var prefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection);
Well it's an int, so probs zero ^^
it's supposed to return a DynamicBuffer
so maybe it returned an empty DynamicBuffer and then my case was not handled (aka remove the NetworkStreamInGame from the client etc..)
yeah but .Length is 0
and yeah length = 0 the case is not handled ๐
okayyyy we were not talking about the same line, I need coffee
how... do I use the new build pipeline again?
@deft stump Right click create => Build => Empty Configuration
then select your file => Inspector and add component u need
at the end you select your config file => inspector => Build
probs doing some background work on the right low side ?
you also need to make sure you have the com.unity.platforms.xxx you target
I do
cool
uuugh this is so frustrating just to present a demo
yeah
I wanna throw a chair
okay
I'm still being screwed over
this is frustrating
uuugh
@zenith wyvern I'm still being screwed over
Ouch. What does your timeline look like?
Just for visual debugging in the editor I think. Yeah that's pretty bad. Whats happening in your game to cause that kind of physics load?
Did you try switching to havok physics?
spinning and jumping (ofc there's gravity)
Are you controlling them manually or setting velocity in the rigidbody?
I'm not controlling them manually
there's a timer that is set to jump
but I've already deduced that isn't the case
can you disable or remove the physics debug display component?
i find that its terribly slow
There's a PhysicsDebugDisplay authoring component
maybe unticking everything disables everything
yeah should help based on what I see here
PhysicsDebugDisplayData is the comp added on conversion containing those authoring checkboxes
Or maybe systemGroup.RemoveSystemFromUpdateList() on DebugStream system ๐ค ?
https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.ComponentSystemGroup.html#methods
Don't know the implications though
Locus, skies falling, seas becoming as blood. Generally bad.
Iโm guessing though.
Scratch that, misread the condition. Shouldnt execute if you don't put the component (as one would expect). The checkboxes only allow you to include/exclude with more granular control.
Should I create singleton entity or it is created automatically?
pretty sure it was created automaticly if you used SetSingleton (or something like that
question: how do you structure your ecs project ?
currently, I have a folder for all components, and another folder for all systems, etc.
but I am not sure whether this structure is the best, because there are systems and components that are logically bind together
and when I use assembly definitions for stuff like unit testing, it is better to have these things packed together in the same subfolder
Does anyone know how I query the camera in tiny
In the example it just queries the camera component , but how is that component created
It's created by a conversion system that runs on the regular camera during scene conversion
Is this automatics
I remember something like that on Hybrid you just needed to add something to Scripting Define Symbols
Or is my memory failing me
Not sure what you mean. It's a GameObjectConversionSystem, so it runs any time the monobehaviour it's targeting gets converted
Is there a sample how to unit test conversion system? Afaik conversion runs in separate world. IDK how it communicates with default one
@zenith wyvern I think this is what my foggy memory is thinking off
Iโm a bit confused why my entities are rendering sice I have not explicitly converted my camera and I canโt query a camera component in a system
As singleton it return 0
Are there any news about 2D in dots except 2D Entities package which is only for project tiny?
IConvertGameObjectToEntity.Convert() has a reference to the destination world's manager. Also you can get the "PrimaryEntity", the one/first that will be automatically linked to your GameObject
@acoustic spire can't tell you more as I didnt set up tests yet, but did you try to see how Unity does them ? They probably have some for loading GOs, subscenes, and such
Mmm Iโm lost , Iโm looking at bare bones Tiny 3D git example , camera is in not in sub scene , no conversion or authoring component... but I magically work and I see no camera entity. What am I missing here , is it not using the RenderMeshSystem ?
I searched through Entities.Hybrid.Tests and found nothing similar. May be my way is wrong: I want to initialize 2 worlds, create corresponding systems, update the worlds and validate the results
Not related to ConversionSystem then ?
Unity.NetCode.Tests.BootstrapTests looks interesting
netcode spawns both a client and a server world after the default one for init
I think you can find good stuff even if not interested in network
But I guess they should have same Test in Entities without netcode to check for multiple worlds
@acoustic spire https://hatebin.com/ymayjldeih
Yep. It's interesting. Thanks.
So I group around 'feature' eg pathfinding, will then have sub folders for components and systems
makes sense, but what if I end up with a component that is used in multiple features ?
Same pretty much. But I don't bother with subfolders unless the base folder starts to get cluttered
I usually have a "Common" folder for shared stuff
maybe I should experiment with these things more
isn't there some sort of "best ecs practices" book or something ?
I don't know about that, I usually just look at other people's projects and if I like what I see I copy it
Did you see they tried a DOTS Visual Scripting tool before buying Bolt ? It's kinda irrelevant now but started very promising
How to troubleshoot situation when a system isn't updated?
In my case BlobAssetUserSystem never updates though it has UpdateAlways system attribute
// Create 10 entities
for (var i = 0; i < 10; i++)
{
var e = m_Manager.CreateEntity(typeof(TestComponent));
m_Manager.AddComponentData(e, new TestComponent {Value = 0});
}
// The system should set up Singleton component
World.CreateSystem<AtlasBlobAssetConstructionSystem>();
World.CreateSystem<BlobAssetUserSystem>();
World.Update();
If you put a Debug.Log inside BlobAssetUserSystem's OnUpdate it doesn't print?
it doesnt
may be something with world initialization. I'll try 5argon test classes
If I remember correctly you have to add the systems to the update list of a component system group
Works!
So yeah, I need to create system group first. Like this:
// The system should set up Singleton component
var s1 = World.CreateSystem<AtlasBlobAssetConstructionSystem>();
var s2 = World.CreateSystem<BlobAssetUserSystem>();
var g1 = World.CreateSystem<InitializationSystemGroup>();
g1.AddSystemToUpdateList(s1);
g1.AddSystemToUpdateList(s2);
World.Update();
TypeManager.FieldInfo is not available in 2020.2 Unity.Entity preview17 solve?
obsolete: https://docs.unity3d.com/Packages/com.unity.entities@0.2/api/Unity.Entities.TypeManager.FieldInfo.html
here is missing, but there is TypeInfo instead, build a code here, why gets overwritten? https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.TypeManager.TypeInfo.html
thats a very old version...
wait very confused, the doc is 0.2 but your refering to latest version?
that docomentation that i found, 2020.1 had that integrated
also there in 0.5.1-preview.11 but not in preview 17 https://docs.unity3d.com/Packages/com.unity.entities@0.5/api/Unity.Entities.TypeManager.FieldInfo.html?q=TypeManager.FieldInfo
im still confused what the issue is? Unity changed FieldInfo into TypeInfo?
Unity.Entity.TypeManager.FieldInfo changed into Type? upgradeguide? https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.TypeManager.html
sorry man, no idea, check the change logs untill you find exactly what version removed it, maybe something in there.
Or just try changing it to typeinfo? ive never used either so no clue what they are for
I would just download the older version of Unity
13 Errors to fix, with that Field changed to Type?
try it and see
It is the Sample: TinyKarts from Unity Project Tiny https://forum.unity.com/forums/project-tiny.151/
yes, if you want to try it to, with you sucsess with actual version Unity Rendered Pipeline URP, get from here it is a fast webgl https://forum.unity.com/threads/project-tiny-0-32-preview-is-available-ui-new-skinned-mesh-renderer-blendshape-sample.1045204/
I use it for my roguelike which is turn based. Some parts were annoying and not very intuitive, like setting up game phases. Personally I still prefer it over OOP since it keeps my project maintainable as the scale grows, since it forces me to keep everything nicely separated
If you've made games outside ECS before and you haven't had any problems then ECS isn't going to do you any favors I would think
Ya that is 100% the issue.
Data modelling of cards/players?
Super clear.
Phases and sequencing?
Wat.
Specifically the reactive nature of card games is what's tripping me up.
What made it click for me is making use of singletons for "game state". So a system related to some state or phase will only run when a singleton representing that state/phase is present
broken shader, from msg above, burst re-compile..
Kart Racing is a dots/ecs project https://github.com/Unity-Technologies/ProjectTinySamples/tree/master/TinyRacing
//From: NativeArray<TypeManager.FieldInfo> typeManagerFieldInfos = TypeManager.GetFieldInfos(typeof(T));
NativeArray<Unity.Entities.TypeManager.TypeInfo> typeManagerFieldInfos=TypeManager.GetTypeInfo<T>();
//but file gets overwritten, by recompile! (package-update-howto?) GetSaveSystems.cs (see open in new tab!)
In other channel also try to solve this Sample Unity Tiny Kart Project similar to fast WebGL https://discord.com/channels/493510779866316801/768488207109062697
adding @karmic basin to this response.
I don't have Physics Debug Display component attached to any entity
And that makes the entire thing so confusing.
WHAT IS IT DEBUGGING!?
@deft stump what happens when you toggle the system off in the entity debugger/systems view?
How do I get a managed component from entity?
GetComponentData doesn't work with classes
In Unity 2019 render pipeline 8.3 is to old CoreUtils.cs errors1
GetComponentObject
a lows of 20, highs of 90
it's still wildly fluctuating
the culprit lies in BuildPhysics world
it completes the job
not schedule it
I don't think it's a scheduling issue - you can see the CreateContacts job is taking forever
Not sure why physics would be so slow but it does appear to just be physics being slow
This jumping - are you doing it in a FixedStep system?
no...
If you're interacting with physics at all you need to [UpdateInGroup(typeof(FixedStepSimulationSystemGroup)]
Hrmmm
Not sure if that will fix the issue but yeah
If it's still bad you can try reducing the fixed timestep
Wow, just that is causing that performance drop?
yep
my systems are very simple.
and even if I put the if statement outside the foreach, the result is the same
Okay a low of 20s and high of 70s
.....
my jump system is being completed right after schedule
uuuugh
this is so confusing
why are you completing reeeeeee
It has to complete since it's interacting with physics. Physics is running it's fixed step mutliple times in a frame, so it makes sense it needs to complete dependent jobs multiple times as well
I don't know why you're worried about scheduling, profiling has already showed you the physics is just being slow
Your best bet would be to ask why your contacts job is so slow on the physics forum
Oh yeah, and you might be getting odd results from reading input during a fixed timstep too https://forum.unity.com/threads/fixed-timestep-features-coming-to-entities-dots-physics-packages.899687/
Actually I guess you're not reading input, but probably still worth reading over that to make sure it works the way you expect inside a fixed timstep
dots / ecs / burst all build slow and the packages are mixed from wrong versions of unity, that fails to build same sample project from documenation, once had compile blue screen!
Clean all 3 Unity Versions, to try dots OBAMA/TRUMP again?
Yea I saw
https://tiny.vision/demos/TinyRacing/Wasm/TinyRacing.html <--Drive a round of Kart Race here like webgl dots building, play? https://github.com/Unity-Technologies/ProjectTinySamples/raw/master/res/TinyRacingTrailer.gif
Hi all
Can we store native collections (Native Stream mainly) within shared components?
And can Shared components be a singleton?
Hi guys! Anyone have any production experience with dots/Entities on mobile? ๐
the error is pretty self explanatory, you need to edit an scene object to add references
@ocean tundra i think longterm sharedcomponents will only be allowed to have blittable types
Hello, is there a way to index struct of arrays the same way that unity is indexing int3, float3,... types. For example, you can use int3[2] to get the z value of int3. Could the same be used in a struct which only has a bunch of arrays of the same size? E.G Grid[5] return the 6th NativeArray<int3> in the struct.
you can overload operator[]
public T1 this[int index] { get {...} set {...}}
Yes, though I've been struggling with it, can't use Marshal library since i need this struct in a job and the job system is not allowing me to use it, throwing exceptions. Trying to use UnsafeUtility, but mostly just been crashing.
There is the evil pointer arithmetic way...
get {
fixed(NativeArray<int>* ar = (NativeArray<int>*)&this)
{
return arr[index];
}
}
}```
emphasis on evil
(typed this without checking so may need some compiler error fixup)
First thing i tried, since unity uses same thing with their int3, float3,... types. However, using NativeArrays for this throws "cannot take the address of, get the size of, or declare a pointer to a managed type".
ugh, right, nativearray is not blittable
ok, so the only way seems to be a switch(index) {... }
manually returning each option
Finally got it. thanks for the help @worldly pulsar
get
{
void* pointer = UnsafeUtility.AddressOf(ref chunk0.nodes);
Astar_Chunk chunk = UnsafeUtility.ReadArrayElement<Astar_Chunk>(pointer, index);
return chunk;
}
What is chunk0.nodes?
NativeArray<float3>
Instead of AddressOf you can use chunk0.nodes.GetUnsafeReadOnlyPtr() to also have job safety
Might also be more descriptive but idk
GetUnsafePtr() and GetUnsafeReadOnlyPtr() for some reason crashes. Only UnsafeUtility.AddressOf() works.
Huh
Are you sure the bounds you are reading from are correct?
GetUnsafeReadOnlyPtr only calls the atomic safety method and returns the buffer
It should throw an exception and not crash when something would be wrong with the method
Or the job system would break apart
yep, i just replaced "UnsafeUtility.AddressOf(ref chunk0.nodes);" with chunk0.nodes.GetUnsafeReadOnlyPtr(). The AddressOf works fine, the GetUnsafeReadOnlyPtr() crashes. Not sure what's going on, but AddressOf() will suit my needs just fine.
Pretty sure AddressOf returns the address of the NativeArray not the buffer inside it
Wait just read the messages above, you have multiple native arrays inside your Grid and trying to return the one at the given index?
What is Astar_Chunk then?
Astar_Chunk is just a NativeArray<float3>
Ah okay, yea that should work fine. My bad ๐
anyone knows?
know what?
how to fix that error
I don't really need to explain because the error is clearn just read it ^^
You can't creat a object when your graph is opened in asset mode
Just get out of the asset mode and create it in the graph
dont know why this always appear every time
anybody know how to fix this
every time after compiling ,these four error occur
but i dont get any error while running the actual game
have tried re installing the burst package ,didnt work
interesting part is ,when i copy the whole project to another disk(not C:/), and tried to open it,these errors gone, so it
only errors when the project in C:/
Question: When I set mesh.SetVertices(dynamicBuffer.AsNativeArray) and then modify the dynamic buffer in another system, will mesh reflect the changes?
No
It copies the array somewhere?
Yes, writing into a mesh always copies the data
sad
๐
Quick Burst question - for, probably, small arrays is it better to let the array loop all the way or break out when you've found what you need when it comes to burst compilation?
or for large arrays for that matter
I know break is supported, but is it worth it?
Hello again DOTS friends,
Happy to announce a new Collection has joined the family, as well as a release build. ready to drag and drop into your projects!
https://github.com/DennisCorvers/UnsafeCollections/releases/tag/1.0
Happy programming everyone!
@low oasis I do, but not sure if it costs or not
@gusty comet Why use those over the built in ones?
just more options?
Fantastic. How does this look under burst? All I need now is some collections with preallocated memory like the FixedLists. I have my own hacked together implementation of a FixedRingBuffer but would like more options honestly.
Can they be stored in components? (IComponentData??)
Unmanaged but still dynamically allocated memory collections. You technically can put them into Components but it'll be like using Unsafe-X currently. Not very efficient and will destroy your cache.
Also a suggestion, a MultiHashMap with unique values as well as keys. Current implementation by unity is basically a collection of lists with unique keys. Would appreciate a collection of hashsets.
These shouldn't be difficult to create by using the available types (Don't mind the @ that's a mistake)
And if you can also make a version with fixed memory allocation (structs of fixed number of bytes) and all the same usages, I'll place you up next to Jackson Dunstan in terms of magicians in burst. I dont have any higher honor than that sadly.
For project tiny should all UI text be texMeshPro
For now. Apparently they're trying to make UI Elements work and TMP is baked in.
Is that the end workflow in mind UI Elements to TMP ?
Or is that a temp thing they are working on
Ultimately, unity wants everything to use UI Elements. From the editor windows themselves to the game UI as well. Currently, Tiny seems to be using some sort of hacked together GameobjectUI but the roadmap, as trustworthy as it is, has UI elements total integration and only option as the end goal. As with the rest of Unity in general.
UI elements has so much boilerplate though. Reminds me of the old days of DOTS and the current state of ISystemBase. It also has the same amazing potential as DOTS currently. 1 or 2 draw calls for the entire UI and dynamic updating of parts of the UI. Literal magic.
But holy shit the boilerplate. Want to write text and align it to the top left of the screen? 20 lines of code.
I think I would be ok writing more code if it worked in tiny
If you want the features, you'll have to go back to the general pool of DOTS. Project tiny honestly feels like a 2 man, if very enthusiastic, hobby like URP's Boat Attack. Very interesting workarounds and tricks but honestly unsustainable.
I thought tiny was my only option for ECS on webGL
In unity, it is unfortunately. Outside unity, hrm. I've heard a lot of good promises of newer engines but they usually fade out and die. Browser based game development is unfortunately not that fleshed out.
Ok , well thank for the info, I will march on with TMP
Yea, good luck. I just recommend you keep in mind that UI elements is going to take over soon and a lot of the features of TMP will be pulled out or downgraded in the conversion. Consider making a temporary project playing around with UI Toolkit to get a feeling of what is to come. Performance, fantastic. Features, very much lacking.
My UI need are super simple atm, do you think UI elements can many work in tiny for some simple stuff or it just not compatible at all
No. Tiny is it's entirely different ecosystem. Building a new engine almost entirely from the ground up. Nothing from the wider unity world works with Tiny.
Unless explicitly supported by Tiny. Like I believe Burst.
Ok .. so Iโm out of option and have to TMP โน๏ธ
Yea, just dont get too comfortable. There is no long term support version of Tiny after all.
doesn't ecs technically work on webgl? just no burst and multithreading i thought
WHAT no long term support !
ECS is a form of coding. DOTS? I dont believe there's even an option to compile in webgl. There's no Platforms package for it.
Yea, Tiny is under rapid development. If you read their release notes on this recent UI integration, they're stating that the current implementation is a placeholder and that they're actively working on making UI elements, or a form of it, work. Just that they couldn't delay not having a UI system for so long.
isn't this the platforms package https://docs.unity3d.com/Packages/com.unity.platforms.web@0.10/manual/index.html
Huh, that's what Web was. WebGl specifically? No clue.
In bit confused now, if I want to build web app what should I used
From wikipedia, Unity, the larger engine, does not support WebGL but instead WebAssembly (Wasm).
So yea, use Project Tiny but dont expect to make a complete game out of it. Networking specifically is going to be a pain to make. Raw C# sockets is the only way and good luck with making your own networking solution from scratch. That'll probably be the largest part of developing a functional multiplayer game in Tiny.
webgl and webassembly are not mutually exclusive, but yeah basically arguing semantics at that point, key takeaway is that they want a game playable in browser
i tried using Tiny but imo it's not usable even for small things for another 2 years or so, there's just too much core engine missing
Singleplayer browser game, I recommend something more native than the massive workarounds game engines currently do like Babylon.JS.
Sure, it's javascript and all it's dynamically typed horror but much better support with browsers everywhere.
Different engine is not an option at this point
Hrm, then your choice is already made. Nothing we can say honestly.
Tiny.
Ok thanks for the info
As a side note, I've stared at the Entities' package page for months now and I just now realize there's more images to the front page "What is ECS" than just the first. It's a whole slideshow.
TinyKitchen with dots unityasset Sources, Browser-Play-Game
Source: https://github.com/Unity-Technologies/ProjectTinySamples
Using: Tiny Project URP Wasm Dots/Ecs similar WebGL 2, Unity2020++
https://github.com/Unity-Technologies/ProjectTinySamples/raw/master/res/TinyKitchen.gif
Compile, if you have sucsess make a screenshot, share here your succsess?
Play: https://tiny.vision/demos/TinyKitchen/Wasm/TinyKitchen.html <--play
Do I have to pass ref variables to functiosn called in entities foreach?
like this?
Entities.WithNone<NeedsCompanion>().ForEach((Entity entity, ref Coord coord, ref SpatialHashUnit unit) =>
{
UpdateCell(entity, ref coord, ref unit);
}).WithBurst().ScheduleParallel();
yup
alright thanks
but only if you change the value
wait haha it says updatecell is reference type and can only be used without burst and using run
i think update cell has to be static
oh ok haha thanks
Imagine this, a dynamic buffer that's also a hash map. I need to see if it's possible
Quick google and source code search: no. Far too much backend magic surrounding dynamic buffers that even changing the indexing just doesnt work.
I'm looking at https://github.com/Unity-Technologies/Unity.Animation.Samples/blob/master/README.md and it says that Unity DOTS Animation supports "HDRP/URP GPU skinning only." I don't know enough to understand what that limitation is implying.
Ah, I think you're right. I think it's indicating that skinning is required to take place on the GPU.
I should have been able to deduce that for myself. But thanks for coming to my aide. ๐
How much have you messed about with DOTS animation Korn?
Not at all. I'm more pure numbers entity component simulation.
Also please ping me whenever you mention me. I'm alt tabbed to my own code trying to debug something so I'm not reading discord.
So what do you do in terms of animations in your project? I'm bludgeoning my way through DOTS. I've gotten entities to render in the hybrid renderer. Now I'm trying to figure out how to handle deforming and animating those meshes.
Heh, dont have any animations. Dont have any graphics at all. I stare at a scene minimized that state "no cameras rendering" all day long. I'm trying to port an economics simulator that's purely numbers so I, thankfully, never have to deal with any of that broken graphics nonsense.
Heck yeah dude, who needs graphics
Does your project also lack animations, Sark? ๐
The only 3D project I did in DOTs was static meshes only. I'm working on animation right now for my 2D game but obviously that's a lot more straightforward
I believe @safe lintel and @scarlet inlet have at least some experience with the dots animation package though, could try poking them when they're around
I'm going to beat my head against the limited documentation for another hour or so. I don't know enough to ask any pertinent questions of an expert at this point. I'm cobbling together an alife simulation and trying to use pure ECS so that I can drive up entity counts. Eventually would like to plug in some machine learning and experiment with that space. I don't really need animations, in fact rendering anything in 3d is superfluous to what I originally wanted to accomplish. But after slogging through learning Unity and DOTS, having the opportunity to learn a new skillset animating and deforming 3d meshes is tantalizing. So I'm going to embrace the scope creep unless/until this documentation breaks my spirit.
I haven't looked at it since last year, all I remember at the time is immediately thinking "this looks too complicated for me" and deciding I would stick to 2D animation for now
Yeah I'm wagering on a similar trajectory.
If you do want to stick with 3D you could always do 2D animated sprites in a 3D world
If I bounce off this that's probably where I'll settle. That was pretty much my original plan, but I've gotten greedy.
Thank you ๐
Yep that's new with @0.17, was a single image before. Don't worry you're not blind yet ๐
Hello!
I'm trying to use DOTS to improve the performance of my really small app that I put into an android/ios application by making aar module and then run it in some activity(android)
The problem is I experience very low FPS on weak devices
The only thing that I think could help is to convert and instantiate my gameobjects as entities. (Or rewrite the whole app logic to ECS' style)
Can anybody suggest something on that? Or maybe I need to try other solutions to improve instantiating? UPD: But I am not sure that only instantiating cause the problem, maybe it is Unity itself load the process. But I think it will be better to try
Does anyone have experience with box casts (I assume CollisionWorld.CastCollider)? I'm currently having problems with some really obscure scaling and cropping issues.
The documentation sadly only shows sphere collider casts, some working box cast example would be really helpful
What exactly is your problem with using a box as the collider inside CastCollider are you by any chance using LocalToWorld.Rotation as the orientation?
Never casted a box, but it would be the same query with a ColliderCastInput as any other shape. On the official samples they showcase every one of them :
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsSamples/Assets/Demos/3. Query/Scripts/QueryTester.cs
Is Build and Run meant to work in Project Tiny samples, or is the different build configurations meant to go through a separate workflow for now? I'm trying out a Tiny project sample in 2020.2.2f1.3859.13 and it seems GameSaveSystem is not able to resolve its references to GameSaveNativeCalls in the build.
I never built a Tiny, but I remember they have a dozens of page of getting started doc
I'm sure you'll find build info in there
They sure do haha - I've been looking through that and wondering if that's part of the workflow difference for right now.
does netcode remove ISystemStateComponentData structs from an entity on the client when it's deleted on the server?
i have a few on there and it seems to delete them all except 1 randomly? I don't get it
It doesn't
i only have one reference in my code to remove my system state component. and the breakpoint on it is not being hit (I have burst off). How can I set a breakpoint on whoever is removing it?
===
are there issues with putting multiple systems in a single file? it seems that some of my systems are not running in all worlds....
nope that's not it...
World.GetOrCreateSystem returns something that's not null, but I don't see the system in my group
I guess if it doesn't run the entity debugger just doesn't show it?
ok what about this. if some system throws an exception, does it just not run the rest of the group or frame or something?
yeah.... it's lookin like this is the case
so dumb
you can also check a box to filter systems that didn't run in the Entity Debugguer, and search your prospect
oh. I"ll look for that thanks
it says "not run" instead of displaying execution time
"show inactive systems" thanks!!!
I find also "show playerloop" useful
yes!!!! I see my systems breakpoints being hit now!!!
is there any reason not to have a try-catch in every OnUpdate? Is there a significant performance impact?
public class NonSuckingSystemBase : SystemBase
{
protected override sealed void OnUpdate()
{
try
{
NonSuckingOnUpdate();
}
catch(Exception ex)
{
Debug.LogError(ex.ToString());
}
}
protected virtual void NonSuckingOnUpdate()
{
}
}
like this
Iโm trying to get text mesh pro to render on tiny , I have it setup like the example but it impossible to debug with no editor. Anyone know some common things to check
I donโt know how this is converted
From general C# experience, exceptions and stack-unwinding is a huuge performance hit.
Looking at Unity documentation, you are not going to use burst compilation if you use catch, which is going to be another pain point in performance.
https://docs.unity3d.com/Packages/com.unity.burst@1.2/manual/index.html#language-support
Look in your library/packagecache/com.unity.tiny folder. You can find conversion systems in "Authoring" assemblies
I think Iโm a version older with no tiny.UI
Latest version is .32
I was having weirdness with gamesave, I got this reply https://forum.unity.com/threads/project-tiny-0-32-preview-is-available-ui-new-skinned-mesh-renderer-blendshape-sample.1045204/#post-6768361
Maybe you have to surround all gamesave stuff with that define?
I don't really understand why you have to do that or how anyone would figure it out but yeah
I'm just trying to build the sample project Tiny2D - none of it even seems to use GameSave (which makes sense since it's a toy example)
Though, running a Tiny project without UNITY_DOTSRUNTIME enabled seems like the problem.
Wouldn't that be because weak devices have less cores available for jobs to exectue on? @gusty comet
are scriptable objects usable from within jobs etc?
like if i want to execute a method on a scriptable object?
@gusty comet i would guess no
scriptable object is a class
you could make a static method
See I always thought that static methods were not safe when it came to threads
but it seems its ok with the job system?
you cant change any data with them
they should just 'do' something, no state or data changing
They also can't read any mutable static data, so not very useful in that context I think
well what I am trying to do is add codable behavior for ai
scriptable objects seemed pretty good
so that users could just create a new behavior and code it without touching anything else
any suggestions?
You can't use scriptable objects in jobs or burst
Any suggestions for something that would work?
your scriptable objects could still be used for authoring, and then somewhere you convert them into a entity node graph
depends on your AI pattern
like im pertty sure a behaviour tree could be modeled in ECS
it would just be a bit tricky to get it going
Yeah I was going to try that but was failing on the UI side of things.
The graphview documentation isn't very good yet
yea so keep the UI as Authoring only
and use something like XNode or whatever it was
then you take that SO and covert it into 1 single ecs node tree
and your ai agents get a reference to the root tree and some other components to know where they are in it and state data for the tree
UrpScorption, but 1. repository uses Git LFS to track resources, 2. and remove Rider Editor package disturber to dots!
Oh that is awesome, the built in api for graphview is really tricky and I wasn't able to figure out how to get the wires to connect haha
I will see what I can get going now that I have some sort of way to make the graph at least.
yea been using xnode forever
its a bit odd sometimes bit way easier then building from scratch or using any built in stuff
im hoping eventually the built in stuff will get a nice API and be easy to use
tbh i feel like a lot of unities api is so verbose in the hopes someone will sell a plugin on the asset store to make it simpler so personally I doubt it xd
There are a lot of core engine features for sale on the asset store
The only thing I have bought recently is the imposter system by amplify
but again, thats a core engine feature and is in most commercial game engines already
I've never really messed with it. Whats better about it than unities built in pathfinding?
everything ๐
many different graph types, all updatable at runtime (important for procedual generation)
cool local advoidence stuff (so agents will avoid others)
and you can mix and match them all however you like
let me know how your AI attempts go, my first try at AI was terriable and would love to see how behavior trees (or something node based) works
also youve seen the AI planner?
GIT LFS, have no account yet but i try?
@gusty comet I just use SourceTree https://www.sourcetreeapp.com/
does it work to checkout without github student account?
um no clue, just make one they are free
git LFS from asset requires loginName?
no git lfs doesn't require a login name. That looks like you're trying to login to Github, which means you would need an account.
github is a git hosting site
they have both free and paid options for hosting/registering(I use free)
yes i know for student is github free(not really free=, but else if you get lot of data and transfer is a big risk, costs!!!
@gusty comet github is free
You will need an Atlassian account if I remember well. Last time I used it it was free. Private repos were free there even before github did it
anyone know what this means?
xD
no idea what line is the issue
I was going to ask if you were doing something special
no i mean I dunno
dumb suggestion, if you restart Unity, still there ?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
good suggestion. lemme try
(that version the error is on line 42)
I mean, DOTS is messing hard on me. Last time I tried to open Profiler window, it insisted on adding a Particle System in the hierarchy. Multiple times ๐คทโโ๏ธ
lol
42 is empty but i guess using statements are missing
OH the line numberrs aare fucked cause that's not the whole file
it points a the first line in the function, not the function prototype
so this: if (HasSingleton<ThinClientComponent>())
when when I ifdef that out it points at var localInput
OK
so
// if (!found && localInput != Entity.Null)
// {
// buffer.SetComponent(cmdTarget, new CommandTargetComponent { targetEntity = Entity.Null });
// }```
when I comment this out it works
like it doesn't support adding to the command buffer outside a querry
I'm just going to put it direct on the entity manager after playback instead
yeah probs better luck with the EM
You're doing something someone here was doing also a few days ago
and I don't understand
why adding to a command buffer and playback it immediately ?
to support burst
- IIRC there's already a sync point just before the client sends commands to the server
๐ค ok maybe I dont use it enough yet to get the pattern here
it won't compile if you try to do it without the buffer
you'd ened to add .WithoutBurst on the query for it to compile if you're using entity manager in there
I want the performance so I use the buffer
yes but why use a newly created buffer here and exec it immediately, while you have another commandbuffer waiting for you just before sending the command data (if I'm not mistaken)
you mean like get some other system and create a command buffer on that system?
yeah
wouldn't that be more expensive than just making a local one?
true it can't run in parallel or w/e but I'm not super worried about that right now
I mean when I stumbled upon it, it looked like it was meant for that, lemme double-check what I'm babbling
yeah true, player input is once per client after all
I think when you use the end and start systems you still have to pass in an allocator
(safe mode on Unity startup <3)
i think that's more for when you're doing work in parallel