#archived-dots
1 messages Β· Page 57 of 1
but my logic needs to be used on all systems (even if that is only 2 currently...)
of all sorts
then your architecture is wrong
and you need to figure the other way
they do? i always use local to world and i never knew they had helper methods, how fascinating!
take a look at TransformAspect
in manual
it has tons of helpers
then how should i do it, without needing to copy and paste everything like sprinkles, im really lost and confused
i need to have dinner now, ill be back soon though, sorry, and thanks so far for everything
or you can store data in a way that is obvious and simple enough
ok i've had dinner and i have thought really hard about this, and i think i get it now, and i think i found a better way than what i was doing previously, thanks so much for all the info, im now going to remove all those static methods, chuck the ones that are actually used (and are a replacement for more than 1 or 2 lines of code) in whatever system uses them most, should another system ever need it then i can just do it manually and not use a method at all! Hopefully that makes some sense, im tired lol, thanks so much for all the info!
anyone messed with joint motors at all?
posted a question here - https://forum.unity.com/threads/joint-motor-more-than-one-axis.1379079/
tldr - trying to get motors to work on more than just the x axis
Hi! I'm just getting started with DOTS. I have set up an empty 2D URP project (2022.2.1f1) and it appears I'm already running into an issue. I added the Entity Graphics package (1.0.0-pre.15) to get the required dependencies. However, it appears that transport and 2D packages cause several issues which seem to be related to an old collection library, I believe:
Library\PackageCache\com.unity.2d.animation@9.0.1\Runtime\TransformAccessJob.cs(165,62): error CS1955: Non-invocable member 'NativeHashMap<int, TransformAccessJob.TransformData>.Count' cannot be used like a method.
Library\PackageCache\com.unity.transport@1.3.0\Runtime\IPCManager.cs(79,44): error CS1955: Non-invocable member 'NativeHashMap<ushort, int>.Count' cannot be used like a method.
From my short search, it appears that the NativeHashMap was renamed to NativeParallelHashMap quite some time ago.
Is this a known limitation, i.e. is 2D not supported currently or am I looking at this wrongly?
Thanks!
What version of collections are you using? And how are you including the transport dependency?
the 2d animation package doesnt work with dots, remove that and everything should be fine
So I'm spawning items, and realized I'm setting a new UniformScaleTransform when I spawn them and overwrite the desired scale/rotation from my prefab.
What's the normal way to handle this and only update the position?
Or do I have to get the translate component seperately from the prefab with a componentLookup?
And yea, 2D isnt supported with DOTS in the first place
Thanks for taking the time! Oh well, that settles it then. I was thinking about prototyping a tile-based game with some interacting systems (think Rimworld or similar). Thought that could benefit from this approach. Just thought it'd be a good exercise to get my hands dirty :)... But I get that for most 2D games, this would probably be overengineered. Maybe a GO-based architecture works well enough.
oh, Rimworld would benefit a lot from dots
and since RW barely has any animations or graphics, you don't even need neither tile map or skeleton animation to make a clone
Yep, that's what I thought... But does "no 2D support" mean it doesn't render sprites as well? Because I suppose that'd be pretty much the only thing that's needed.
there are no 2D tools at all
you use 3d as 2d basically
with z as depth
and there is no 2d rendering, so under the hood it uses hybrid with GO sprite renderers
besides, you can use tilemap, but only in non-interactive way
no physics or such
I think that'd be fine. Maybe I'll have a look. Thanks for the hints! I'm not married to the idea or anything π ... I just want to avoid working against the "intended way of doing things" when I'm still learning.
I've just placed a cube collider on every wall tile. It works decently enough. The stateless physics engine requiring complete physics state regeneration every frame is a bit painful though
So it's good to know the limitations. Maybe I missed it and it's mentioned somewhere in the docs. If not, it'd be nice to add a paragraph to the Entities Graphics documentations.
I have it working with component lookup, but it feels bad to do the lookup, so I could make a new component for it. Just feels bad there isnβt a cleaner way to utilize some of the prefabs transform values, while modifying them
you can use static colliders
Static colliders are still regenerated every frame.
what's the difference, between static world regeneration once in a while vs dynamic colliders every tick?
are you sure?
The BVH isn't rebuilt but the world state still is.
Static colliders only optimize skipping BVH reconstruction. There's an initial world state building that must be done every frame. Not that expensive thankfully, 1,000 colliders only result in 0.05ms parallel.
but that 0.05 adds up with netcode requiring 32+ physics steps for rollback.
I'm trying to implement a nativearray/nativelist of generic structs that calculate faces for my minecraft clone.
The struct implements an interface that gives details on what exactly the mesh should look like (like vertex count, etc), so that it is easier to add new or different shapes other than quads like spikes or flowers in the future. however it seems that unity jobs doesnt like me doing this as it wants me to use a non-nullable value type. is there a good alternative or workaround to this?
ideally, I should be able to have one nativearray or list for a whole grid of differently shaped faces
i suppose i could just store an int or enum which tells the mesh generator what type of mesh it is maybe? but that also makes it harder if I need to do any precalculations to a type of shape before it is sent in to be generated
You can either use a union struct using [StructLayout(Explicit)] or some time of value reinterpretation. Or multiple arrays.
Check out how unity physics does with collider reinterpretation. Colliders are all 1 array but the type of collider and the data within is different. They use a header struct with the type of collider as an enum and reinterprets the data within using that enum.
yeah doing that or similar seems best for my scenario. union structs sound like a headache anyway lmao
It's not too bad. Just keep track of the field offsets and you should be good. Especially if you use structs instead of manually computing the offsets of each field within your array data.
unionizing the values for faster netcode serialization is sneaky
Although couldn't you just make it a long at that point? I've never checked how netcode actually serializes everything
The color may change and the properties not. This is equivalent to "composite = true" on the ghost field but with 1 value serialized instead of multiple.
But yea, a ulong would work as well... hrm
I thought netcode only serializes the entire component and checks the hashes to check for changes?
Or is it per field
Yea, but when it serializes bytes, it converts all the byte values within Color32 into a uint4.
Which I assume wastes a lot of bits. Depending on how the bitpacking works. Probably doesnt do anything honestly
I just thought it would be (very slightly) faster to serialize a single long than 2 uint, but it probably makes no difference
(and like I mentioned I never actually checked how it does it so I might be completely wrong)
same here
Yeah pretty much, no idea if it's faster or slower though π
anyone ever had the Allow unsafe code setting not work? annoying, ive deleted the library but it still thinks its not ticked
did you tick it in ProjectSettings though?
yeah
then I guess just try to restart
make sure the asmref for the script also has it
ah wait it was cos it was in the package not the general project.
yeah that was it π
painful to delete library on an older surface pro
Ah, how do you resolve player-player collisions then?
Why doesn't it just work?
From the players perspective how is the collision different to any other interpolated ghost
Predicted - interpolated collisions (using a owner predicted two sphere collision) results in client-server divergent simulations.
Because on the client, interpolated objects are enforced kinematic, so predicted objects will bounce off them like walls. But on the server, everything is dynamic since there is no such thing as interpolated serverside physics. So objects collide and push normally.
That's kind of the nature of prediction
I've made everything predicted which solved the issue of collisions but remote player controlled objects move very poorly.
Your player is not a kinematic?
Most controllers still use kinematics and execute the dynamics itself
I would really hate to implement a full 3D physics stack just to move a single player.
Because, from what I can tell, kinematics dont interact with static objects.
Controllers often have a dedicated developer or even small team working on it for the entire game development
It's a lot of work
ugh
Sounds like you should use rival π
im looking at it now, im gonna see if i can clamp it to 2d without any particular hacks
alternatively check out the netcode car demo from unity
since those cars are heavily physics based objects
actually yeah they use dynamic physic object cars on owner predicted
so that seems like a good source of an example of what you wanted to do originally
Fwiw, this is the crash i've been getting since switching to 2022.2.1f1 and dots 1.0
I dont know if it's just me but playing the car demo doesnt work for me. But I have been digging through it as reference. That's where I pulled predicted smoothing from which slightly helped the issue.
Do cars collides with each other?
Give me a sec, pulling up the repo
oh i never tried multiplayer
i would have hoped so
because that'd be the whole fun of the demo
out of memory?
allocating 1TB of memory will do that
yeah.. basically it seems fine when i'm actively working on the project - when i walk away from the pc for any length of time i come back to that
seems like probably a memory leak
hmm not sure
we had a similar bug a few years ago
just randomly try allocate like 40GB of memory
was basically just a bad write on a pointer
hmm
not saying this is you
my only real suspect is baking tbh
graphics has the most issues of the packages for me atm
or potentially one of the assets ( i use a fog asset that does graphics related stuff obviously )
Failed to load 'C:/Users/CornFlakes/Documents/ECS-Network-Racing-Sample-master/Assets/Terrain/Terrain_0_0_89adce58-f5ec-4f5a-803b-a54fad3b41f3.asset'. File may be corrupted or was serialized with a newer version of Unity. That's error when I try to play the car sample. And I'm on 2022.2.1F1
i haven't really tried to get to the bottom of it yet tbh, i'll maybe try removing that asset from the scene etc.
odd. what version of unity?
there was a breaking bug related to the car project that was mentioned recently, that they have or are going to update with a fix
yeah physics baking (unless there was something else I missed as well)
but that looks like just a terrain asset?
Yea, just a broken asset I think
Hrm, it's 1kb size. I think something just overwrote it. Gonna grab a copy from github
ah did you pull/clone the repo or just download it rom github?
you have to pull with LFS
Yea, just realized that. Doing that now
huh, I thought they fixed this physics baking problem?
look at this post
this poor guy, reported it like 2 weeks ago
"update editor, reimport" etc etc
i load up racing sample, get it first thing, report it
they can repo it instantly
but i don't understand, how whoever was developing the racing demo didn't report it -_-
it reminds me of my work, people see a red error, 'clear' - "Someone else must have reported it already"
It's unity, it always throws errors.
anyway i loaded up rival, it does not seem to use dynamic controllers (seem to be static) which is what I suspected
I thought the backport fix already came through because I can use physics smoothing on my main project with no issue.
ugh, i have to go through all the prefabs to try and find physics bodies with interpolation on just to fix this error
There we go
hrm, doesnt look thin clients work
Yea, collisions are really bad in this
Wow, so many shaders
Is Unsafe.NullRef burst compatible?
i don't even know what that is
from what library
Unsafe
it's part of C#
Runtime.CompilerServices
But it's not part of what unity uses
I think you can build something similar with the methods in UnsafeUtility though
it seems internal
to the c# library?
[NonVersionable]
[MethodImpl((MethodImplOptions) 256)]
public static bool IsNullRef<T>(ref T source) => ref source == IntPtr.Zero;```
hmm
what am i missing
Weird
oh wait no, .net 5+
In a "normal" C# project it's not internal
regardless i guess question is
why do you need it? but an null check is fine in burst
(but yeah, i thought unity didn't support .net 5 yet so I'm not sure how you're using it π€·ββοΈ)
(or am I mixing up all the confusing versions again)
I'm trying to write a TryGetValue that returns by ref
I'm using a BlobHashMap library someone wrote and their methods don't return by ref, which is an issue for me
What happens if you do ref (*(T*) ptr) where ptr == null?
I'm guessing it's a bad idea to use the value, but in theory getting the address of it should also resolve to null, right?
Is there a built-in way to disable an entity? (like collider and mesh) in 1.0?
oh does that library finally work in 1.0?
It didn't work before?
unity broke it in 0.16 from an unneeded safety check
Ah yeah, I removed that
π
(who needs safety amirite)
The blob safety system is so weird, it just doesn't seem to catch a lot of stuff
think i've done it like this before
ref var r = ref UnsafeUtility.AsRef<int>(null);
Yeah that was basically my idea too
Does getting the address of the ref resolve back to null though?
only 1 way to find out
Seems to work
returns true π€·ββοΈ
Using the value even throws a nice NullReferenceException, so also seems pretty "safe" to use
if only 1 entity has a specific component does it automatically get treated like a singleton component, or do i need to specifically mark it somehow?
ok cool, thanks a ton!
How is dots performance on mobile?
Is there a way of updating shared components without forcing a sync point or using an ecb?
Nope
By definition they need a sync point for their value to be changed
I thought that since they can be unmanaged now that restriction would no longer exist
for a MultiValuedHashMap, is a value enumerator deterministic/consistent? π€
E.g - if I store multiple values for a key and grab a value enumerator, will iterating along the value enumerator have the same order between multiple runs? Or should I not bet on this and actually store a 'sort key' so I can iterate things in the order that they're stored into the MutliValuedHashMap?
Normally I think the order for set type containers is undefined
They require a sync point because changing a shared component value potentially repartitions entities and changes chunk layout
alright - yea I think I'll store a sort key for now so I can iterate things in the order that they're stored
You can use them inside burst methods now that they are unmanaged
The reason they require a sync point isn't because they weren't unmanaged before though
Right I forgot to mention that I only change scd using entity queries (with scd filter) so it's more of a 'swap', although I guess that still risks a structural change
That doesn't just risk a structural change, it is one
Does it force data to be moved?
If the SCD value is changed, yes
Even if all of the entities sharing that scd has it changed all together? Ideally no extra work would be done
I don't think this is checked for, I might be wrong though
Pretty sure it's always a structural change
Yeah probably honestly
The idea is to just not change them that often
Been getting this wonderful error..
When i hit play with the subscene open it's fine
Everyone gets that error 
Well it doesn't load the subscene in playmode when the subscene is closed
and it wasn't previously throwing this error π
It just breaks sometimes
The "quickest" way to "fix" it is recompile, then clear the entity cache
But it will break again at random times
yeah i couldn't find the clear entities cache option in 2022/ecs 1.0
ah yeah thanks
Agents = SystemAPI.GetSingletonBuffer<NavMeshAgents>(true),
you request a nice little buffer readonly
but unity don't care, have write access anyway
tertle help, my function works with burst off and breaks with burst on π¬
kekw
What even is this error message
System.IndexOutOfRangeException: Index {0} is out of range Length {1}
I guess the formatting broke
And it's not actually 0 and 1
just clear subscene, restart unity, clear again
yeah burst doesn't support exceptions
Great then how do I debug this 
clear cache worked for now, thanks
so that's just the format string
Time to print random stuff everywhere
break point on top of the exception
i've had this randomly
!
I thought you can't in burst functions?
2022.2 and burst 1.8 supports break pointing
waht
(by simply turning burst off automatically where you put a break point)
but yeah there is little reason to turn off burst
it's deterministic if you don't use parallel writer
Weird, if I set it to break on IndexOutOfRangeException, it doesn't
Does that not work with burst?
is it erroring?
If I set the break point where the exception is thrown, it doesn't get thrown anymore, I'm guessing because it turns off burst
great
How do I do that?
no
there is definitely an issue with burst caches i keep running into
(basically a crash or quitting unity while compiling just breaks everything for me atm)
O cool. Then I can likely work with this
@rotund token I don't think ref pointers resolve back to null in burst
The highlighted line is where a NullReferenceException is being thrown
Kind of a bummer
Yeah, this doesn't log anything

It works outside of burst
Would be nice to add that to the burst docs, since it seems to be missing. Kind of a niche thing anyways
does this just not mean your IsNullRef line doesn't work
because it's returned the null ref pointer fine
i think I used it something like
ref value TryGetValue(T key, out bool found)
or something
That doesn't work if that functions calls a function that also needs to return by ref
Which can be worked around, but it's still really annoying
what do you mean?
it just changes your code to
ref var result = ref data TryGetFirstValue(key, out var isValid);
if (!isValid)
{
value = default;
return false;
}
value = result;
return true;```
if TryGetFirstValue uses a function that returns by ref, you will get a compile error
You can't have a function return by ref and have a ref or out parameter
oh i see what you're saying
(and then call another function with the same properties)
It's not a huge issue, since I can just put everything in one function, but it's still kind of annoying
wait it seems to work fine for me?
Let me check, I had issues with that when refactoring earlier
where T : unmanaged
{
result = true;
return ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index);
}```
this compiles fine
(at least in rider)
thats a completely different error
^
I assume it doesn't show the actual issue, instead only telling you that it's not a valid thing to return by ref
That's why the error message is different
where T : unmanaged
{
ref var a = ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index);
result = true;
return ref a;
}```
this works fine for me
i don't know what is up with your iterator
but just make a method that doesn't return it?
Yes, because you aren't calling a function with an out value in that function
If ArrayElementAsRef had a ref or out parameter, that wouldn't work
both parameters are passed by value
Alternatively call ElementAt in a function that also returns by ref
i think you're overlooking a really easy solution
get rid of the out
you aren't using
make an overload without it
That's why ^
I was just trying to explain since ^
Returning null ref is still kind of awkward though since afaik you can't force a function to "receive" the return value as a ref
Overwriting a local value with the null ref value immediately throws a NullReferenceException

