#archived-dots
1 messages ยท Page 148 of 1
you are setting CameraComponent's Target field right ?
Joker, if I understand you correctly this video is about exactly what you want https://youtu.be/UUCv2nDAKg4
In this episode, we create a new Chaser Entity to showcase how to create relationships between Entities. We can add a component to hold another Entity's ID, then use the ComponentDataFromEntity structure to get access to its Translation. With a few extra tweaks to our existi...
^ that was I was about to link
This is the 3rd or 4th time this link is shared for you Joker ๐
They use ComponentDataFromEntity to make an entity follow anotehr one
I literally linked him that playlist earlier in this channel ๐
to be fair, the previous links were the other videos in that series
But yeah, might wanna watch all of em, Joker.
Its really hard for someone to teach DOTS basic over discord, so you better just watch every single video about DOTS on internet, i literally did
so you cant really 'learn' DOTS in this channel
the problem is finding the ones that are new.
its much better if you watch those videos
only difference is JobComponentSystem to SystemBase from what i can see
you can even still use IJobForEach if you like, they arent removed yet
The problem is that most of the video is just out of date
i REALLY REALLY strongly urge you to watch CodeMonkey's videos
tell me a video that is out of date
i will 'translate' into current way
The game Academy.school videos are vry recent, and should not be out of date
@halcyon plume that video that was linked to you about chasers is not out of date. it's using systembase which is what you're using right now.
If those methods do not work for you, you might be on an older version
unless you are using videos from Entities 0.2 then you should be able to use it
you can still use the code from Entities 0.5
@cursive cosmos
{
private EndSimulationEntityCommandBufferSystem _endSimSystem;
private struct Spawn : IJobFor
{
[ReadOnly] public int cols;
[ReadOnly] public int rows;
[ReadOnly] public Entity prefab;
public EntityCommandBuffer.Concurrent ecb;
public void Execute(int index)
{
var pos = new float2(index % cols, index / cols);
var e = ecb.Instantiate(index, prefab);
ecb.SetComponent(index, e, new Translation()
{
Value = new float3(
pos.x,
noise.cnoise(pos),
pos.y
)
});
}
}
protected override void OnCreate()
{
_endSimSystem = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>();
RequireSingletonForUpdate<PrefabsMapSingleton>();
}
protected override void OnUpdate()
{
if (Input.GetKeyDown(KeyCode.S))
{
var ecb = _endSimSystem.CreateCommandBuffer().ToConcurrent();
Dependency = new Spawn()
{
cols = 20,
rows = 20,
prefab = this.GetSingleton<PrefabsMapSingleton>().prefabsMap[TEST_UI.prefab],
ecb = ecb
}.ScheduleParallel(20 * 20, 5, Dependency);
_endSimSystem.AddJobHandleForProducer(Dependency);
}
}
}```
eisenhorn, add cs or csharp right after the first triple backticks for code highlighting. you also need a linebreak right after, so:
```cs[NO WHITESPACE HERE]
(code)
```
someone is hacking Hod's post ๐
It no longer supports escaped backticks in a code bracket ๐ฆ
I don't care it's just fast written for him to get idea he can copy in IDE if he want ๐
dont work
Fair nuff
joker, if you ware trying to post the error, consider switching to the console tab
Yeah, so you are not allowed to have same type inside ForEach and GetComponent inside that ForEach
ye this better
i need to get target translation but cant cuz i get camera translation in foreach
ForEach((Entity entity, ref Data data)=>{
var selfPosition = GetComponent<Translation>(entity);
var targetPosition = GetComponent<Translation>(data.Target);
})
yeah not ref
cannot use component access method GetComponentDataFromEntity with the same type 'Translation' that is used in lambda expression parameters
it actually doesnt matter afaik
but i dont use any "ref" or "in" for Entity fields, you wont change it anyway
Seems to me like you possibly have something like this:
ForEach((Entity entity, ref Translation translation1) => {
//translation1 already exists
//so it doesn't let you do this:
var translation2 = GetComponent<Translation>(entity);
})
Potential memory aliasing, and safety system prevents you from that
I already told you
TBH that message, while telling me something is wrong and that it doesn't like it doesn't help me
true that
I was trying to point out exactly what it was complaining about
This error pretty straight forward and clean. You can't do that safely as it's potential race condition - you have type with write access and trying to access same type from other entity to which other thread can write.
not working
Joker, start from regular Unity ๐ DOTS to early for you ๐
It's just good advice, don't think is rude
Most of the people here learnt stuff from the hardway, bunch of trials and erros, many tears were shed, you gotta walk that as well ๐
I haven't tutorials and docs, as we developed on DOTS from beginning. And I'm not looking tutorials ๐
Source code is better tutorial
I just have such a feature. I canโt decide something and ask for advice. But before they give me the answer to the question, I myself decide. I donโt know how it goes, and I'm a little ashamed of it. But sorry ill try DOTS
Books about DOD are also good tutorial
too techincal tho ๐
Forgot to do SetComponent)
Thanks guys who help me with a low start in Unity DOTS
you mean gifted to you ? ๐
Wow what a sacc.
Given to you
presenting is whole another level ๐
you mean gifted to you ? ๐
@opaque ledge yeah, English not my native
Forgot completely about 'gift' word
We laughed at this for a long time, because he could mean that we are good and this is a sign of appreciation and at the same time that we are so terrible that we should read this book ๐ But yeah it was first ๐
presenting is whole another level ๐
Joachim sets up a powerpoint in eizen's bedroom.
"yo, lemme tell you why DOD is the shit"

haha
@storm ravine what is you native?
Russian
ะฝั ะฝะฐะบะพะฝะตั ัะพ)
In English
^^
@storm ravine That actually makes a lit of sense.
So you use IJobFor and add the amount of units in the schedule instead of using loops and shit.
One thing I'm curious about though is the prefab, is it possible to fetch the prefab entity in some other way since I kind of have it already in entity form in another class (Used the convertToEntity component)?
Is there any reason a job will take longer to dequeue and execute on Android and iOS than on desktop or WebGL platforms?
when the job itself actually takes less than a frame's worth of time to execute
@storm ravine That actually makes a lit of sense.
So you use IJobFor and add the amount of units in the schedule instead of using loops and shit.One thing I'm curious about though is the prefab, is it possible to fetch the prefab entity in some other way since I kind of have it already in entity form in another class (Used the convertToEntity component)?
@cursive cosmos I'm not using that ๐ Just wrote for you. Where you'll get params - up to you
in other words, does Unity schedule jobs on mobile devices in an idiosyncratic way
SpriteShapeController uses jobs internally to recreate its geometry, and for some reason it just updates itself less frequently on my Android and iOS devices than on other platforms
this is a new error, Sprite Shape v2 series did not exhibit this problem
this has to do with job scheduling
which is the main difference in the code
so I'm wondering if there's just a checkbox or preference I'm supposed to set
mobile devices forces vsync, maybe thats why ? no idea
it's most obvious if I'm using sprite shape controller to draw a line between a point and the user's finger, for example, where you can see the line art is not being updated every frame, even if the points requested to be drawn are
no
it's not going to be that
it's got something to do with job scheduling which is why i'm asking the DOTS people here
have you profile it ?
yes, there is no performance issue with the sprit eshape controller job itself
i'm asking if there's a reason that unity would delay running a job
for no good reason, basically
i'm sure they have a reason
but if there'sd something platform specific regarding when jobs run
well, hope you find your answer
so no one knows how to just
force jobs to run
i get that there's JobHandle.ScheduleBatchedJobs or whatever
it's like the most basic feature of dots right? job scheduling
you're scheduling your job from ecs right?
sure
i have a JobHandle, i would like the code inside the job handle to run you know, after i call a line of code
.Complete is not it
a system always finishes the previous frame's job before scheduling new one so typically should be always every frame
did you set Dependency?
using SystemBase?
nvm i think Dependency isn't necessary anymore, been a while since i last used
only other thing i can think of is maybe you have an ordering issue
nvm i think Dependency isn't necessary anymore, been a while since i last used
@hollow sorrel Dependency always necessary if you scheduling, codegen track it for you in SystemBase ForEach, but for regular jobs in system you should track them by yourself.
yea i mean i'm assuming he's using ForEach
or maybe i misunderstood
@winter onyx if you're scheduling your own job you gotta do Dependency = muhjobhandle in the system because otherwise the system won't keep track of it
i.e. it won't force complete it next frame because it doesn't know that it's running
could complete 10 frames later if it's slow
it sounds like platform issue tho, not really code
i didn't write this, unity did
for what it's worth
we're talking about SpriteShapeController
there's nothing wrong with the way they schedule jobs on sprite shape controller
the issue appears to be, pretty much unambiguously, that on mobile devices jobs are just not run as frequently as on desktop devices
there are two suspicious jobs-related calls on SpriteShapeController
internal void BakeMeshForced()
{
if (spriteShapeRenderer != null)
{
var hasSplineChanged = HasSplineDataChanged();
if (!spriteShapeRenderer.isVisible && hasSplineChanged)
{
BakeMesh();
Rendering.CommandBuffer rc = new Rendering.CommandBuffer();
rc.GetTemporaryRT(0, 256, 256, 0);
rc.SetRenderTarget(0);
rc.DrawRenderer(spriteShapeRenderer, spriteShapeRenderer.sharedMaterial);
rc.ReleaseTemporaryRT(0);
Graphics.ExecuteCommandBuffer(rc);
}
}
}
and
var spriteShapeJob = new SpriteShapeGenerator() { m_Bounds = bounds, m_PosArray = posArray, m_Uv0Array = uv0Array, m_TanArray = tanArray, m_GeomArray = geomArray, m_IndexArray = indexArray, m_ColliderPoints = m_ColliderData };
spriteShapeJob.Prepare(this, m_ActiveShapeParameters, maxArrayCount, shapePoints, shapeMetaData, m_AngleRangeInfoArray, m_EdgeSpriteArray, m_CornerSpriteArray);
jobHandle = spriteShapeJob.Schedule();
spriteShapeRenderer.Prepare(jobHandle, m_ActiveShapeParameters, m_SpriteArray);
JobHandle.ScheduleBatchedJobs();
there are no dependencies or anything
oh it's monobehaviour stuff, i misunderstood mybad
i sort of just want to know, is there a method
anywhere, in the whole api
that just, forces the jobs to run now?
i get that the answer might be, no
i mean maybe there's something extremely buggy with android, and there's a job that runs instantly on the desktop that takes seconds on the android device
JobHandle.ScheduleBatchedJobs(); is forces the jobs to run
that exists for sure
the thing is, we sort of know that it doesn't do that
it just wakes the threads and says for them to check
it doesn't actually do it
so the answer is no
you can't do it
that's okay with me, i just wanted to make sure
It do it
Reason for delay also described by Unity
The job system intentionally delays job execution until you call ScheduleBatchedJobs manually because the cost of actually waking up worker threads can be expensive. Thus a good default is to delay the actual kick until a few jobs have been scheduled. Generally if you are scheduling a bunch of jobs in a loop, wait with kicking the jobs until the end of the loop. If you do significant amounts of work on the main thread between scheduling jobs, then it can make sense to ScheduleBatchedJobs between each job.
yeah
i mean who knows, we don't have the unity source, at the end of the day
we don't know when it actually does it
maybe it's running the job on time on all devices, but this "execute command buffer" call is delayed on android
that's my only other hypothesis
that call is just obviously main-thread-synchronous
You should understand that - starting job execution not equal "all done"
For example you schedule first job and call it, and it start running it
and depends on many things (cpu, code complexity etc.) it will finish after 10 or 100 ticks (abstract)
If you not force it to complete right now
Jobs have a Run function that you can use in place of Schedule to immediately execute the job on the main thread. You can use this for debugging purposes.
this is what i think i was looking for
the job itself
is instantaneous
it finishes in microseconds
the spriteshape's job that it is scheduling
it doesn't have a performance issue there
granted, i do not know how ot profile the specific job
there is no result for "how to profile unity job"
shouldn't .complete do the same thing
ProfileMarker
Complete does same thing for Parallel scheduled jobs
is asking, gently, for unity to schedule things
it doesn't actually force them to occur
job.Run forces it to occur
which is really an issue with the API
it's not anyone's fault
Uffff.. it DOES that's all.
.complete is synchronous afaik
code after it doesn't run until the code in the job is completed
it's not a suggestion
But complete on mainthreaded code will be overhead
that's true
because of schedule
but i'm not interested in just watching the screen freeze
for 4 seconds
do you see what i mean?
Run will do the same
we don't know if it freezes for 3.999s of sleeping, followed by 0.001s of actual job execution
it will stall main thread
no, what i'm saying is it won't
It DOES
there's only 0.001s of actual job execution
I told you difference
clearly on android it's sleeping the thread
do you see?
i don' tknow it doesn't matter, don't worry about it
and i don't know if unity devs hang out in this chat
i mean they'll understand exactly what the issue is
.Complete is just waiting for the task to complete, and gently asks the scheduler to "run it now", it does not force the scheduler to actually do it
there's a degenerative situation, which i can reproduce on android, where the scheduler is delaying the actual execution of the task
Main difference with Run is it not Job anymore technically (as you expect it) it become "method" on mainthread (and if it uses Burst it become bursted method)
when i say actually do it
i mean you just don't know how this works
which is fine
you could just say i don't know
it was helpful
.Completeis just waiting for the task to complete, and gently asks the scheduler to "run it now", it does not force the scheduler to actually do it
@winter onyx wrong
but the answer is using Run
Absolutely wrong
Complete FORCES all jobs in JH chain DO all work using every thing they can (main thread and worker threads if it parallel)
It become similar as calling code synchronous on main thread
same as Run
Difference in performance here only Schedule
Complete just has the main thread wait until the jobs are finished, and gently asks the scheduler to start jobs now
Not at all
the furthest i can see that Complete calls is
[NativeMethod(IsFreeFunction = true)]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void ScheduleBatchedJobsAndComplete(ref JobHandle job);
that's what it does
and i bet, i would be a lot of money, that if we looked at the unity engine source code
for what that concretely does
an answer from eiz on this might as well be same as getting an answer from a unity dev
dunno why you're dismissing it with "i don't know so neither do you"
it will look like
ask the scheduler to run all the jobs, possibly prioritizing the job i was passed
wait until the job i was passed is finished
the scheduler's internal code looks like
i have a bunch of threads with queues, they will sleep until they have work to do
tells those threads what to do using queues
and what i'm trying to say is
The JobSystem automatically prioritizes the job and any of its dependencies to run first in the queue, then attempts to execute the job itself on the thread which calls the Complete function.
that unity wrote something wrong in how the android scheduler works
yes
attempts being the operative word here
it doesn't execute the job
I personally discussed scheduling with DOTS team, and Complete behaviour (Complete itself) equal to Run. Overhead before complete is Schedule.
It does.
yes we're talking about unity code
i don't even have control about when it calls its own job
it's just a bug in a package unity authored
and unfortunately the only way to get the source nowadays is in the PackageCache directory
i would loev to just
reference you the code
i mean i'm not braindead ๐
i mean clearly there's a regression
i just have diagnosed it already
i think .run is what i will need
i'm about to find out
I think I need to abandon the idea of converting game objects to entities, it's just causing me more headache than my codemade mesh cube x)
@cursive cosmos What seems to be problem
Nah, just having a hard time finding out how I send objects into systems that are not components, but complete entities.
Might have to do it the singleton way
my feeling is, just from looking at how the sprite shape controller is written, there is a bug in the job scheduler
in the most recent unity version
or that the meaning of the API has changed, between point versions
and you know, i just can't do unity's job for it
building an android application on combinations of sprite shape packages and unity editor versions
i would rathe rjust fix the bug
they won't do that either, they just won't
it's like the targeting arrow in my game right? and all of a sudden it just starts working crappily on mobile devices
i will credit you that .BakeMesh().Complete() fixed the issue ๐
how to actually
IJobExtensions.Runa job handle yet...
@winter onyx you can't as JobHandle is result of scheduling, which not exists if you Run on main thread.
For JobHandle you only have Complete
i mean, i'm not supposed to do that
I told about your it's most obvious if I'm using sprite shape controller to draw a line between a point and the user's finger, for example, where you can see the line art is not being updated every frame, even if the points requested to be drawn are setup ๐ You getting sprite shape and moving spline points and call BakeMesh right?
you're not supposed to call bakemesh
the sprite shape knows when it has changed
the issue was the scheduler
i mean, clearly i would like to use a worker thread to render the mesh (the profiler puts it at 4ms, which still seems extremely high to me)
for two points
on android, the job scheduler just sleeps threads more
it's going to be that simple
i'm sure some unity engineer had a good reason for doing that
this was a regression, no code changed other than spriteshape and the unity editor
SpriteShapeGenerator itself is IJob which only use 1 thread and as you call complete on main thread it will use only main thread ๐
to be clear
listen i mean, did i write the sprite shape generator?
no
am i using it wrong? no
am i now doing something i'm not supposed to be doing? yes
does it fix my issue? yes
am i braindead? no
that's sort of what i wanted, i did want to do something that i wasn't doing before, that i know i'm not supposed to be doing
because i can't wait a week for Unity QA to tell me to install the latest version of the editor and try again
yeah i think that's the moral of the story
๐
If you don't wan't to wait ๐
i mean if there was a way to freeze the package version
there isn't
it just upgrades for you
yeah, this sort of confirms people's beliefs
from library
job scheduler having a bug is completely different from spriteshape generator having a bug tho
and it become local package
the popular opinion, years on, is that this stuff is garbage
the job scheduler definitely has a bug
you could be right that job scheduler has a bug but it's a big claim because a lot of people are using it including on android and haven't reported same
you could be first to have these specific circumstances that trigger it but i'd be more inclined to think spriteshapegenerator or use thereof is the issue
i mean
no dude
job scheduler has existed even before ecs
there are maybe a handful of people using it on mobile devices
at any scale
and also have the ability to understand what's going on
imo you should tone it down a little, you should relax, if you think its a bug go report it
i think the scheduler was actualyl correct until very very recently
this is a new bug
yeah don't get me wrong you guys don't work for unity
this is for them not for you
it's infuriating to say the least
For them use bug reporter, then it will be in their field of view ๐
hope i wont encounter any problem when i build my game for Android ๐
Anyone who can punt me in the right direction regarding sending variables from other classes into a SystemBase class?
Or is that maybe nothing I should be doing in the first place? ^^;
SharedStatics perhaps, you can also make a singleton MB
the bug reporter doesn't even upload projects correctly on macos
and i have a fiber connection
to put in perspective
like obviously i care
i want it to be good
Anyone who can punt me in the right direction regarding sending variables from other classes into a SystemBase class?
Or is that maybe nothing I should be doing in the first place? ^^;
@cursive cosmos Depends on many thing. Mutable\immutable data?
submit a bug about that 
i've reported a bug about spriteshape before, funny enough, related to the jobs
and it got fixed
yeah exactly ๐
but it took 20 days
it was a lot of back and forth about update to the latest editor version
which by the time i did that, well, there was yet another version
@storm ravine It's a gameobject that has been converted to an entity and will serve as the type of object I will spawn. So basically just an Entity with components
when the QA person actually got around to check
you know?
and their script just says, make sure they're using the latest editor version, in a product that constantly has regressions
in comparison, the unreal source code is just open, i suppose you can go and fix it, i mean it's equally riddled with bugs and there's just no support whatsoever, you need to poach Epic Games employees
so it's not like there's a 100% better alternative
Anyone who can punt me in the right direction regarding sending variables from other classes into a SystemBase class?
Or is that maybe nothing I should be doing in the first place? ^^;
@cursive cosmos you can do SharedStatic, you can have entity which will hold data itself (class\struct ICD)
Cool, will check it out.
For example you'll have singleton entity which hold your prefab entity and use that singleton entity in systems
oh, the prefab is fully converted to an entity, so I don't think it's necessary to make a container for it, no?
listen big thanks though you did fix it
.Complete worked
i won't argue with results ๐
lemme check
as sprite generator job wraps Burst attribute to preproc define
I'm not using that package then don't know if it has dedicated checkbox for burst in sprite shape generator
Which will enable define
installing the Jobs package imports Newtonsoft Json ๐ฟ
Yep newtonsoft dependencies which appears\disappears between versions annoying
Why Jobs package?
You don't need Jobs package afaik
as it uses UnityEngine jobs
Jobs package only contains couple of additional Job types
no it does not say burst
but right now i don't see the job it schedules at all
probably because i'm using complete now?
i mean it's not running on any of the workers
i see physx jobs
which are also not burst
yep
Remove complete
for tests
OR
open burst inspector
Is it greyed out for you?
Burst package not require newtonsoft, It only install math lib itself
is sharedStatic basically a global variable in a way?
yup something like that
Why Jobs package?
You don't need Jobs package afaik
๐
After installing burst restart editor
After installing restart ๐ It's required ๐
gochtya
As it will throw you errors after installing which will disappear after restart
is sharedStatic basically a global variable in a way?
@cursive cosmos it like regular C# static fields with some restrictions for Burst
@cursive cosmos if you have problem regarding instantiating entity. Maybe the ECS Samples from Unity is worth to look at ๐
okay i'm oing to try running without .Complete and regular (not development) build on android
see how it goes
it looks like it burst compiled
Just check in editor first
as with burst it now can be veeeeeery tiny and hard to find on timeline ๐
Nah, instantiating an entity was not confusing, it was how the system works and How I can transfer over data from normal mono classes to systemBase classes :)
But does this mean that if I try to do this with sharedstatics, is there a risk that the system job will run before the static is set?
this part specifically It is recommended to always initialize the shared static field in C# from a static constructor before accessing it from HPC#. Not initializing the data before accessing it can lead to an undefined initialization state.
yep, just read that ^^;
So then is the question, does system jobs start running before a mono OnStart method?
Probably not.
lol
yes you're right
it's very tiny
it was 0.008ms
SpriteShapeGenerator (Burst)
Yes now it burst compiled
in Worker 14 of 32
Without complete
With complete it will be similar
maybe a bit longer like 0.01ms
Which will be fine now? In comparison with 4ms?
yeah without complete
i am compiling for the device now
once build without profiler one with
development build unchecked
Use release build
yeah that's what i mean
as dev build (same as editor) has safety checks overhead
it will x5-10 faster than now
I meant to ask Eizen, how is blobassets represented in chunks exactly ? when we build a blob and put into a component every component will 'reference' to a single place which holds the value, but where does that value live exactly ?
Yes if you unchecked it will be similar to build by performance (but not completely, release build will always be faster)
i'm going to go make a coffee while this compiles
Blobs is preallocated 200mb per scene.
this has been very helpful thank you
When you use blobs you store just ptr to memory address
this is why blobs use many ref structures
per scene ? you mean per world ?
so how the process works then, will it be a cache miss just to retrieve that value ? or Unity will prefatch that value first and then run process ForEach ?
Eizen be like "how do i explain this in a way that a scrub can understand"
i am not really into details, but was just wondering, since whole idea of ECS is to be able to have all the data you need in a cache line or smth right ?
No I just trying to find conversation in Unity slack or on forum, where I described that couple of times long time ago
ah okay fair
Well can't find that, will explain it shortly
Or send you to source code of Blob.cs ๐
As it's not so short to explain
eh dw about it then ๐
like i said, i am not really into details, but was just wondering since it would be a cache line miss or smth
It mostly unmanaged memory
they store data in blobs as batches
Look at BlobAssetBatch
@opaque ledge accessing stuff from a blob is likely to be in cache, because you likely are accessing the same blob a lot from a query
dont worry about every single cache miss lol
yeah vblanco tl;dr valid ๐
unity does N cache misses where N is number of comps in your query per-chunk
I'm just empty at the end of a day ๐
lol
okay without .Complete the bug comes back
with burst turned on
so i sort of just need .Complete
Yes
so i will redo it now with .complete
hopefully it just won't be 4ms
to draw a line
my feeling is burst will help
As it will give you immediate result for current frame and renderer will handle that changes and will render exact state in current frame and not from previous frame, but now with burst it will be very small
yeah
alright i'm going to make myself another coffee
it works much better
you did it, you're today's hero
no
hero of the year
lol
Oh god, finally made it to work
Now let's see how big I can make it until I break my instance of unity.
Thanks for the help guys, next up I need to figure out the whole extra axis and the cave system and such like that...
Is there any tutorial/samples for DSPgraph & co ?
I want to start adding sound to my ECS game, but I can't find much about it (nor even where to get the package) ?
DSPGraph is pretty low level audio, you can still add class IComponentData on your entities and make systems that queries for it and run audio that you put into that component data, however you have to run the system with .WithoutBurst().Run() so on main thread without burst
some people have posted some snippets of stuff in the forum thread for it, could also look at the tests folder for the package.
Looking for any literature around proc gen for terrains in DOTS. I haven't touched DOTS in over a year hoping for it to have matured a lot and most of it's left my brain already, breaking terrain into components I can see a few that stand out (as an example)
- TerrainData (perlin noise values, erosion math, other features)
- TerrainMesh (building verts and tris)
- TerrainTexture (building a texture based on things like TerrainData's height and features)
Is it preferable to have a single System looping over and running each of those jobs, or 3 systems running each in sequence? These systems won't actually do a whole lot when the game is running besides cull / instantiate new terrain chunks...
Does this design seem reasonable? Am I way off?
Is DOTS even perhaps overkill for this kind of thing? ๐
I mean, from what I have seen so far, I think most 3D games that are non-instanced (like open world) for sure should use DOTS. The difference is massive in performance. I also am growing very fond of how entities work and now when I got the "convert gameobject to entity" pattern down, it makes it pretty easy to make different kinda voxels.
I'm still nowhere near in making the terrain like Trove or Cube World. But I want to get there and I am also looking for reading material for voxel worlds. ๐
I did read a thread https://forum.unity.com/threads/dots-for-floating-origin.807117/ about Joachim mentioning floating origin being very difficult to implement right now - that was 5 months ago. Anyone know if there was any progress on this front?
yeah sorry, can't help you there, don't even know what that means.
Floating origin is when the world is "reset" to 0,0 when you move too far away from the "origin" point. An issue happens with floating point precision when you get into large distances (e.g. 100,000 units away) because a float can only contain a fixed length. Floating origin is the process of moving the entire game world back to 0,0 when you get too far to stop those issues from happening
(In Unreal it's called World Origin Rebasing)
I mean, I got linked this, and it looks pretty fluid
https://forum.unity.com/threads/a-voxel-game-prototype-in-unity-ecs.852610/
But why would you need it to reset the origin?
because the larger a float gets, the less precision it can have
a really simplified example:
let's say a float can only contain 8 numbers, you can have
x: 1.0000000 - which means floats can have 7 decimals worth of precision, but you can only have 8 numbers, so when you get to
X: 1000000.0 - it can only have 1 point of precision
as a result, things like animations and movement become "jittery"
And by saying float you mean the coordinates, or?
yeah, unity uses floats (the primitive type) for it's coordinate system
I think Unity uses 32bit floats
huh, interesting, never thought of that problem, I mean, then you need a system that remembers the location for each entity...It would be pretty bad if your home coordinates reset...
Yeah in DOTS I'm not sure the best way to do it, in regular Unity* though - you can pretty much just move the whole world back (e.g. http://wiki.unity3d.com/index.php/Floating_Origin)
interesting, would need to research this though.
I mean, I have barely understood how I should limit rendering.
So this is far off for me xD
I think if you're making any large-scale world (not just procedural), you have to consider floating origin - so it's something to remember
for sure.
@turbid sundial should be easy in DOTS
could just apply an offset to every Translation component same as you would normally, except ecs already allows you to easily fetch every Translation in the world
also with DOTS you actually have the ability to go with double precision if you want that, unlike normal unity
would prob go for origin shifting before considering that but still it's an option
Yeah I think there are some basic ways to approach it, but there are a lot of considerations
for example if you're not pure ECS, you'll have to match your shifting in both "worlds" (systems?)
and depending on how many entities you have, you probably want to put them all on the main thread so they all get shifted at the same time (and the world doesn't "stream" back)
not hard, but just some things to consider - I was mainly looking at Joachim's comment that they'd add new APIs to make floating origin easier.. assuming that hasn't progressed?
yeah it's not built in already, dunno bout progress
what do you mean with world doesn't stream back?
oh because ecs and gameobject world
yeah, you'd want to make sure the shift all happens at the same time
one way to do that would be to use the separate worlds in ECS
ie. process the shift in world 2 in the background
yea true it's a bit tricky if you're managing positions in both gameobject world and ecs world
if i were doing that i'd prob have an entity copy of every gameobject and make ecs world in charge of updating positions and sync it back to the gameobjects at end
so it'd be like
a monobehaviour wants to move -> add ecs moverequest component in ecs world or something similar -> when ecs runs, add moverequest to position -> end of ecs update, sync positions back to gameobject transforms
or something like that
dunno if there's pitfalls i'm missing here
so then ecs world can change translations and origin shift at will because the gameobject world is never directly manipulating positions
if I want to spawn stuff with ecb.
am I right to get the beginsimulationcommandbuffersystem?
or get get the endsimulation one?
You can spawn directly in manager.
??? you can't use entity manager in a job though
You can use the command buffer, read the link he sent you
The first paragraph
The EntityCommandBuffer (ECB) class solves two important problems:
When you're in a job, you can't access the EntityManager.
I read the link. I'm using ecb.
I'm asking which ecb system should I use in spawning entities?
is it right that i use BeginSimulationEntityCommandBufferSystem instead of EndSimulationEntityCommandBufferSystem ?
Well, what are your needs?
If you want the entity to do anything this frame, spawn it in begin, otherwise it might be that you want end
??? you can't use entity manager in a job though
@deft stump i mean not in job. If you need to do it in job just ECB
@tawdry tree i have questions about new input system. I make android game. How i can send walues from virtual joystic in input system?
I am not familiar with the new input system, so can't help you there.
The documentation is found here, though:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/index.html
I suggest you ask in #๐ปโcode-beginner if anyone know how to simulate actions in the new input system, as the input system isn't part of DOTS
ty
now i have problem with dots
Letโs check out what Unity is working on for the new Input System!
โบ Go to https://expressvpn.com/brackeys to take back your Internet
privacy TODAY and find out how you can get 3 months free.
โ Get the new input system here: https://bit.ly/2SiXsgS
๐Check out our merch! https...
i need instance of input system and send it to my ECS InputSystem
How i can do it?
lul
How i use new input system is.. OnCreate method i create a instance of my input system script and enable necessary controllers and do bindings etc, then in OnUpdate method i read these input controllers and if controller is being pressed i schedule the job to move my player, if not i dont
have you ever use new input system before ?
no. But i undestand how to use it in monoBehavior. Just subscribe on events and do actions like move etc
but dont undastand how to use in ECS
I could use some kind of buffer and write to it on an event
I just donโt think that calling Entities ForEach during the event will be correct
think of Systems like singleton Monobehaviours, OnCreate is Start method of a Monobehaviour
yeah thats it basically
OnUpdate runs every frame, check your controller's values in OnUpdate
if a button is pressed then schedule a job that moves your player
if not, dont schedule it
like this?
but unity said this
I think the best decision would be to make Singeltone
thats not how you read a value from a controller
check their manual or watch some tutorials on how to do it
But not sure if it will give access there
you read the value of a controller OUTSIDE of ForEach
ye
i forgot about that
ty
and yes it works)
cuz
this type is Vector2d
There is a question about input from Android
The documentation says nothing about it
is there a way to know when a ecb finish creating entities cause it is taking lot of time to show in the entity debugger
like a callback or for profiling?
have you checked profiler hiearchy mode ? there should be a marker for it afaik
lemme share a system I made for the new input system.
sadly it's not burstable code.
Anyone could point out why this wouldn't work? (DOTS Physics)
https://pastebin.com/at9GK37P
This is in a ITriggerEventsJob, trying to find the point of contact between a projectile and a object (that might have a shield(trigger), hence have two colliders on same entity).
The code enters only the raycast when the projectile is hitting the base ground. I've added some padding to the raycast start end to see if there were some error.
wow i done this
if someone need
just place script On-Screen and it will work
dont forget to set path
Continue on my problem, not really sure what is going wrong here. I've changed to now cast the colliders against each other, and still no hit .. (full job in this one with some debug trash)
https://pastebin.com/wFNKLiYn
โ
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=fkJ-7pqnRGo
Let's learn 2 ways we can handle Events in Unity DOTS! The final class is included in the Project Files.
Unity DOTS / ECS Tutorials
https://www.youtube.com/playlist?list=PLzDRvYVwl53s...
11:00
is entities 1.0 will be released with unity 2020.1?
In 2020.1 cycle according to roadmap.
it's already in beta so... maybe a few more months
wait what... so currently the unity physics package isn't compatible with ecs 0.11
the curse of being on the bleeding edge 
is it not ? ๐
Does it make sense to use DOTS for simple games?
imo, yes.
yea i think so, simple games can end up being pretty complex, once you fill out all the finishing touches.
btw, how do I check if an entity is out of view from the camera?
get camra translation and object translation. calc distanse. compare
i have a script that do that @deft stump
actually i found on web, i should share that
ara. send!
give me a few
i changed some code for my use case
is entities 1.0 will be released with unity 2020.1?
@plain cloak doesn't mean they release it exactly same time, or even it'll happen for 2020.1
Is possible to have 1 object in perspective projection and 2nd in orthographic projection for the same Camera?
these roadmap targets more often shift than stick
we're lucky if we even get entities 1.0 this year IMO
@dull copper i see
that being said, 1.0 doesn't really mean much will change
rest of the DOTS ecosystem will not be production ready in years
so having core of it "released" doesn't make the full package feasible in production
Entities package itself is pretty solid already
what do you mean by "not production ready"
quite literally that
oh god no
only entities, burst and job system are somewhat solid now
rest is still experimental
you could always go hybrid in places where it lacks, no?
hybrid renderer is flaky atm, dots physics doesn't evolve much and feels like is on some limbo, dots netcode got pushed yet another year (so they suggest it to be production ready only at some point next year - and will probably shift again), only unity knows how to use dots animation...
it's not realistic to expect full dots stack to be production ready this year at all, Unity officially targets 2022
and you gotta put year or two extra to that estimate
true
in my current project, i use dots for all the calculation and state/gameplay stuff and use regular gameobjects to render, animate etc.
its a bit hacky but it works for now, was just wondering when i can go fully dots
but i guess that won't be here for a while
that's the safest setup atm
you cant go full dots right now
but if you know how to setup hybrid components then you can do everything that you can do with Monobehaviours
ui/audio/animation/Addressables etc.
by hybrid components i mean basically adding class IComponentData or AddComponentObject, and write systems that that queries for those
i haven't used HybridComponents, is there any documentation on those or is it in development stage. I took a break for couple months so haven't caught up to all the updates yet
one of the unity staff said HybridComponents were meant for internal usage not for developers, but i guess it could be useable, idk, never tried
there was an example of it in ECSSampels
cool, thanks
I wouldn't invest heavily on that hybridcomponent atm
there's no guarantees it'll even stay around
workflows with experimental things are always subject to change
Well, I could insert my 2 cents about the use in production and what is possible / impossible, pure DOTS / hybrid, you know... but I will probably keep silent ๐ 
@storm ravine i have read your thread on forums, your game looks great ๐ great job. And to use DOTS at the time you started.. It was one of the things that lead me to use dots aswell ๐
I'm afraid to imagine how many people started using DOTS after the example of our game and how many people now curse me after everything turned out to be not easy for them ๐
true lol ๐
oooh, what kinda game are you making @storm ravine ?
Go to DOTS forum you'll see my pinned thread
DOTS has it's own forum O.o
it has
Yes
https://forum.unity.com/threads/unity-ecs-and-job-system-in-production.561229/ and you'll see progress through DOTS evolution. We started refactor everything to DOTS right at GDC 2018 (And we on Unity DOTS page ๐ https://unity.com/dots#studios-using-dots) And from videos on forum you can find playlist with different things in our game
A city builder must be a really good way to use DOTS I can imagine...
Dang, Diplomacy is Not an Option gives me a lot of zombie defense vibes...what is that game called again...
they are billions ?
yes!
๐
Fun take on it though, I prefer fighting these guys
Yes, TAB, Stronghold, Settlers - you'll see some similarities with them.
TAB's can get really messy towards the end though, how big can the town grow in Diplomacy?
Well in sandbox mode you'll be limited only by map size
oof
"and the map is procedurally generated".
I am certain it's not, but that would be a fun follow-up
gusy how to MeshFilter as struct?
You mean add a mesh to a entity?
"and the map is procedurally generated".
I am certain it's not, but that would be a fun follow-up
@cursive cosmos ?
as in procedural + "endless" ^^;
Really annoying to type with a blister on my index finger btw, assembled too many things yesterday.
Well map itself procedural, but not infinite, you have static 1000x1000 area (just now, in game campaign it will be variable, in sandbox you can change size from predefined sizes like 400x400 800x800 1000x1000 etc)
That's cool though, looking forward to having some gameplay in my map....just need to manage to even make a map first..
I'm more of a 2D person, going into 3D and making DOTS on top of that might have been a big first step.
Anyone know any good resources for the theory behind terrain building with voxels? Gonna try searching for some nice reading material today.
preferably cube spawning, like trove
I'm bracing myself for a lot of math...
Marching Cube for generation process itself, about world pattern - multi-octave perlin noise
Alright...Some good search words at least, need to write these down, also saw something about erosion noise or something, don't know what that means yet
erosion math? well something along those lines
erosion noise is a step after initial generation and for minecraft style, it not so suitable
Oh, what does it actually cause?
It sounded like it makes the caves and such because of the whole erosion part, but that might also mean just holes I guess..
Oh, so it's more for flat meshes?
So that is not usable for voxel blocks?
Erosion is about water, wind, etc affecting land through time
why this is class? and where is my struct
Oh, okay.
In this coding adventure I attempt to implement a simulation of hydraulic erosion to make a procedural terrain look more natural.
If you're enjoying these videos and would like to support me in creating more of them, I have a patreon page here: https://www.patreon.com/Sebasti...
how to simulate water waves in ecs? i have an WaterComponent and WaterSimulationSystem. But unity dont allow to change mesh
@halcyon plume use shaders, do not change the mesh on each frame
@zinc plinth ehhh. Soo i go to teach shaders
๐ฝ Click for Timestamps & Info
This is a several hours long improvised live introductory course to shader coding in Unity! It has been slightly edited in the beginning to remove useless info and me messing around with the mic. The rest is the stream in its fullest!
Timestamp...
wow ty
np, love her channel
renderbounds components take data from getComponent<render>().bounds or from mesh; i mean cause there is a component call worldrenderbounds
thanks
what it whants?
it wants love and attention โค๏ธ
lol hahaha , sorry about laughing
you'll have more chance of getting an answer in #archived-shaders @halcyon plume
could u take a look at my question above please ๐
i dont know about shaders sorry man
oh i forgot about other chanels)
"renderbounds components take data from getComponent<render>().bounds or from mesh; i mean cause there is a component call worldrenderbounds" What is the question exactly ?
i need the a component that store meshrenderer bounds , i tried to use worldrenderbounds but the AABB it generates it always axis-align to world so i thought about using localtoworld component and mesh bound on local so i read there is a component called RenderBounds but i dont know if the data i should give to generate it must be take from getComponent<render>().bounds or mesh
i think i have to improve my writing
the thing is that i need to get an local axis align AABB to be saved on components
i really apreciate if u could give me some advise with that ๐
hmm, never tried that so i dont know ๐ฆ
but there must be a way to convert world AABB to local AABB ?
yeah probably but this is not exactly the matter i have, it is more that i doubt if i have to use the bounds of the render or mesh cause one comes on world and the other on local
tbh, sounds like you should use mesh bounds, because render bounds depend on camera right ? but yeah i dont know really, sorry
in API you can find what is the difference afaik
For RenderBounds you should use mesh.bounds
i just solve it , finally i have to use mesh one; thanks for the help anyway , i hope i could help u in the future cause u are always helping me i really want to know enought for helping
yeah man
All other bounds will be generated automatically from this and required matrices, as World and Chunks bounds
i tried the two ways and checking data i get the conclusion
thanks for all the helping u give here , its amazing
one more thing, when i use localtoworld.forward and that it just return the vector on global . I know it is a stupid question
I don't see a question in your sentence 
protected override void OnUpdate()
{
Entities
.WithoutBurst()
.ForEach((in PlayerTag player, in BulletTag bullet) =>
{
TriggerEvent trigger = new TriggerEvent();
Entity ea = trigger.Entities.EntityA;
Entity eb = trigger.Entities.EntityB;
Debug.Log("entity A: " + ea.ToString() + " entity B: " + eb.ToString());
}).Run();
}
am I doing this right?
context: I'm trying to make triggers work with dots physics. for now I just want a log to pop up.
okay whuuuuut. this system isnt being run... (debugging)

You need special job structs for trigger and collision events
You need special job structs for trigger and collision events
great. so I can't magically do it in entities.foreach
public struct ShotTriggerJob : ITriggerEventsJob
{
public void Execute(TriggerEvent triggerEvent){
//Confirm triggerEvent entities is the entities you want
//if its is then do logic, otherwise return
}
}
protected override void OnUpdate(){
var simulation = stepPhysicsWorld.Simulation;
var physicsWorld = buildPhysicsWorld.PhysicsWorld;
Dependency = new ShotTriggerJob{}.Schedule(simulation, ref physicsWorld, Dependency);
}
oh thanks, curly
float4x4 is basically a table of float4's (4 float4's)
float4 is x, y, z and w
so how can apply a matrix to a vector ?
math.mul()
Hello dear dots user!
do you have a clue about how to dispose a NativeList that must be used in a job?
it's annoying me so much
list.Dispose(jobHandle)
https://i.imgur.com/63US2Wu.gif
So this is strange to me. I generated a mesh in dots (RenderMesh, RenderBounds, Translation, LocalToWorld) , simple 4 verts 2 tris, put it in the world. It seems to have some weird culling in the scene (and game) views if you get too close, or look at it directly. You might be thinking this is near-plane camera clipping, but I can put a standard cube gameobject in the same spot that won't clip the same way. Any thoughts?
HybridRenderer culling maybe? ๐ฎ
Ah, apparently it's known issues in the giant hybrid renderer v2 thread
I've noticed my cubes sometimes do that.
I've got a fun problem, so I followed a tutorial for making a cupe with 3D perlin noise, and the big difference is that I spawn my cubes using DOTS with thanks to @storm ravine .
The fun thing about this is that my cube literally looks like it has more of a pixelated chaos going on than a wave shaped cave pattern which his has with the same underlying code.
So I'm wondering, does perlin get affected by the multithreaded code while spawning items causing this pattern or what could be the cause? Can post the System in a sec.
How do you get the perlin noise?
@turbid sundial it looks like your render bounds are incorrect
Ah, apparently it's known issues in the giant hybrid renderer v2 thread
@turbid sundial There is no issue with culling. Just adding bounds do nothing (it will be 1 point culling, you can find thread on forum where I describe and show it) You should set bounds for render bounds from your mesh. You set it?
which his has with the same underlying code.
@cursive cosmos which one? I'm not using that code, it was written in a couple of minutes for you (if you about parallel job) ๐
no, but thanks to that code snippet you splurged out of you, I grasped what I did wrong :p
What do I even use to share code snippets nowadays?
```
```
It's a bit long though
If it's longer than ~20 to 40 lines, pastebin or something similar is better
about noise I think I know your problem
you just put float2 pos as argument for cnoise I guess, add some property to multiply that float2
Mathf, huh
noise.cnoise use this instead
Oh, is that a thing..
float2 sample = samplePoint * frequency + octaveOffsets[o]; float perlinValue = math.mad(noise.cnoise(sample), 0.5, 0.5);
something like this
In DOTS code you generally wanna use the newer math library rather than the old stuff
I have no clue what's old and new, just smashing my keyboard over here
That said, that cube of yours looks pretty much like what I expect from perlin noise
The newer library you get from a package, as opposed to Unity.Mathematic.Mathf
So wait, should I replace my perlin 3d with that perlin value completely basically?
Perlin noise will be the same, not matter noise lib or Mathf
Algoritm the same
Only difference is implementation
As noise lib implemented with math and SIMD friendly
This is only difference
Or in short: it can run faster
I like the fact that there is something called math.mad though.
DOTS math lib implemented in consistency with CG math lib
As an aside, with perlin noise you should mess with the scale if you want bigger caves, and thresholds to change amount of space/solid
As opposed to that pixelated mess
float2 sample = samplePoint * frequency + octaveOffsets[o];
float perlinValue = math.mad(noise.cnoise(sample), 0.5, 0.5);
While using this though, x/y/z wont affect the noise at all, so how would I go about sending that into the job for positioning?
is that instead of the noiseScale?
the samplepoint is the x,y,z
perlin noise sample point is float2
For 3D perlin you should write your own implementation, for example just use keijiro implementation (and replace parts to math. it will be easy) https://github.com/keijiro/PerlinNoise/blob/master/Assets/Perlin.cs
Unity.Mathematics.noise.pnoise sounds like perlin noise?
so the noise for vector 3?
Browsing through the docs for the math package
Declaration: public static float pnoise(float3 P, float3 rep)
There's a 3d overload
it's just different namespace yes
http://prntscr.com/stx0ob
This looks mad, trying it
public static float cnoise(float3 P)
What the actual bleep i that
yeah 3D version in different file
Oh, manual noise implementation?
http://prntscr.com/stx0ob
This looks mad, trying it
@cursive cosmos well built in implementation also not so easy in comparison ๐
using Unity.Mathematics;
const float3 _rep = new float3(0,0,0); //no idea what rep does, so identity
private static float Perlin3D(float3 pos) =>
math.mad(noise.pnoise(pos, rep), 0.5, 0.5);
This should be the barebones use of 3d perlin noise, in the form of a helper
Then you just chuck in the pos and get a noise-sample
pnoise is not "classic" perlin noise
cnoise is classic perlin noise
pnoise is pereodic variant
Heck do I know, these names are cryptic
cnoise also doesn't need whatever rep is, so use that instead
it like Classic Noise and Periodic Noise ๐ And can confuse as pnoise feels like Perlin Noise
These noise functions, are they part of Unity.Mathematics?
Awesome, i was thinking ill use LibNoise or something, nice to know there's burst compatible ones
use multipliers
Oh, should I go upp in the noise scaler?
using Unity.Mathematics;
public static class NoiseHelper
{
public static float ZeroToOneNoise(float3 pos) =>
math.mad(noise.cnoise(pos), 0.5, 0.5);
//Uniform scale in this case
public static bool ProcGenPoint(float3 pos, float threshold, float scale) =>
ZeroToOneNoise(pos * scale) > threshold;
}
Higher scale = bigger openings
If you make it too big there's a certain chance you'll see nothing at all, or all solid, though
yep, went solid
Also, from your sample code it seems like you generate a new cube each press of your generate button. It might be useful to make a way to change values (scale, threshold) at runtime and re-generate the cube when you press it. that way you can get a feel for what you get out of the procgen
Well, that's one option
But right now you have
void OnUpdate() {
if (Input.GetKeyDown(KeyCode.S))
//Does not remove old generated stuff?
//Generate new
//...
True, I could make a check so I can just spam S for them to re-render
Which is fine for just seeing how generating one chunk or whatever you call that works, but not so useful for experimenting with different values, since you need to exit play mode, change values (in code?), enter play mode, press S
That's a lot longer iteration time compared to "change values, press S"
And once you want to generate more chunks you can easily expand the system for that
So what you linked is the bool if they should span a block...can try that
Short iteration time is exceptionally useful in experimentation ๐
Yeah, the helper I posted is just a simple "Create block/enemy/whatever or not?" kinda thing
@storm ravine - I've searched the forums but your name isn't coming up (RE: RenderBounds)! Do you have a link by chance? ๐ Also, there's also WorldRenderBounds and ChunkRenderBounds with little to no documentation - are there obvious use cases for these?
Mind, I wrote all of that from looking at some documentation and have not written such code for DOTS myself, so it might not compile as-is
so what would threshold and scale mean, I'll just fiddle with them and see what happens
@storm ravine - I've searched the forums but your name isn't coming up (RE: RenderBounds)! Do you have a link by chance? ๐ Also, there's also
WorldRenderBoundsandChunkRenderBoundswith little to no documentation - are there obvious use cases for these?
@turbid sundial They already using under hood for HLOD and culling, RenderBounds is what you should care usually
Good to know
@cursive cosmos Scale "scales" the caves (true/false result).
Threshold is how "high" the resulting number must be to return true, or put differently, how rare the procgen is.
I recommend setting the threshold fairly high for initial testing (0.7? it's 0-1 BTW), and when you have more air that blocks, scale up slowly (from 1 to 1.2 then 1.5, 1.7, 2, 2.5, etc) to see how that works
@tawdry tree http://prntscr.com/stxfnd
Tried your noise while using .5f threshold and .9f scale.
It's pretty much the same as my first result, I'm very confused ๐
0.5 threshold should mean about 50% of blocks are solid.
Try threshold 0.7 and scale 1
I'm curious to see a screenshot of that, by the way
solid
cnoise require 0-1 value
THAT looks like many layers of perlin noise
with big noise scale
yep, I do want it like that, but can't get it to work xD
so pretty ๐
So threshold 0.7 made a fully solid cube? I think I inverted the check, then. try 0.3
quick side question, I looked at the docs for noise, how do you seed it?
I'm guessing you cant and need to do some sort of math after the noise so it works like having a seed?
perlin nosie isn't seeded
The "seed" is the position, so if you want a "seed" you use some arbitrary large offset
sweet, that makes sense
nothing @tawdry tree
Usually worlds tend to be pretty flat, so you'd primarily offset the Z position of the input position
@open walrus Oooh, it's super sensitive, then. Try 0.45?
I need to change the things to public.
Sounds like the output of "ZeroToOneNoise" doesn't go anywhere near zero or one with your small sample
there is a way to know if all jobs are completed, right?
grab the resulting jobhandle from the .Schedule
Or use .Run instead, which will wait for them to complete
//Option 1
var jobHandle = someJob.Schedule(/*args*/);
jobHandle.Complete();
//Option 2
someJob.Run(/*args*/); //Not good for chained jobs
@storm ravine Am I correct in this? Been a while since I played around in DOTS, being semi-active here to get freshed up on the current state and get those juicy often-linked videos before I delve in
For completing jobs right here yes. But for checking if chain done there is jobHandle.IsCompleted
If you don't want to force them to be done right here, right now
Oh yeah, should've mentioned that
That'd be something like
var jobHandle = someJob.Schedule(/*args*/);
jobHandle = someOtherJob.Schedule(jobHandle/*other args*/);
jobHandle.Complete();
And my bad about normalization, normalization required only for "default" scale ๐ A bit working now and looking in a half eye. Use division for your sample for scale
nvalidOperationException: The previously scheduled job ExportPhysicsWorld:ExportDynamicBodiesJob reads from the ComponentDataFromEntity<Jovian.Components.Weapons.Projectile> ExportDynamicBodiesJob.safety. You are trying to schedule a new job CollisionEventSystemJob, which writes to the same ComponentDataFromEntity<Jovian.Components.Weapons.Projectile> (via CollisionEventSystemJob.UserJobData.ProjectileData). To guarantee safety, you must include ExportPhysicsWorld:ExportDynamicBodiesJob as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.Schedule (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters) (at <fdd4f5823e2a41e8be8d5dcbd0bfd5b1>:0)
This is in a ICollisionEventsJob - how do I do what Unity asks of me here? And why does Unity.Physics read my Projectile tag, this has nothing to do with physics.
@cursive cosmos
EIZEN, are you just rubbing it in now, or are you telepathically communicating on how to actually get that?
stop bragging @storm ravine :<
var noiseVal = math.mad(noise.cnoise(pos / scale), 0.5, 0.5) * frequency;
if (noiseVal > 0.5f)
{
var e = ecb.Instantiate(index, prefab);
ecb.SetComponent(index, e, new Translation()
{
Value = new float3(
pos.x,
pos.y,
pos.z
) + new float3(0, 50, 0) //just offset for move it up from my ground
});
}```
oooh, code
There's the actual help I wasn't seeing
Just posting the result without code... I was wondering if you were VOIPing or something
@warm panther For the second half of that, I assume you use Jovian.Components.Weapons.Projectile in the job.
As for how to do that, the job wants ExportPhysicsWorld:ExportDynamicBodiesJob as a job dependency... though I'm not sure how to accomplish that
@warm panther For the second half of that, I assume you use
Jovian.Components.Weapons.Projectilein the job.
As for how to do that, the job wantsExportPhysicsWorld:ExportDynamicBodiesJobas a job dependency... though I'm not sure how to accomplish that
@tawdry tree Yeah that's what I read out of it myself.
if (noiseVal > 0.5f) and this should be replaced to your threshold
what was your values on scale and frequency @storm ravine ?
15 0.9
Why the math.mad operation, by the way?
@cursive cosmos threshold should be 0-1 as noise return you 0-1 in current implementation and frequency <= 1, frequency can be > 1 but then you should change threshold as they related
Noise should IMO return a normalized 0-1 value for easy of reasoning
It gets better:
nvalidOperationException: The previously scheduled job CollisionEventSystemJob reads from the Unity.Collections.NativeArray`1[Unity.Physics.Velocity] CollisionEventSystemJob.EventReader.m_InputVelocities. You are trying to schedule a new job Solver:ParallelApplyGravityAndCopyInputVelocitiesJob, which writes to the same Unity.Collections.NativeArray`1[Unity.Physics.Velocity] (via ParallelApplyGravityAndCopyInputVelocitiesJob.InputVelocities). To guarantee safety, you must include CollisionEventSystemJob as a dependency of the newly
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <fdd4f5823e2a41e8be8d5dcbd0bfd5b1>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <fdd4f5823e2a41e8be8d5dcbd0bfd5b1>:0)
Unity.Physics.Solver.ScheduleApplyGravityAndCopyInputVelocitiesJob (Unity.Physics.DynamicsWorld& world, Unity.Collections.NativeSlice`1[T] inputVelocities, Unity.Mathematics.float3 gravityAcceleration, Unity.Jobs.JobHandle inputDeps, System.Int32 threadCountHint) (at
This is what my simple CollisionEventSystem gets when it just get scheduled, without using any ComponentData. this is practically 1:1 copy from the samples I found on the forum.
Why the math.mad operation, by the way?
@tawdry tree as it will be reinterpreted in assembly code to 2 add instructions instead of one add and one mul
Yeah, but why are you doing multiply and add to begin with?
[UpdateAfter(typeof(EndFramePhysicsSystem))] by the way
Does cnoise return -1 to 1?
Wee, progress!
yes it [-1:1]
@storm ravine you are a noise genius.
Sugar, now you got a good cave generator! For a floating island generator, increase the threshold a bit (or lower, depending on which implementation you use)
Now I need to figure out landscape math and how to know if it should be grass and dirt and so on.
But this is a good start
looks great
wait, can you even make system variables public for change?
do you have to place the systems on an empty game object and such?
You can make them public, yeah
Might not be a good idea, it is certainly easy to go against the best practices that way, but for experimentation, sure
No, systems exists in the entity manager, mostly
At least during experimentation phases, yeah
systems exists in player loop
If you want to be able to tweak them "live" you could make a monobehavior with the appropriate settings, and in the MB's update, set some public static vriables to the same. The system could then access those (outside the job)
That's a really dumb and naive way, but should work?
A more DOTS-y way is to use singletoncomponents or entities or whatever replaced them
Still need to get the values into some code you control, tho
I'm just afraid to spawn duplicates and such.
like, pulling a slider and spawning a million of the entities would be bad
Hmm, the live thingy with subscenes could maybe do it? Haven't touched those yet, so wouldn't know how
If you did what I said, you would still need to press the "generate" button to generate
Oh, and you should add something to find and delete all the existing entities first, probably...
yeah, which would not be bad, but I still need to grasp all my entities and remove them, dunno how to grab them all though unless I should save them in some list and remove then one by one in jobs
entities.WithAll<your_tag_component> and entitymanager.... use intellsense and look for dleeting entities?
Oh have not even made a tag component yet, should probably fix that
You want at least some way to fetch the blocks, yeah ๐
Alas, I have to be off, feeling the sleepy seeping in.
Good luck!
see ya!
Who connects UI and ECS? As I understand it, is there any system like UISystem and the displayValue component which is on something? or how? what about the events?
Wow, unity crashes hard when you leave a stray Debug.log in a burstcompile job. what garbage.
At least a warning would be kind.
I mean we can barely debug jobs as it is, at least printf debugging needs to be available at all times.
I'm this close to writing something that renders a native textbuffer to stdout or something. like the matrix.
Doesn't it give warning if you don't burst compile?
nope
also, ever since I put this system in, Enter Play Mode takes ~20 seconds. I wonder what's up with that.
Well I was able to successfully get a collision to work, but as soon as I try to read any Componentdata like my Projectile tag, it doesn't work.
InvalidOperationException: The previously scheduled job LocalToParentSystem:UpdateHierarchy reads from the ComponentDataFromEntity<Jovian.Components.Weapons.Projectile> UpdateHierarchy.safety. You are trying to schedule a new job CollisionEventSystemJob, which writes to the same ComponentDataFromEntity<Jovian.Components.Weapons.Projectile> (via CollisionEventSystemJob.UserJobData.ProjectileData). To guarantee safety, you must include LocalToParentSystem:UpdateHierarchy as a dependency of the newly scheduled job.```
Same old
So... What about UI in ecs?
I export my ECS data to a classic UI as needed. Some of it, yes, via singletons, others through messages much like what Codemonkey demoed a while back.
So I'm creating a NativeArray<float3> to represent all of the positions of terrain chunks I've generated. Obviously, this fills them all out with zeroed float3s, and when I check whether or not a chunk exists at that position - it always will, so it'll never be generated ๐ฎ I guess a simple fix would be to just put the terrain at 1f on Y, but any other thoughts?
@warm panther can u send video link ? And example of your code
Projectile is literally this.
It is not used in any of my systems (however it is added by an authoring component)
Ah oops.
I thought you were gonna help me with my issue ๐
@halcyon plume https://www.youtube.com/watch?v=fkJ-7pqnRGo
โ
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=fkJ-7pqnRGo
Let's learn 2 ways we can handle Events in Unity DOTS! The final class is included in the Project Files.
Unity DOTS / ECS Tutorials
https://www.youtube.com/playlist?list=PLzDRvYVwl53s...
What is your issue?
As soon as I use any ComponentData in my collision system, I get this error:
InvalidOperationException: The previously scheduled job TRSToLocalToParentSystem:TRSToLocalToParent reads from the ComponentDataFromEntity<Jovian.Components.Weapons.Projectile> TRSToLocalToParent.safety. You are trying to schedule a new job CollisionEventSystemJob, which writes to the same ComponentDataFromEntity<Jovian.Components.Weapons.Projectile> (via CollisionEventSystemJob.UserJobData.ProjectileData). To guarantee safety, you must include TRSToLocalToParentSystem:TRSToLocalToParent as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.Schedule (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters) (at <fdd4f5823e2a41e8be8d5dcbd0bfd5b1>:0)```