???
???
warning not an error
That's really odd
hacker
I'm calling the police
It's definitely a compile error for me
it was a compile error when i did it a different layout
like this
anyway i don't care about, too weird just use pointers π
Yeah I thought about it, but It feels weird to use pointers for one thing in blobs, and ref for everything else
π€·ββοΈ
someone call the ref police
The double ref might be a problem.
I'm starting to think so too
Maybe burst can't pass a null reference or something
(as ref)
But then I don't see why AddressOf works
If you pass a null reference as a ref property, it may be resolving the wrapper variable which is valid but the reference itself is null.
But then AddressOf would also not work
Is there an easy way to print the memory address of a pointer from inside of burst?
I only know the IntPtr string formatter, but that won't work in burst
It has to be pointing to something for it not to evaluate to null
just do addressof and then get the address of the pointer, cast it to an int
and write it out
x4 if you want to format as hex
as expected
Yeah, odd that the null check doesn't work
just compare it to IntPtr.Zero
return new IntPtr(p) == IntPtr.Zero;```
something like that?
It works as long as it's not in the function, so I'm guessing something weird is going in burst when passing it by ref twice for some reason
Time to sleep ποΈ
oh wait no
thought it was a different method
Funnily enough it works if I cast the pointer to an int and compare to 0
π€·ββοΈ
I think burst assumes references can't be null and optimises some code out
I've had problems with that in the past
safer to use pointers if it can be null
Is there any way to get entities to render in the scene view?
they should by default
if they aren't, check your authoring settings
is set to runtime data
That was it, ta
probably a silly question, but how do i remove a component from an entity?
EntityManager.RemoveComponent<T>(Entity)
thanks a ton!
anyone know how ScheduleParallelByRef compares to ScheduleParallel? i see it used in the LocalToWorldSystem
It's for when you have a lot of the same structs required as input into a job. I use it in performance testing to run the same job over and over again.
hmm, I guess ill use it then? any downsides if you dont have lots of same structs? is there any doc or forum post on it?
I mean, I dont see anything wrong with just creating the job on create and then setting the fields of the job struct in update just before scheduling. Maybe there might be an issue with long running (multiple frame) jobs but the performance benefit might be minimal.
i don't believe you could store store private fields anymore
for caching temp allocation etc
i generally find it, not worth the rare error
just checking that this is a good way to get read write for a component on a known entity? ```cs
state.GetComponentLookup<SomeComponent>().GetRefRW(SomeEntity, false);
SystemAPI.GetComponentRW
ooh, thanks so much!
how exactly do i use it, as it wants a systemhandle and not an entity?
oh yeah
that's a wrong one then
kek
well you can just do
GetComponent
and then SetComponent in the end
ooh good point, thanks for the info!
As alternative
/// <summary>
/// Provides an unsafe ref to component data directly. Gets invalidated on any structural change.
/// </summary>
/// <param name="em"></param>
/// <param name="entity"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
[GenerateTestsForBurstCompatibility]
public static unsafe ref T GetComponentReference<T>(this EntityManager em, in Entity entity)
where T : struct, IComponentData
{
var access = em.GetCheckedEntityDataAccess();
var typeIndex = TypeManager.GetTypeIndex<T>();
access->EntityComponentStore->AssertEntityHasComponent(entity, typeIndex);
access->EntityComponentStore->AssertNotZeroSizedComponent(typeIndex);
if (!access->IsInExclusiveTransaction)
access->DependencyManager->CompleteWriteDependency(typeIndex);
// var ptr = access->EntityComponentStore->GetComponentDataRawRW(entity, typeIndex);
var ptr = access->EntityComponentStore->GetComponentDataWithTypeRW(entity,
typeIndex,
em.GlobalSystemVersion);
return ref UnsafeUtility.AsRef<T>(ptr);
}
but generally it's better to use SystemAPI
the code I sent is only good if you only have just 1 component of T type to look up for RW in OnUpdate cycle
ok fascinating, thanks for the info
wondering how would i set the name of an entity? (if entities even have names)
EntityManager.SetName
thanks a ton!
any idea if any of the physics devs spoke during the Q&A?
I dont think i ever have used private fields and the use by the transform system just recreates every ref job in update(as I do) π€·ββοΈ
Does anyone know how to add leaf colliders to a compound collider at runtime?
I suggest to bake them and then add already baked collider to entities you want
oh wait
compound...
yeah... nvm me
Heck I'll even take how to make a compound collider from scratch during runtime at this point.
why is it even required?
sounds like overcomplicating things
I have items that can be attached to each other, like assembling something like a chair or a computer, etc. So you can detach a part, and then eventually have compatible parts that can be attached to different assemblies.
I think you should look into using joints
I did. And i got it to work perfectly.
But the issue was when an item falls to the ground that has fixed joints, it then jumps up wildly.
I tried everything, wrote a bunch of questions in this room. And no results.
π€
Now I'm back to combining colliders π¦
Ragdolls in sample don't jump wildly
But I don't need ragdolls, I need just simple, fixed joints. Basically to replace the traditional Transform Parent Child system.
ragdolls are pretty much joints
Pretty much.
I don't remember them having anything
have you tried to reproduce your bug in isolated environment?
Yes, it's actually where the bug occured. I have an environment just for building this behavior.
you could report to unity
i think if a fixed joint is causing a physics thing to jump around wildly it should be considered a bug, but im not really sure on behaviour of stuff like how collider penetration when fixing two rigidbodies together should be expected with this
btw
do your joints have very fixed angle
or some slight movement is allowed?
maybe that could help?
Oh yeah I tried that too, allowing some degree of movement, but that gave me other unwanted behavior.
Yup, cranked that shit up to extremly high step counts.
Tried all sorts of variations.
Didn't help one bit
Been working on this at every angle I could think of for a week straight lol.
Bout ready to give up on this project.
send it to Unity?
That I haven't done.
Could it be something to do with the mass or inertia of your objects prior to attaching with fixed joint? Have you tried creating an equivalent gameobject setup in a subscene with fixed joint and seeing how it behaves?
Yeah I considered that too. So until I got the right behavior all my objects have mass 1.
Inertia I havenβt considered. Whatβs the rule about inertia?
Well I think if your objects are misbehaving maybe probe some of the physics values and compare against for example a simple baked version of your body object
Just wondering if you are for example disconnecting an object that is part of a compound hierarchy for example and then adding physics mass etc to it when creating the jointed setup at runtime ( assuming that's what you're doing? ) maybe they are not initialized properly or something along those lines
In authoring, all items are separate. You assemble them at runtime. I never pluck off a child/leaf collider from the body.
The joints are created during bake for items that will have other item(s) attached to them. Then during gameplay, I just assign the other body to the joint data.
Did you try with havoc out of interest or no access to licence?
No access to license. I want to though π¦
In my experience, there's 0 difference from standard unity physics outside of stacking stability.
isn't stability the main appeal of havok?
I guess, yea. That's what they're advertising.
Is the performance about the same?
one of the benefits is because Havok is stateful bodies can 'sleep' meaning if they are within a threshold of movement they'll no longer be factored in to simulation calculations, so sims with large numbers of objects will benefit from that where a lot of dynamic objects are stationary..
i think though because Havok is stateful it can also have a little bit more overhead so in some cases be slightly less performant..
Hm.
kinda tricky to debug this one
well, need to track down that q I guess π
Make sure stack traces are enabled for asserts in the player settings
Is there something I need to do to get a subobject in a subscene to update it's position relative to it's parent?
once an object is converted to an entity at bake in a subscene, you can either rely on the built in parenting transform system or, if it's a physics object, do it manually
it seems it's not set up properly for the built in parenting
is the child a physics object?
the child isn't, but the parent does have physics
children should just work
there is no PropagateLocalToWorld which seems like it might be necessary?
in the editor I can see LocalToWorld changing, but not WorldTransform
WorldTransform should be set to LocalTransform every transform update
are you using rival by any chance?
I am
yeah we ( @minor sapphire & I) noticed a bug with rival
rival overrides the transform system with a write group but doesn't update the WorldTransform
so your character is always at 0,0,0
you need a system after rivals own transform system that writes WorldTransfrom = LocalTransform
i dont use rival
LocalToWorld targetLocalToWorld = SystemAPI.GetComponent<LocalToWorld>(mainEntityCameraEntity);
hmmm
i am summoning shinyclef with his fix
oh hi
hold on I'll paste a system for you π
/// <summary>
/// Rival has a WriteGroup on component <see cref="Rival.CharacterInterpolation"/> that prevents the
/// TransformSystem from updating the WorldTransform. This system copies LocalTransform to WorldTransform
/// for any root objects with the CharacterInterpolation component.
/// </summary>
[UpdateInGroup(typeof(TransformSystemGroup))]
[UpdateBefore(typeof(LocalToWorldSystem))]
[UpdateAfter(typeof(CharacterInterpolationSystem))]
[WorldSystemFilter(WorldSystemFilterFlags.LocalSimulation | WorldSystemFilterFlags.ClientSimulation)]
[BurstCompile]
public partial struct CharacterInterpolationWorldTransformFixSystem : ISystem
{
public void OnCreate(ref SystemState state) { }
public void OnDestroy(ref SystemState state) { }
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
new CopyTransformJob().Schedule();
}
[BurstCompile]
[WithAll(typeof(CharacterInterpolation))]
[WithNone(typeof(Parent))]
private partial struct CopyTransformJob : IJobEntity
{
private void Execute(ref WorldTransform worldTransform, in LocalTransform localTransform)
{
worldTransform = (WorldTransform)localTransform;
}
}
}
Also @calm edge I mentioned it here: https://forum.unity.com/threads/released-rival-dots-character-controller.1118761/page-3#post-8689680
thanks, I just hacked up the CharacterInterpolationJob instead of adding a new system π
I'll have a read through that thread later
Huh, i should make sure the WorldTransform gets properly updated next time I update the package. I was too used to always using LocalTransform for rigidbodies so I never noticed it.
@minor sapphire I'll be answering your forum questions probably tomorrow
Awesome thanks. I figure I must be missing some fundamental differences between first and third person requirements for a netcode controller. Probably made worse by the fact in my game I can toggle between first and third person views π
porting first person sample to a third person context probably leaves some gaps somewhere heh
The other problem with rivals I had was having 100s of physics objects causes the rivals code to take a massive amount of time doing physics steps
I'm new to ECS physics, but It seems like it's manually stepping the entire physics world?
oooh, I get it now, it's not the rivals code, it's the normal physics step that happens before and then the rivals code is waiting for its job to complete
Yeah, but I was just confused at what was responsible
I was just seeing how far I could push it
this warning appeared in the ide im using (visual studio), is it anything to be concerned about, or should i just ignore it?
interesting error but i wouldn't be too concerned if it's not popping up in unity
ok good!
theres a forum post somewhere that shows havok being worse in terms of raw active rigidbodies(that werent sleeping). iirc it wasnt that much worse but kind of surprising
hmm i'm not sure that's too surprising?
it has to do a lot more to determine state/sleeping/etc
but generally I think you'd have a lot sleeping so in most real world scenarios it's probably going to run a bit better
i tried to add the concept of coming to rest in unity physics, my implementation ended up being so gross
i need to figure out a good way to do it, determining rest was a pain
is it possible to use EntityManager.SetName() in a bursted function or is it impossible?
it wasn't before, probably still not
ah unfortunate
EntityManager.CreateEntity(); will always put the new entity at 0 0 0 right? Meaning any child entities should have their local position be equal to their world position?
makes sense but at the same time i thought for sure havok would be super duper optimized or whatever to ensure it was the fastest and best choice of the two
on the other hand, unity physics built specifically for burst
i haven't really benchmarked or seen a real world test so if anyone has one would be interesting to look at
i do wish they had gone forward with the extra low fidelity 3/6dof rigidbodies like they alluded to a while ago
not sure what the plan for stuff is long term but for many of my own uses just something that bounces/collides but doesnt need a super accurate sim would be fantastic for effects
I'm having an issue where I verify completely that I added elements to a DynamicBuffer inside of a Baker, and that during Baking the elements exist in the DynamicBuffer, and that DynamicBuffer is NEVER cleared or has its elements removed elsewhere in the code. Yet, the moment the game is run, the DynamicBuffer is shown as empty. What could be the reason for this?
This is only happening to one of my DynamicBuffers. Everything else works. the chunk size is far from being exceeded by a single entity
The Entities Hierarchy is showing that the elements exist
Both in Edit Mode and Play Mode
I'm printing the length of that DynamicBuffer inside of a job and it's always 0. That's despite the Entities Hierarchy showing that the DynamicBuffer has 2 elements
It's not disabled either
your code has the funk!
not doing a reinterpret or something on the buffer
so the clear isn't being found from inspection?
ooo
ECB.AddBuffer?
try use the journal - it should tell you everywhere your component is accessed
Thanks for the suggestions. No reinterpret. I searched for usages and they're all confined to one file, which I scoured thoroughly. No .Clear(), no Remove(), no ECB.AddBuffer(). The journal didn't reveal anything - printing the length of the buffer from within a job shows 0 despite Entities Hierarchy literally showing the 2 elements it's supposed to have. Here's the access code:
foreach (var eventDone in eventDones.AsNativeArray())
{
EventActionsJob.Execute(ECB, eventDone.Entity);
}
It's inside an IJobEntity with this
what would be the best way to get an array of all components of a certain type, guessing using an entity query then using ToComponentArray<>()?
hmm it seems ToComponentArray<>() requires a reference to something, how mysterious
That's not very good idea
It will copy all data on new memory
ah, should i use a get RW version then?
ok and how would i access the components in a job?
ok thanks a ton!
Non job alternative - systemapi query
ok
Is it required entities to be in a subscene so that systems can operate on them?
I have entities existing outside of a subscene and observe that the movement systems won't move them, even though the systems can query them.
trying to use an IJobEntity, how do i complete the job?
no
from the perspective of a query there is no difference between an entity in a subscene and not
it also seems i can only run, but the docs claim that there are more options
Are you using an EntityCommandBuffer?
look at manual
they have examples of IJE implementation
That's right. I have just tested with entites in a subscene, my systems won't run too. Don't understand why π₯²
Are you sure your systems are running? Check the DOTS Systems window π
My system is not running. That's what I'm wondering about.
Am I doing it wrong here?
It knows there are 10 entities matching the query
But it doesn't run
Huh, I have no idea
how do you know it's not running?
did you throw in a debug log?
or a break point?
What singleton do I need to get
to run TriggerEventsJob?
SystemAPI.GetSingleton<SimulationSingleton>(?
yes
after what systems those jobs are played back?
Hello, I am using Unity 2021.1.2, I am trying to implement something in the JobSystem, I have all the packages needed and can use NativeArrays, but I cant seem to find "NativeList", anyone familiar with this problem?
oh btw, what was that the fastest way to check whether entity matches query (has component)?
Smth about query mask if I remember
yeah entity query mask
so, I just pass it to job and that's it?
it's part of collections package
I had to import the package indeed, guess it is different than using Unity.Collections, thank you! π
hmm, I'm guessing for disabled component my only choice is query mathing?
it should work fine for disabled component
queries can match disabled entities
if you tell it to
I'm trying to figure what's better:
- using IEnablableComponent
- using buffer that contains list of disabled entities
Since application has very little entities (like probably 5 max disabled entities to track, before they are cleared)
yes by default queries ignore disabled components
but you can tell them to include them
yes but masks are made from queries no?
all entities in a query should return true if passed to the mask
so if my query is returning disabled entities, the mask should match them
protected override void OnCreate()
{
var query = new EntityQueryBuilder(Allocator.Temp)
.WithAll<TestComponent>()
.WithOptions(EntityQueryOptions.IncludeDisabledEntities)
.Build(this)
.GetEntityQueryMask();
var entity = this.EntityManager.CreateEntity(typeof(TestComponent));
this.EntityManager.AddComponent<Disabled>(entity);
Debug.Log($"Matches Query {query.MatchesIgnoreFilter(entity)}");
}
why do you make me do this!
but Unity description literally says so
lol
oh, btw
YOu specifically included disabled
meanwhile it should be vice versa
what?
.WithOptions(EntityQueryOptions.IncludeDisabledEntities)
For my case I don't want this option
then don't use it?
as I want to filter disabled somehow
var query = new EntityQueryBuilder(Allocator.Temp)
.WithAll<TestComponent>()
.Build(this)
.GetEntityQueryMask();
var entity = this.EntityManager.CreateEntity(typeof(TestComponent));
this.EntityManager.AddComponent<Disabled>(entity);
Debug.Log($"Matches Query {query.MatchesIgnoreFilter(entity)}");```
no
then I guess this is where mask won't work
yes because it doesn't support filtering as the method says
well, my question initially was about them π
but I appreciate you showed interaction with query options
which it does work for!
the question you are asking does it work for IEnableableComponent
yeah, and it's not. So I'm considering either using query check
or making buffer
which will contain disabled entities
fastest way is to probably just do a IsEnabled on ComponentLookup
if you care about a specific state
in one case I'll have to implement IEnablableComponent pipeline
in other I'll have to implement a singleton buffer
I'm figuring which is less evil π
i assume this is an entity reference?
my use case:
if player collided with specific trigger, trigger should get disabled.
Meanwhile trigger should only get disabled, no entity itself.
buffer for such disabled triggers will be very small, max 5 if player is lucky
that seems straight forward enough
what's the problem?
should the trigger stay perm disabled (i.e. removed from physics simulation?)
I guess I'll just make IEnablableComponent
it's time for me to learn how they work at least
π
Hmmmm.
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var singleton = SystemAPI.GetSingleton<EndFixedStepSimulationEntityCommandBufferSystem.Singleton>();
var buffer = singleton.CreateCommandBuffer(state.WorldUnmanaged);
state.Dependency = new InteractionJob
{
ecb = buffer,
buffer = SystemAPI.GetBuffer<InteractionBuffer>(_interactionBuffer),
interactableMask = _interactableMask
}.Schedule(SystemAPI.GetSingleton<SimulationSingleton>(), state.Dependency);
buffer.SetBuffer<InteractionBuffer>(_interactionBuffer);
}
InvalidOperationException: The previously scheduled job InteractionSystem:InteractionJob writes to the Unity.Entities.EntityCommandBuffer InteractionJob.UserJobData.ecb. You must call JobHandle.Complete() on the job InteractionSystem:InteractionJob, before you can write to the Unity.Entities.EntityCommandBuffer safely.
did I do smth wrong?
buffer.SetBuffer<InteractionBuffer>(_interactionBuffer);
you passed the buffer to the job then used the same buffer on the main thread
I see
safety system triggered because job handle was not complete
during that write
just do it before the job and it should be fine
yeah, I just wanted to know why exactly it was a problem
hmm
So I need to make a physics object that can move and has physics object children.
It only gets moved by transform, no physics involved.
It's basically just moving trigger
and I need it to have multiple trigger shapes, which will produce different effect on trigger event
I used to do it previously with static colliders
it worked back in 0.51, but not anymore
so I'm wondering if I should make some sort of custom parent system, that will move children accordingly or...
damn
Compound trigger should work right?
does compound allow you to distinguish between collider/entity pair?
for example:
on top you have sphere, on bottom box.
If sphere is triggered - result is A.
If box is triggered - result is B.
I believe the collision events have the compound collider key included
So you can find the specific collider that hit
I'm in bed so can't look it up
yeah, trigger events has this property
I do wonder though, how can I get original entity from this collider key
I guess I will need to make some sort of dictionary on main entity during baking?
From memory you get rigidbody which has the entity
Yeah it references a dynamic buffer on the entity with an the children I think?
Been a long time since I looked at this though
π€
Physics and I are not on good terms atm (well to be fair, more netcode handling of physics)
to setup compound
what do I need to change on shapes/bodies?
or do I even need body on children?
physics is least documented as well
oh
looks like main entity has this buffer
all right
so maybe this works
bruh, smth wrong with my algorithm and Editor crashes if I try to debug it
if (colliderKeyLookup.TryGetBuffer(e, out var buf))
{
var triggeredEntity = GetTriggeredEntity(buf, key);
private static Entity GetTriggeredEntity(DynamicBuffer<PhysicsColliderKeyEntityPair> dict, ColliderKey key)
{
foreach (var keyEntityPair in dict)
{
if (keyEntityPair.Key == key)
{
return keyEntityPair.Entity;
}
}
throw new Exception("GetTriggeredEntity didn't find correct entity.");
}
I keep gettng exception all the time
what's more curious
with compound trigger events happen even if I don't trigger anything
oooh
looks like my physics body has empty buffer
I see now...
I was going to ask about checking the contents of that buffer π For loops over a collection behaving weirdly is in my experience almost always because of some unexpected thing with the contents
well, it's still doesn't make any sense
my trigger event happens
out of nowhere
also weird, that conversion even creates that buffer for non-compound
considering it has default internal capacity of 16
here's my compound collider
waaait a second
wtf
I can see now why my trigger happens out of nowhere
my physics body is living it's own life before game starts π€£
Here's the Baker
var eventDones = AddBuffer<DecisionMakerEventDoneElement>();
foreach (var eventDoneList in authoring.EventDoneInstances)
{
foreach (var eventDone in eventDoneList.EventList)
{
eventDones.Add(new DecisionMakerEventDoneElement
{
Entity = GetEntity(eventDone)
});
}
}
And DecisionMakerEventDoneElement is just an Entity reference to an Entity whose System represents a block of logic. Like an event
Here's the definition
[InternalBufferCapacity(0)]
public struct DecisionMakerEventDoneElement : IBufferElementData
{
public Entity Entity;
}
yep it's horrible. in my buffer size override list
is that part of your library?
what is it called, so I can look it up later?
just a window that looks like this that let's you override capacities
it basically just overrides typemanager data before anything uses it
good stuff
How can we create entities in baking system?
with great effort π
tldr: you need to add a SceneSection sharedcomponent
to associated with a subscene
Don`t
Too much pain
Create all you want in baker instead
Ok. By some reason my particular singleton component doesn't exist in build so I looking for different ways of how I can bake my singleton. Have no ideas anymore because I use few singletons and all works fine, but particular one won't appear in build, spent an evening on that
How do you make this singleton?
Simple baker with zero fields. Works fine in editor
using Unity.Entities;
using UnityEngine;
namespace NSprites
{
public class AnimationSettingsAuthoring : MonoBehaviour
{
private class AnimationSettingsBaker : Baker<AnimationSettingsAuthoring>
{
public override void Bake(AnimationSettingsAuthoring authoring)
{
AddComponent(new AnimationSettings
{
idleHash = Animator.StringToHash("idle"),
walkHash = Animator.StringToHash("walk")
});
}
}
}
}
So, your subscene is not built?
You don`t have any 'editoronly' tsgs??
No, all works fine in editor, but particular singleton doesn't exist in build
nope
Do you have managed stripping??
No, I've finally found issue
Seems build crashes because system runs before subscene loaded and with new "all system updates without any require" system just accessing to not yet loaded singleton. I should account this new system behaviour.
yeah i dislike this behaviour
of having to put require for update on everything for your singletons
Where can i find tutorial for ecs 1.0?
pinned messages
bruh
what is wrong with physics
my object collides with 1 collider
but some unrelated collider also gets collided
wtf
if I make more copies of collider
they also get trigger event
lol
3 colliders
collision happened here, yet all colliders are affected by ITriggerEventsJob (which removes PhysicsWorldIndex from them and why they don't get drawn AABB anymore)
baking runs also before build?
π₯²Native containers in IComponentData still not supported yet?
only in 1.0
yeah
I tried NativeList in IComponentData but it's not working
why not?
π€ Not sure. It just not working and failed to bake into subscene
well, it works for me
hm, i don't think it's intended (yet) for bakers
i'm pretty sure bakers/subscenes are not aware of serializing nativelists
I need some help with scene management in entities 1.0
I am able to load a scene but I'm not sure how can I unload the previous one
I have tried to use SceneManager.UnloadScene() but it does not seem to be working
I was meaning runtime
hmm, I'm using rivals character controller and firing slow projectiles so the relative velocity is important, but the character doesn't update physics velocity, is there any way to get velocity out of it?
You can get it with:
KinematicCharacterBody.RelativeVelocity
KinematicCharacterBody.ParentVelocity
ParentVel is the velocity of the moving platform being stood on (if any), and RelativeVel is the character velocity relative to that. So the total velocity is the sum of the 2
I added this:
float3 velocity = float3.zero;
if (parent.Value != Entity.Null)
{
if (SystemAPI.HasComponent<KinematicCharacterBody>(parent.Value))
{
var body = SystemAPI.GetComponent<KinematicCharacterBody>(parent.Value);
velocity = body.RelativeVelocity;
}
}
but the HasComponent is throwing InvalidOperationException: No suitable code replacement generated, this is either due to generators failing, or lack of support in your current context
Hmm, I haven't encountered that one yet but you could try an editor restart
no difference π¦
Are you making the call to SystemAPI inside a system, or is it inside a job or a static method?
If you need this in a job, try passing a ComponentLookup<KinematicCharacterBody> instead and replace SystemAPI calls with that
is using a box collider per tile enough for a ECS voxel engine? It is for a game like v-rising and without colliders i don`t know how to make rival controller collide with chunks
It is for a multiplayer game, i need all colliders spawned
What is the best way?
Hey everyone. A question to folks who have more experience with DOTS than me. When do I use managed systems, and when do I use unmanaged?
use unmanaged whenever possible and unmanaged when you must interact with managed objects/APIs
wouldn't it make more sense to still make ISystem?
make ISystem what?
if you can restrict it to not interfere with the update, sure
why can't I use managed in update?
if you don't use burst isystem is usually slower to update, also i spent christmas debugging corruptions caused by using an isystem with managed code
so, it's better to use SystemBase if it's not bursted?
quite odd
obviously you should aim to make everything bursted
can't make Animator bursted π
or can you?!
well, much of the animator is just wrapping native calls so i expect it'd be quite possible to call it from burst if you really tried (not in a job)
not that i would suggest doing this, just wait for a new animation system, way too much effort
it's 2d too π
so not only I'd have to wait for animation package, but also for 2d support
i'll be honest, i know nothing about 2d animation requirements
i'm surprised the animator is even used though?
Just don't animate anything
ezpz
Since I have 0$ graphics budget I just use a really simple state machine for sprite animations
epic
0x00007FFC8082B20D (RecastNavigation) [I:\Documents\BovineLabs\com.bovinelabs.shattered\Packages\com.bovinelabs.navigation\RecastNavigation~\Navigation.cpp:250] NavMeshGetTileRefAt
0x00000252EA090876 (Mono JIT Code) (wrapper managed-to-native) BovineLabs.Recast.Interlop.Detour:NavMeshGetTileRefAt (BovineLabs.Recast.Interlop.DTNavMesh,int,int,int)
0x00000252EA090663 (Mono JIT Code) [I:\Documents\BovineLabs\com.bovinelabs.shattered\Packages\com.bovinelabs.navigation\BovineLabs.Recast\Interlop\DTNavMesh.cs:74] BovineLabs.Recast.Interlop.DTNavMesh:GetTileRefAt (int,int,int) ```
i write 2 lines of c++
and i crash my game π
That's what you get for being unfaithful to C#
C# is a vengeful mistress, for she was created by Microsoft
Can confirm, I tried coding something in Java once and instantly my bathroom exploded.
(May or may not be a true story)
That's why you go Java->C#
Java doesn't give a shit what you do when you're done with it.
animator can be used for anything that needs smth changed over time
if you do it with playables you have built in support for netcode
Is that the animations stuff in netcode?
playables has been a unity thing for ages https://docs.unity3d.com/Manual/Playables.html
think timeline
netcodes new hybrid / presentation system supports this
I meant is that what the animation namespace in netcode is for
I was wondering, since there is no dots animation system yet
Or is that just unused code
Also is there any documentation on this? I can't find a thing
oh yeah
they have a kind of hybrid animations system
completely undocumented
add a
GhostPresentationGameObjectAuthoring script
and then a GhostAnimationController
and you have a networked hybrid entities animation solution
is there same but for single player?
their implementation is very similar to how my old hybrid implementation worked
except they added a layer of netcode for prediction etc via custom playable nodes
How does it work / what does it even do?
let's you animate via an animator / playable graph with netcode prediction support
is there an equivalent EndSimulationEntityCommandBufferSystem for baking systems?
there are no command buffer systems setup in baking world
you could setup one but probably advised to just complete and playback on the spot
also for animation ive been spending a lot of time with bendzae's simple dots animation repo, id recommend it if you didnt want to use kinemation
(although its 3d only)
it still doesn't support blending right?
ive added it and rootmotion support on my own fork
tbh rootmotion was kind of breaking my brain, and no guarentees to how good/perfect my implementations of either rootmotion calc or blending is, but it works
also https://github.com/thelebaron/unity-dots-animation/tree/blending without the rootmotion stuff
i thought this was mostly avoided these days for inverse techniques like motion matching
because root motion usually feels awful
well im fairly certain id have no idea how to do motion matching π₯²
sadly same
i'm really hoping unitys new animation system isn't just a rewrite
and is a whole new modern implementation of animation
but i fear it'll just be another blend / state machine implementation
(it's fine if that side is also included but i want more)
did you look at the old com.unity.animation package?
it had a burstable timeline implementation!
latios is too hard for me to debug to use it
the dataflowgraph setup seemed very different from what exists for mecanim but i havent really used playable graphs to tell if its that different
i think dfg was flawed
and probably led to the whole thing being rewritten
(not the concept, the implementation)
how so? i did see right before they announced 0.5 stuff it was rewritten fully bursted
impression was first release was like conversion, second that we havent seen maybe refined like baking? wild guess though
didn't know they had rewritten it bursted
so that'd be the first step to fixing it
good
TemporaryBakingType can be used with buffers right?
yeah
@signal phoenix Does your character controller allow for the case where characters can push dynamic bodies but not get pushed by them? Does that even make sense?
isn't that just a kinematic?
In the case where the pushed dynamic object can no longer be pushed, like against a corner, the player character should also stop like a dynamic object. Otherwise, it should act as a kinematic object.
My understanding of physics engines can't see a way this is possible. Maybe a smaller dynamic body within a kinematic body that detects if the kinematic is overlapping a dynamic body, in the case where an opposing dynamic can no longer be pushed, overrides positional data of the complete character. But the issue then arises in cases where two characters collide.
Rival prevents a kinematic object from phasing through walls and other characters on collision and also prevents characters from being pushed, which is good. But what happens when a Character - Dynamic - Character interaction, where two character controllers sandwich a dynamic rigidbody between the two and one attempts to push against the dynamic body.
I haven't tried rival but this behavior worked fine in the unity physics character controller sample if I recall
And works fine on our controller at work on legacy physics
Yea, Im trying to see if rival supports it
is it even worth scheduling a job only to complete it immediately after scheduling vs running it in an isystem?
(in the case of using ecbs/playback)
only if you want to thread it I guess
Alright, testing shows that it does work with a C - D - C format. Just that the characters need to have the physics body set to collide. If the characters should be pushed, the body needs to be set as "None" or "Raise Trigger Events"
This is great. Now I'm gonna have to figure out how to implement a 2D top down format.
There's usually run() for this
To avoid scheduling
yeah I figured as much. actually having difficulty finding where baking shows up when profiling the editor
If it's baking usually you can just systemapi query
You can definitely profile it in editor though
But I think it has to be on an open subscene so it's the main process running it
ahh open the subscene
Closed subscenes bake in a separate process
I usually just turn on editor profiler
Open subscene
Soon as lock disappears pause profiler
Okay, a bit more experimenting with rivals. A character with dynamic physics enabled, physics set to collide, and an infinite mass results in a body that can push dynamics against walls and not through them but not be pushed by them or other characters. Exactly what I want. Now for more testing to see if this set of probably unintended settings causes physics to explode
The main issue I'm seeing right now, dont know if it's resulting from this set of parameters, is that dynamic rigidbody movement (not characters) are very poorly interpolated.
Oh wait, might be because physics baking is broken. Thanks unity.
(just saw your new reply above, but answering anyway)
I think this would be possible:
Make sure SimulatedDynamic is enabled on your character. Then, in your character aspect, customize the OverrideDynamicHitMasses callback so that the character has a characterMass.InverseMass of 0f (infinite mass). The Basic sample character does something similar in its BasicCharacterAspect.OverrideDynamicHitMasses in order to make the vehicle act like it has an infinite mass for pushing the character.
However, with that change, your character will now be pushing things without slowing down at all. If you want pushing to still take masses into account, there might be a way to calculate new InverseMasses for both the character and the other object in OverrideDynamicHitMasses in a way where if the relative velocity between the two would be pushing against the character, the character would be given an infinite mass, but if not, the regular mass ratio would be kept (we'd have to try it in practice, I've never actually tried it)
Huh, havent thought about slowing the char down when pushing. I will need to experiment more with this but once I've implemented a 2d char controller as I think rival is the way forward.
I finally found some time and got my nav mesh streaming to clients
i should have recorded this in higher resolution
Very cool
I fear I'll have to switch to a navmesh approach someday too
Grids are really annoying in a number of situations
wondering is there anyway to make sure an IJobEntity is finished running?
Complete()
ah thanks!
where would i find this?
jobs return a jobhandle
by default this can be hidden for ijobentity
but if you do like
state.dependency = yourjob.schedule(state.dependency)
then call state.dependency.complete()
it'll stall mainthread until that job is complete
ok thanks a ton!
ideally you avoid this as it's not good for performance but sometimes it's necessary
How bad for performance is it, as i have about 10 of a certain type of component, and every now and again it needs to grab these components and use them immediately, but these components never change, so should i instead just store this list of components on a singleton component? (and note i only need to read the component data which should never change)
Profile it but I dont think it'll be that bad. Consider using a blob asset if it doesnt change.
hard to tell. what's bad about it is no further jobs get scheduled.
fascinating, ill definitely profile it, and mess around with it, thanks for the info yall
Do you take suggestions to edit your samples?
For one, in BakedSubSceneReferencePropertyDrawer, I would replace
var sceneField = new PropertyField(property.FindPropertyRelative("SceneAsset"), property.name);
with var sceneField = new PropertyField(property.FindPropertyRelative(nameof(BakedSubSceneReference.SceneAsset)));
which allows for editor side validation of inspector registration. In case someone wants to edit the name of "SceneAsset" and not wonder why the inspector suddenly broke from the renaming.
In fact, I would replace the entire override with: csharp #if UNITY_EDITOR [CustomPropertyDrawer(typeof(BakedSubSceneReference))] public class BakedSubSceneReferencePropertyDrawer : PropertyDrawer { public override VisualElement CreatePropertyGUI(SerializedProperty property) { return new PropertyField(property.FindPropertyRelative(nameof(BakedSubSceneReference.SceneAsset))); } } #endif
wondering how i would make an entity the child of another, guessing using state.EntityManager.GetBuffer<Child>(SomeParentEntity).Add(???), although i cannot workout what to replace the question marks with?
i think you just add a Parent component to the child with the parent entity in the field
oh ok, thanks a ton!
(i don't do much in the way of hierarchies though)
oh nice query builder has AddAdditionalQuery
What's a use case for that?
you've always been able to combine multiple queries into 1
new EntityQueryDesc { All, Any, None etc },
new EntityQueryDesc { All, Any, None etc }
);```
Just an easier way to append components of an existing query onto a new query?
how you would classically do it
this query would return entities from either subquery
.WithAll<NavMeshSurface>().WithNone<WorldReference>()
.AddAdditionalQuery()
.WithAll<WorldReference>().WithNone<NavMeshSurface>()
.Build();```
i'm using it like this
the old state.GetEntityQuery( isn't burst compatible because it takes params/array
Oh, a union query rather than intersection if the WithAlls were merged.
Interesting, let me see if that's relevant for anything I'm doing. I can see how that's useful
it's somewhat of a niche feature that has existed for a long time
but it's useful when you need it
I swear I wanted to do something along those lines, a union query, but I managed to implement the system using a classic intersection with a roundabout way of component querying.
But I cant find it anymore, oh well. Good to know it exists.
im getting this error, but i swear im initializing the random struct correctly: ```cs
[BurstCompile]
public void OnStartRunning(ref SystemState state)
{
ref ChunkMaster MapInfo = ref SystemAPI.GetSingletonRW<ChunkMaster>().ValueRW; // ChunkMaster is my component that contains the random struct aswell as a few other bits and pieces for generating the map
MapInfo.Seed = (uint)UnityEngine.Random.Range(0, MapInfo.MaxSeed);
MapInfo.RandStruct = new Unity.Mathematics.Random(MapInfo.Seed);
}
ah, ill just unburst that function for now then...
oh wait
thats not even your error
your error is you're passing 0 to mathetmatics random
you cant use a 0 seed
.Range(1, MapInfo.MaxSeed);
should be that at minimum
but this also implies your MaxSeed is likely 0 atm
oh ok thanks a ton!
RandStruct = Random.CreateFromIndex(MapInfo.Seed)
it works for 0 to uint.maxvalue-1
ok ill use that thanks
still getting the error, and MaxSeed is definitely not 0
hmm it seems that seed is always set to 0, weird
by manually changing the rand struct's state to 1 it gets rid of the error message, how odd
(i still dont think yo ucan use Unityengine random in burst)
i removed the burst compile attribute, that should be right, right?
yeah so im wondering if you're using this MapInfo rand struct somewhere
and this onstart method is just never called to set it up
no, as the error only occurs during chunk generation, which i have setup to only run when the player moves, the error only pops up then
any ideas why OnStartRunning() aint getting ran?
ISystem
yeah on start running isn't called unless you also implement ISystemStartStop