#archived-dots

1 messages ยท Page 283 of 1

misty wedge
#

I think IL2CPP builds are broken atm

#

not 100% sure if it's been fixed yet though

pulsar jay
#

is there a good way to extend math? Would like to add a projectOnPlane method and unsure where to put it ๐Ÿค”

drowsy pagoda
#

When it comes to using CollisionFilter.[BelongsTo, CollidesWith] filtering, is there a way to use your custom labels in Physics Category Names asset in code as well? Or do we gotta make constants separately as well?

solemn hollow
#

@drowsy pagoda public PhysicsCategoryTags layerMask;

drowsy pagoda
#

Oh didn't realize there was a Unity.Physics.Hybrid assembly.

rustic rain
#

ITriggerEventsJob and ICollisionEventsJob

safe lintel
#

@pulsar jay I just made my own math package for commonly used burstable stuff like that.

devout prairie
rustic rain
#

No

#

Schedule it in void update

#

Also you need to call some method in onstart

#

I suggest you to look up page in manual that mentions those interfaces

late mural
#

can i call methods in a system base from a monobehaviour, and how badly will it negatively affect performance?

rustic rain
#

it does not affect perfomance

#

it's literally same code execution

late mural
#

ok good!

#

thanks so much!

#

can i just use public voids, or do they need the fancy override and protected stuff?

#

in the system base that is

rustic rain
#

public, protected only matters for code style imo

#

during runtime there is no difference between private or public

#

that's how hacky publicizers work

#

it's basically just IDE restriction

late mural
#

woah ok cool, thanks so much!

#

huh just learnt something new, apparrently OnUpdate() is required for a system to work, or else unity throws a tantrum

#

ok!

#

i believe that perhaps this is a bit offtopic, i already got muted a few days ago, otherwise i would continue this conversation

#

lol

#

wondering, from a performance perspective, how big of a difference does using mathematics random vs using unity engine random have?

rustic rain
#

math's random is umanaged and is literally just value

late mural
#

aha, that doesnt mean a lot to me im afraid, guessing it means that neither of them really are better in terms of performance?

rustic rain
#

math one is literally just uint

#

what is most important

#

it's burstable

late mural
#

oh ok i get it then, so it would be more performent if the random is being used in burst then!

#

so like in entity for each situations and stuff it would be better to use the math one then

#

ok, imma try burst compile it then, this sounds like it could be fun and performant, ive never done burst with a regular for loop before lol, this shall be fun!

rustic rain
#

everything else doesn't matter much until you have like thousands random iterations per frame

late mural
#

also making certain im going about this the right way, so im using a for loop to istantiate an object using an entity buffer thingy however many times is needed, this is a good way right? making certain that there aren't any specially designed for loops for istantiating or anything

rustic rain
#

Hmm

#

if I remove singleton component

#

and then add it on other entity

#

on same frame

#

will OnStartRunning trigger?

rotund token
#

OnStartRunning is pretty simple

#

if (!DidRunLastFrame() && RunThisFrame()) OnStartRunning()

rustic rain
#

I guess it won't

#

hmm

#

not fun

rustic rain
#

it seems like you instantiate random with same state

#

every time

#

why not just store random on entity?

#

and instantiate from index or smth else

late mural
#

wondering, how do you burst compile for loops, or is this not possible?

solemn hollow
#

you need to use for and not foreach if that is your question

rotund token
#

are you passing in a Random into the entities.foreach?

#

because each thread will get the same random with the same seed

#

and therefore generate the same values

devout prairie
#

Solution - create an array of randoms, one for each possible thread, each with a different seed:

#

Then inside your job, access by thread index:

uncut rover
rotund token
#

personally i usually just pass in a seed, say from UnityEngine.Random.Next(0, int.maxValue) or just a time value etc

#

then add the entityInQueryIndex to it

#

var random = Random.CreateFromIndex((uint)(seed + entityInQueryIndex));

#

better yet if using a IJobEntityBatch just use the batch index etc

uncut rover
#

but it's non deterministic or is the batch index or entity query index guaranteed to be the same for each execution (start/stop playing) ?

rotund token
#

that is completely deterministic

#

(not that I care)

#

but you will always have the same entityInQueryIndex every frame until a structural change occurs

solemn hollow
#

i think he meant deterministic between play sessions. i am not sure it is

rotund token
#

entities is deterministic

#

it will be the same every play session in a fixed update

#

if you create 1million entities the same way, it'll be layed out the same

#

and they'll have the same entityInQueryIndex

#

parallel containers are the thing that usually break determinism (or non fixed step)

solemn hollow
#

havent thought about determinism too much and am just wondering

rotund token
#

nativehashmap.parallel containers isn't determinstic for example

#

two thread writing will be non-determinstic who gets to write

#

multi is worse because it'll write in different orders

#

sometimes X will come before Y, other times Y before X
this can matter when you're iterating back

uncut rover
#

it feels weird because it ties the behaviour to what happens to entities. let say that base on the random value your entity does something. now the entity does the same thing every frame. If another entity is destroyed, you'll have a structural change and you entity that executed the same behaviour every frame will suddenly change behaviour even though nothing happened to it. So while it's deterministic if the things that happens to the other entities always happens in the same order and at the same time, it still feels like a bad idea to tie the behaviour to the entity layout in emmory.

solemn hollow
#

oh right. can you read the value in the parallel hashmap before overwriting it in from another thread? probably not right?

rotund token
#

let say that base on the random value your entity does something. now the entity does the same thing every frame.
it doesn't do the same thing every frame

#

you generate a new seed every frame

#

if you want it deterministic, just get an original seed and give it +1 every frame (actually +1 isn't great it'd just shift behaviour, something like ^ 317)

#

if you don't care like me, you just generat a new random one

rotund token
devout prairie
solemn hollow
rotund token
solemn hollow
#

wow i thought thats only checking if the same thread already added

rotund token
#

that wouldn't be a very good hashmap

solemn hollow
#

so if id want to sum up all damagevalues for a targetentity i could do this in a parallel hashmap and still have determinism?

rotund token
#

i can't visualize what you're suggesting

#

oh you mean add all values to a multi hash map

#

from different threads

#

then iterate and add?

solemn hollow
#

yes

rotund token
#

well yeah that should still be deterministic

#

as long as they're not floats*

solemn hollow
#

hmm thats very good to know.

gusty comet
#

Whats the current state of 2d support for DOTS stuff? Still nothing yet?

karmic basin
#

Yeah I think it travelled to another plane of existence

gusty comet
#

huh?

hot basin
#

and nothing probably will be

frosty siren
#

should i mark regular blit-type fields with [NoAlias] attribute? Can it be even referenced to the same memory? I mean in tutorials examples always about native containers

for example i have such struct

internal struct RenderArchetypeForSorting
{         
  public int id;
  public int archetypeIndex;
  public int stride;
  public int count;
}
rustic rain
#

allthough

#

it's not hard to achieve 2D state in physics

#

but that would be 2D for the price of 3D anyway

gusty comet
#

In the end I went with monogame since at that point unity lost its benefits.

rustic rain
#

I currently have rewritten 1 project 3 times already xD

#

first it was pure ECS, then I rewrote it into OOP, then I rewrote it back into ECS and now I'm rewriting it into managed ECS monstrocity

gusty comet
#

That is a huge gripe of mine the whole conversion workflow was unity chickening out. I hope really that recent jumps in tech from unreal spurs unity back into action.

rustic rain
#

2D is as dead as it used to be

#

but

#

once again, nothing stops you from doing it anyway

#

hybrid works fine with sprite renderers

#

physics also works fine with a couple of custom constraints

#

if you'll manage to keep it fully ECS - it'll be a scalable solution

gusty comet
#

My issue is that I can just use any ECS framework in monogame and have less overhead. I am still waiting for proper editor integration. But I am an odd guy anyway since our team so far tried half a dozen time and invested over a hundred hours of resarch and so far we never could find a way to properly scale a project to the levels necessary for production in unity and its mightily frustrating.

#

And that is a team that has shipped games before to be clear.

rustic rain
#

nothing stops you from doing monogame ECS

#

kek

#

that's what I do rn

gusty comet
#

That is my point. I am seeing no real benefit in unitys way of doing it.

solemn hollow
#

what is the bottleneck you cant solve?

rustic rain
#

game objects keep only data, I query over them through entities system

gusty comet
# solemn hollow what is the bottleneck you cant solve?

Its no bottleneck per se. We use ECS a lot since its a paradigm that we like to use since it favors composition and the easy segregation of logic and data, and solving a lot of the headaches that stem from OOP approaches. The bottlenecks if you will we run into is that we fail to understand what the expected workflow within unitys ecosystem is when you scale up a project.

We know that great games of high complexity are made in unity and shipped and were quite successful (hollow knight being a prominent example) but we found that as soon as we scale any unity project to the level needed for a more complex game it either ended up with us using unity only as a render layer and not using the editor at all which can not be the expected workflow.

Hotwiring references in the editor is just not maintainable. But once you abstract everything down into regular c# classes you are basically leaving the editor realm.

#

We know of the event system and such but again, the editor representation makes it practically useless for designers. So its either designers or programmers are "locked out"

#

Issues we do not run in elsewhere and we just fail to comprehend.

#

And in the dots realm specifically the issue is even exaggerated.

solemn hollow
#

i dont think hollow knight had any scaling problems. there isnt much going on at the same time. they even used alot of visualscripting and stuff.

rustic rain
#

well, Unity offers quite an interesting way of conversion that lets you use all editor instruments

solemn hollow
#

so you have good editing performance and optimized runtime

gusty comet
rustic rain
#

any specific example?

solemn hollow
#

ah i got u. yes its kinda hard to keep a clean project when it comes to having 100s of prefabs.

#

not sure how other editors to it better though?

gusty comet
#

Is not one big thing but many small things. Interface representation on the editor side, segregated testing is another big thing.

#

To give an example we used Godot where you can test every scene (equivalent to a gameobject in unity) in isolation.

#

To get the same behaviour in unity you need to do a lot of mocking

#

Generally dealing with dependencies is a nightmare in unity.

#

As I said earlier I am not faulting the engine per se. I just think we do not understand what workflow the engine expects. And when you look up about how to scale game architecture in unity or anything remotely similar all you get is silly things like folder structure

#

Which is utterly irrelevant to the topic.

#

We had even less trouble with that kind of thing in unreal engine which is surprising.

#

The thing is we also do work with third parties at time so we always touch unity at least tangentially every now and then and would love to better understand the whole engine and ecosystem because of that.

#

I am admittedly only a beginner to intermediate programmer at best, but even the more tech savy in our team struggle with it and raise those issues.

solemn hollow
#

Yes it needs some experience with Unity to get a good workflow going. All those problems you are having do have pretty clean solutions though.

solemn hollow
gusty comet
#

The point is when you do that you loose any editor side references of it.

solemn hollow
#

Sry still having trouble understanding the exact problem. i always build prefabs in a way i can just drop them in any scene and they work. im not sure what you mean with hotwire

gusty comet
#

As said we hardly use the editor since most of the games we make are procedually generated.

#

Which most of the time means we have to write our own editor tools, but that is manhour cost asside not a major issue.

rustic rain
#

get entity query of player and then extract to native array

#

then just grab it, array will be size of 1

solemn hollow
#

why not use getsingleton?

rustic rain
solemn hollow
#

huh maybe. i stopped using any monobehaviour logic. not sure how i solved it earlier

#

im using tertles EventSytem to get my data to MonoBehaviours

#

only UI actually

rustic rain
#

btw, any idea how unique world is handled? Is it even possible?
I want to have 1 world with 1 set of systems and other with other

rustic rain
#

hmmm

#

is it possible to grab a reference of world in conversion system?

#

ah, nvm
Sounds like a terrible idea anyway

safe lintel
#

@gusty comet also see pinned messages here

rustic rain
#

something that makes OOP look like garbage xD

gusty comet
#

OOP aka the trillion dollar disaster

rustic rain
#

Hmmm
Any idea how would this problem solved in ECS design?

I have objects that are out of camera bounds, but they constantly get closer. There will be some kind of UI element that will show how far this object from camera bounds. And once it reached camera sight - remove that UI element.

#

in my old code I would just register/deregister those objects upon instantiation

#

in ECS that would be spaghetti

gusty comet
#

No need for spaghetti there. At most you have to split this up into several smaller systems.

#

Generally spaghetti is almost impossible to create if you reason your systems properly.

hot basin
#

could batchIndex from IJobEntityBatchWithIndex be used as a sortKey in:

#

?

rustic rain
#

uugh
First and worst idea that comes to mind:
tag those objects if they don't have a tag yet and register them. Each tagged will be checked for distance to camera. Once it reaches add another tag, and deregister.

hot basin
rustic rain
#

ah nvm

#

should work as sort key I think

gusty comet
#

You can use tags, but I rather would use a component that stores the distance to the camera bounds since you already calculate that anyway and only tag those that qualify to minimize the amount of cache misses that occur due to archetype changes.

hot basin
#

should I mark public EntityCommandBuffer.ParallelWriter commandBuffer; with [WriteOnly]?

gusty comet
#

tags are nice and "free" but as far as I know they still change the archetype.

#

And lead to the aforementioned cache misses.

rustic rain
#

yeah

#

it's 2 more archetypes at very least

#

I don't really get your solution though

gusty comet
#

thats why I would those that have to use your system give them a component outright that stores the distance to camera.

#

You have one system that calculates the distance to camera bounds. Then given you know who qualifies to get the UI element you have to just iterate over that smaller list that qualifies, to avoid iterating for irrelevant entities.

#

So unless your objects are part of the level geometry and have no other data to them, this should work.

rustic rain
#

oof

#

actually

#

I forgot that I can literally store class on entity

hot basin
#

is there readonly verion of GetEntityTypeHandle() or it's already readonly?

rustic rain
#

it's in parameter

#

bool

hot basin
#

it don't have parameter

solemn hollow
#

its readonly

rustic rain
#

oh

#

entity type

#

I didn't notice

hot basin
#

yeah

#

what is the easiest way to setup blob asset reference?

#

Warning: Although there are APIs that you can use to convert GameObjects to Entities at runtime (such as GameObjectConversionUtility), these will be deprecated in the future, because you should never use them in runtime code. They are far, far too slow. As such, you should convert authoring data to runtime data in the Unity Editor during the build process, and Unity should load and use only the runtime data at runtime.

#

so proper way to do this is IConvertGameObjectToEntity or GameObjectConversionSystem?

frosty siren
viral sonnet
drowsy pagoda
#

Are there performance boosts for using GetComponentDataFromEntity<T>(readOnly: true); ...WithReadOnly(componentDataFromEntity); vs SystemBase.GetComponent<T> & SystemBase.HasComponent<T>?

rotund token
#

are you talking within a entities.foreach?

#

because GetComponent HasComponent uses ComponentDataFromEntity

safe lintel
#

should be the same thing

#

unless you run the job

drowsy pagoda
safe lintel
#

yea

drowsy pagoda
#

And why does it make a difference on main vs background?

rotund token
#

GetComponent/HasComponent uses EntityManager on main thread

drowsy pagoda
#

Ah. Interesting. Thanks

viral sonnet
#

trying to burst compile OnUpdate in ISystem and getting this error ```Burst error BC1091: External and internal calls are not allowed inside static constructors: Unity.Collections.LowLevel.Unsafe.UnsafeUtility.Malloc(long size, int alignment, Unity.Collections.Allocator allocator)

#

one for Malloc and one for Free. the job burst compiles fine. If I comment out the schedule of this job the OnUpdate also burst compiles. I don't get what this error means

#

also not using anything static

rotund token
#

i have no issues with my malloc

#

this.count = (int*)Memory.Unmanaged.Allocate(UnsafeUtility.SizeOf<int>(), UnsafeUtility.AlignOf<int>(), allocator);

#

i've transitioned a lot over to Unity's Memory struct now though

#

var ptr = (Ptr)UnsafeUtility.Malloc(this.countPerSlab * UnsafeUtility.SizeOf<T>(), UnsafeUtility.AlignOf<T>(), this.allocator);
actually no I still use Malloc in places

#

and it's running fine

#

(but i'm going to switch that over now that I've noticed it)

#

but under the hood this just uses UnsafeUtility.Malloc

#

just does things like ensure alignment to cache lines etc

viral sonnet
#

not using any malloc ๐Ÿ˜„

#

it's weird man!

#

and shouldn't ArchetypeChunk.DidOrderChange return true for a totally new chunk? not getting any triggers

#

this should be correct, right? version is state.GlobalSystemVersion\

#

ah it's state.LastSystemVersion

rotund token
#

yeah...

#

GlobalSystemVersion is the current version of the world, LastSystemVersion is last time system updated

#

DidXChange basically checks if LastSystemVersion < GlobalSystemVersion (because when changes happens it sets it to GlobalSystemVersion)

#

if you pass in global, never going to change ๐Ÿ˜„

viral sonnet
#

yeah ๐Ÿ˜„ dumb mistake, working fine now

#

can you show me how you show pointers in the inspector?

rotund token
#

i just implemented a Inspector<T>

#

custom inspectors for my components

viral sonnet
#

ok, must be quite similar to the, what was it called, nativedebug something that we tried for the hashmap?

rotund token
#

not really?

#

Inspector<T> is just how you draw custom inspectors for components

#

you can write custom inspectors for anything in entities using it

#
{
    var root = new VisualElement();

    var type = new IntegerField("Type") { value = Target.Effect->Type };
    var modifierType = new EnumField("Stat Modify Type", Target.Effect->ModifyType);
    var value = new IntegerField("Value") { value = Target.Effect->Value.Short };

    root.Add(type);
    root.Add(modifierType);
    root.Add(value);

    return root;
}```
#

is the gist of it

#

mines a bit more complex that due to union

#

and I added an Update to update values on change since i can't seem to do it via bindings (property bindings don't seem to work with Inspector)

viral sonnet
#

thanks, this helped. Is there a Field for Entities? It's not called EntityField

#

was this added with UIElements? This seems much nicer than the CustomEditor that I've used previously

#

didn't even know Inspector<T> exists ๐Ÿ˜„

#

oh damn, this works flawless. thanks again

rotund token
#

you can just use default bindings for fields you don't want to custom draw
this.DoDefaultGui(root, "Type");

#

note if you don't use ui element bindings the values won't update unless you manually check for changes in Update

rotund token
viral sonnet
#

there actually is EntityField in Unity.Entities.Editor.Inspectors.

#

of course it's internal haha

rotund token
#

DoDefaultGui(root, "NameOfEntityField");

#

will just render it with how it would be rendered by default

viral sonnet
#

and that works behind a pointer?

rotund token
#

oh no

#

you have an entity stored in your pointer?

viral sonnet
#

yeah, for another inspector I'm also adding

#

asmref trick it is

rotund token
#
    where T : unmanaged
{
    [NativeDisableUnsafePtrRestriction]
    private UnsafePoolAllocator<T>* pools;

public unsafe struct UnsafePoolAllocator<T> : IDisposable
    where T : unmanaged
{
    private UnsafeSlabAllocator<T> slabAllocator;
    private UnsafeParallelHashSet<Ptr> free;

public unsafe struct UnsafeSlabAllocator<T> : IDisposable
    where T : unmanaged
{
    private UnsafeListPtr<Ptr> slabs;
    
public readonly unsafe struct Ptr : IEquatable<Ptr>
{
    public readonly void* Value;```
Burst is going to love this >_>
viral sonnet
#

I see what you are going for ๐Ÿ˜„

#

wait, how did this work? my editor scripts can't access my main script types

rotund token
#

you mean the inspector?

viral sonnet
#

yep

rotund token
#

are they private

viral sonnet
#

no, the main structs are in NZSpellCasting, the editor script in NZSpellCasting.Editor. I've tried 2 folders now for the editor script but they can't see the main structs

rotund token
#

have you a reference to your NZSpellCasting in the NZSpellCasting.Editor asmdef?

#

(not sure what folders have to do with this at all)

viral sonnet
#

yeah me neither, just trying things. I'll setup an asmdef. usually I don't need to make one. hm

rotund token
#

oh...

#

you're using the old Editor folder aren't you

#

forgot that was even a thing

viral sonnet
#

yeah, oh is there also a new way?

rotund token
#

yeah asmdef

viral sonnet
#

ok, yeah setting that up right now.

#

can you show me which references you are using on your asmdef?

rotund token
#

i'm just using unity and my own libraries

#

after my ocd kicked in

#

just make it an editor only assembly

viral sonnet
#

thank you

viral sonnet
#

how do asmdef and asmref work together? i have the asmdefs for my main plugin and editor now working but now I'm stuck on making the internals visible to the editor asmdef

rotund token
#

asmref target an asmdef

#

and let's you add code to it

#

that's all

#

the now popular trick I cam up with was to inject an AssemblyInfo with InternalVisiblesTo into the asmdef so those assemblies could see it

#

you can add as many assemblies into the AssemblyInfo you want

#

personally I only inject 1 assembly in

#

and that assembly provides all the wrapping for internal methods that I need

viral sonnet
#

ok cool that wasn't quite clear to me. i'll play around with it. should be close now

#

wrapper lib sounds cool

rotund token
#

you don't want to inject too many assemblies into a package

#

because i believe it'll cause that package to have to recompile

viral sonnet
#

ok, I'll keep that in mind. got everything working now. took me longer than expected but at least I have asmdefs running now which was already blinking on my todo list ๐Ÿ˜„

devout prairie
#

not possible to inspect System member fields?

rotund token
#

what's stopping you?

devout prairie
#

like how we can see DynamicBuffer values on entities in the inspector

rotund token
#

oh you want a system inspector?

#

there's nothing written for that

#

usually you'd just break point

devout prairie
#

yeah it'd be useful

rotund token
#

that is definitely behaviour i have never considered

#

not sure if i would even use it tbh

devout prairie
#

if i click a system in the Systems inspector, it shows queries, but not data/members

rotund token
#

i don't really store state in my systems

devout prairie
#

yeah basically i have some nativearrays on my system

#

was naively hoping i could just inspect them ๐Ÿ˜›

rotund token
#

store it on an entity

#

and write a simple inspector for native array

devout prairie
#

it's not a big deal really, would be a nice to have

rotund token
#

i would not expect it to even be on a roadmap

#

but hey, never know

devout prairie
#

i wonder if there's any disadvantage to having persistent nativearrays on systems

viral sonnet
rotund token
#

i don't have many persistent native arrays but i have plenty of persistent native lists i use as variable size ararys i dont need to allocate

rotund token
#

for the most part my systems are stateless

#

i don't share any native containers between systems

viral sonnet
#

i have lots of, just sharing from one system

#

many hashmaps ๐Ÿ˜„

rotund token
#

the only thing i could think of that stores state in a system

#

is my navmesh

#

but even that is actually stored on a component as well

#

so other systems can query it

viral sonnet
#

well, state is the wrong word. i have acceleration structs

devout prairie
#

tbh it's just some data i'm creating during conversion, which could probably live in a blob asset as it's unchanging, but just for simplicity and ease i'm storing it as nativearrays on the system that actually uses the data

rotund token
#

i enjoy being a purist
data goes into system
system does work on data
data goes out of system

#

i just like how it makes my application feel

#

i code much more for writing elegant software architecture than developing games

viral sonnet
#

huh, where would you store a hashmap then?

rotund token
#

what do you mean?

#

any hashmap i create is used only during that update

#

i might store the hashmap in a system to avoid re-allocations

#

but the data is invalid as soon as the system is finished updating

viral sonnet
#

ok so same is me really ๐Ÿ™‚

#

I also never considered looking at any of those containers in the inspector. never even debugged them. but it would be a nice feature tbh

rotund token
#

i am saying there's no value in having this debuggable in inspector

#

and if the feature existed i wouldn't complain

#

i had just never considered it

#

if i'm debugging something like that, i really just want to break point and delve deep

devout prairie
#

basically just wanted to double check my values were in the correct order

#

i rarely use break points tbh!

#

being able to inspect dynamicbuffers is really nice

#

apparently the brain uses 20% of your bodies energy

#

interesting lex fridman podcast with AI dev working on deep mind etc

viral sonnet
#

my sugar intake agrees

devout prairie
#

apparently he started out in games, and worked on Theme Park, anybody remember that gem of a game

#

first computer was a speccy ๐Ÿ˜›

viral sonnet
#

yeah from bullfrog. what's his name?

devout prairie
#

Demis Hassabis

viral sonnet
#

thanks

#

I'm actually quite torn of not going more into AI/ML. It's much more satisfying than any game dev I must confess

#

really the only thing I can get out of gamedev is, ok this runs really fast ๐Ÿ˜„

devout prairie
#

Yeah tbh i've never dabbled in ML at all although i've wanted to try Unity's training thing

viral sonnet
#

I'm sooo over this whooa state

#

an ML has this. I've done very little in ML, recognizing a picture taken via camera inside a big database

#

but that was quite the journey

devout prairie
#

there was a really good video of a guy using unity's tools to train an AI car to park into a space, really funny and entertaining to watch

#

Around 300k attempts and the car finally learns to park

#

Bit like my wife

viral sonnet
#

what's quite scary about ML is that training of anything is absurd in terms of resources and time. after that's finished, the model you get out of it is really just a small bunch of (random to us) data and it's so damn powerful. exactly this model data will be the new goldmines of the next few generations and only big data is really capable of producing it. unless we find a way to actually make networked computing make sense for everyone

dreamy glade
#

In Unity Jobs System, these made-from-scratch chunks of voxels are being 'jobbified' on the Z axis. The 20x20x20 chunks seem to stop generating perlin noise after the 12th row- which is exactly how many logical processors / threads I have in my PC. Coincidence? I think not! I'd love if someone can explain how I can ensure all jobs are complete.

late mural
#

bit late of a reply, but only now do i really have a logical answer lol, turns out that cause only 1 thing will move at a time, and it only syncs positions of things that have moved, then it shouldn't need it hopefully

late mural
#

is it normal to have this many things that unity thinks are potential job leaks?

rotund token
#

normal would be 0

late mural
#

oh

#

is there any good way of making it become 0 then?

rotund token
#

stop leaking native memory

#

turn on your leak detection so you can see what you're leaking

late mural
#

oh ok, ill try that and report back!

late mural
#

it also has massively increased performance somehow!

rotund token
#

ah thats' the opposite of what should happen

late mural
#

exactly, it is kinda worrying that it has done that

#

but hey, atleast good performance exists now

#

went from a situation where i would get 20 fps, to getting 60 fps in that situation

rotund token
#

also full stack trace should dramaticly lower your fps

late mural
#

oh i have not enabled full stack traces, should i try it?

rotund token
#

are you using netcode

#

or ecb in fixed update

late mural
#

i do not think so?

#

im instantiating a bunch of stuff, destroying a bunch of stuff, setting a couple transforms, but not much else with dots currently

#

hmm from testing it seems the leaks are just gone, this is weird

#

before i enabled leak detection i would get over 600 leaks every single time, so i guess leak detection somehow has dealt with them

#

welp instead of being worried im just gonna be thankful and hope like anything that this doesnt cause issues in future

late mural
#

how do you convert transform.rotation to euler angles, as i really dont wanna deal with quaternions

#

i realise that was a bit out of context, so specifically im talking about the component value in the local to world component

rustic rain
#

Just learn dealing with quats

#

That would be easier

robust scaffold
#

I just do everything in polar coordinates. No need to care about rotation when everything is perfectly symmetrical. That does mean everything is a sphere but that is a price I am willing to pay.

robust scaffold
rotund token
#

could have the attribute on it

#

(though I'm not a fan of using it for this reason as it's unclear from just looking at it)

robust scaffold
#

Also, does it work for the other containers? The newest 0.50 best practices article recommends using it. Which I thought was odd as I am pretty sure they wanted to get rid of it as it worked only for native arrays.

#

Also oof the reddits are really dooming right now. Dont think DOTS was hit by the layoffs (at least theres no mention of it in any news articles I scanned) but jesus christ has the stock price nosedived this past year. I dont own any stock but that plunge in value is concerning.

rustic rain
#

Any idea whether SubScenes can keep any game object prefabs in them?

#

I want to make this kind of workflow: during conversion initial game object gets modified, stripped of authoring components, maybe added some new. And then it's saved as game object prefab and kept in subscene

#

so later, when you instantiate entity - it will have that prefab reference on managed component

#

and then I can just instantiate it from here

#

Also, does Unity call IDisposable interface when destroying entity?

rustic rain
#

I assume System's Time.DeltaTime is specific to that System?
Meaning FixedStep will have according Delta time or not?

rotund token
#

Time.Delta time is a World value

rustic rain
#

I see

rotund token
#

but system groups can set it

#

hence how fixed update systems work

#

it pushes a time then pops it when it leaves the group

rustic rain
#

I just wonder, whether I should have delta in fixed or just use whatever fixed target delta is meant to be

rotund token
#

be the same

late mural
#

i only want to change 1 axis, i somehow manage to change them all

rustic rain
#

what do you want to do

#

with rotation

late mural
#

let me explain, this might take a bit

rustic rain
#

just tell technical part. You want to rotate object on 1 axis?

late mural
#

yup

rustic rain
#

in what way

late mural
#

basically i have 1 object with a desired rotation on the x axis

#

i have another object that needs to keep the same rotation on the y and z axis, but gain the x axis rotation from the 1st object

#

my first attempt went something like this: ```csharp
var object_rot = whatever_object.rotation

object_rot.x = second_object.rotation.x

whatever_object.rotation = object_rot

#

sadly quaternions do not like that

rustic rain
#

hmm

#

what about second object

rotund token
#

Well yeah x is not Euler x

late mural
rustic rain
#

maybe instead of assigning Euler angles

#

you sohuld just rotate object_rot together with second_object?

late mural
#

how?

rustic rain
#

how is your second object rotation assigned?

late mural
#

rigidBody

#

it is a gear, spun by spheres hitting it

#

that is an entity

rustic rain
#

nope, you can't grab quats from classic physics simulation

#

allthough

#

hmm

late mural
rustic rain
#

you can get angular velocity

#

but I don't think

#

it'll be very precise

late mural
#

there is a simple way

#

i just need to convert the quaternion into a vector 3 with angles, something which in game objects would be using the euler angles thing, sadly entitie's transforms do not have this

rustic rain
#

well, if you want to go this way

#

you need to extract quat into Euler

#

which is quite big tbh

late mural
#

in what way is it big?

#

performance cost?

rustic rain
#

yeah

late mural
#

oh, well that is annoying

#

is there any easy way then that isnt performance heavy

#

as this will run every frame that the rotations are not the same (with a few decimal places of innaccuracy to help aid peformance)

#

is there any way of converting position into degrees instead? as i can track the position of the edge of the gear in order to work out rotation perhaps? Or would that be even worse with performance?

late mural
# rustic rain which is quite big tbh

how much, as this will only happen to 1 object at a time, only when the rotations are not the same, so assuming it isnt too absolutely heavy, it should be fine, i mean so far euler angles on game objects dont seem to be that performance costly with only 1 object

rustic rain
#

sir, just do it if you don't see any other way

late mural
#

i do want to do it, but how, ive googled there is no info anywhere

rustic rain
#

but converting to EUler is somewhat complex either, heh

late mural
#

cant i just copy unity's game object code for it? and then dot-ify it?

rustic rain
#

Quaternion to Euler C++ might have math solution

#

in google

late mural
#

ok ill try that

rustic rain
#

this is how I usually find certain solution to math problems xD

late mural
#

lol

#

wait no i found unity has a simple method that works on any quaternion, as long is it is not on an entity, so all i have to do is move the quaternion from the entity onto a variable, then convert it, laziness triumphs!

rustic rain
#

simply casting to Quaternion might work... or not

#

last time I tried I encountered problems, but that was long time ago

#

I don't remember details

late mural
#

oh well, ill give it a go and see what happens, i just wanna get my water gun working

#

cause it would just be so much simpler if i could just do soemthing like quaternion_1 != quaternion_2 then make it do something, but sadly it is way to precise, if even a single thing is a tiny bit off it counts it as different, hugely affecting frame rate, hence why i have to do this whole nonsense thing of converting it to euler angles in the first place

#

wish we had a way of rounding quaternions, sadly i dont believe that to be possible

rustic rain
#

unless it's a lot of mat

late mural
#

if i dont do math, then everything fails

rustic rain
#

math is like least expensive thing in C#

late mural
#

yup, and i suck at math though lol

rustic rain
#

compared to some managed queries, casts and etc

late mural
#

lol

#

and no matter how hard im googling i cant find a single thing about converting quaternions to euler angles, most just tell you to use some premade library

rustic rain
#

quite exactly the reason I suggest against it, heh

late mural
#

whyyyy does entity transforms not include the same stuff as game object transforms ahhhh

late mural
rustic rain
#

work in quaternions and keep your workflow inside of them

late mural
#

yes, but i dont understand quternions

#

i dont get them, they just dont make sense to me

rustic rain
#

you don't need to understand them

late mural
#

how?

rustic rain
#

they won't

#

xD

late mural
#

what does that mean???

rustic rain
#

you just need to learn how to use them:
multiplication, dot products

#

cross products

#

you don't need nothing else

#

tbh

late mural
#

where can i learn that, cause i dont know anything about any of that, i just wanna rotate 1 object, please some links or anything, ive been working on this one thing for 2 days now!!!

rustic rain
#

just literally google that
quaternion multiplication

#

this exact one

#

is simple

late mural
#

ok im trying that sure

rustic rain
#

when you do quat1 * quat2

#

you rotate quat1 by quat2

late mural
#

unfortunately that is not what i want

rustic rain
#

so if quat1 is 0,0,0 in Euler and quat2 is 0,90,0 in Euler

#

result will be 0, 90, 0

#

order is important

late mural
#

wha, how in any way?

#

that makes no sense to me

rustic rain
#

it's matrix multiplication

late mural
#

?

rustic rain
#

some smart dud came up how to use it for rotations, and invented quaternion

#

heh

#

it should not make sense

#

sir

#

don't try

#

just learn how to use it

#

it's not for humans

#

it's for machines

late mural
#

how do i learn how to use it though, as im finding nothing useful, my googling is not helping me

rustic rain
#

for humans there's Euler representation of any angle

late mural
#

give me some links please to anything that even vaguely might help

rustic rain
#

sir, doubt my links would help. Language issue

#

just look up

#

smt hlike

#

"How to rotate quaternions"

#

in yourtube

#

or smth

late mural
#

tried that, so many times

#

doesnt help

#

you cant seems to be the answer most give, either that OR THEY TELL YOU TO CONVERT IT TO EULER ANGLES, which is a night mare, so im left with no options but to try and understand quaternions, number made for computers, not humans, and there are no tutorials out there, or atleast none that are easy to find!!!!

#

quaternion multiplication: dont know what it is, seems google doesnt either, no tutorials either

#

the only remotely helpful things ive found have been on wikipedia, but barely helpful, mostly written in such a fancy format that makes no sense

rustic rain
#

welp, you can't learn encyclopedia in one day xD

#

multiplication, dot products
cross products

late mural
#

yes, you also cant learn by doing nothing, but nothing exists, so im forced to learn by doing nothing, which aint helping me in any way!

rustic rain
#

those are key, just start with them in order

late mural
rustic rain
#

once you will know what each mean - you won't need anything else imo

late mural
#

still annoying how there is very little info out there, and even the stuff there is, is very vague and unhelpful

#

also multiplication of quaternions and stuff like that does not exist according to multiple search engines

#

yup nothing is popping up anywhere, there is seemingly no knowledge about the multiplication stuff, so im giving up researching about it, pretty sure it does not exist

#

im continuing to research the other 2 things

#

although they dont seem related to quaternions in any way...

#

if anyone is reading this and knows even a tiny bit of knowledge about quaternions, i will take anything, i am desperate

#

sometimes i wish that entities were more similier to game objects, so that i wouldnt have to deal with things like this

rotund token
#

i dont think this has anything to do with entities

#

it's simply you're using an experimental product that isn't complete

late mural
#

i suppose so

rotund token
#

i'm pretty sure you'll get full easy transform support with aspects in 1.0+

late mural
#

oh well, for now im doomed to trying to understand quaternions just so i can rotate 1 entity

#

unity literally has a method to conver euler angles into quaternions, yet no way to do it backwards, apart from that, it seems no one know anything about how on earth you convert from quaternions to euler angles, atleast no one open source...

rotund token
#

there's a method in the physics package that does it

late mural
#

what is it called?

rotund token
#

ToEuler from memory

late mural
#

thank you so much!!!! I have been trying for 2 days, thank you so much, you are awesome!!!!!!!

late mural
#

googling cant find it, dont see it anywhere in the physics manual, and my ide aint auto completeing it

rotund token
#

Unity.Physics.Math.ToEulerAngles

late mural
#

thank you so much!

rotund token
#

you need to learn to search

late mural
#

yes i do

rotund token
#

๐Ÿ˜…

late mural
#

im not good at searching lol, i just dont get it, no matter how many tutorials i watch

late mural
#

my ide is giving me not found errors

rotund token
#

look at my screenshot

#

it's internal

#

you can't access it

#

but it shows you how to do it

#

make your own method from it

late mural
#

i dont quite know what that means

#

but imma assume from what you said that means i have to manually alter the unity physics code then to add it?

rotund token
#

internal means you can't access it outside of the assembly

late mural
#

so i was correct with my interpretation then?

rotund token
#

just copy paste the code into your own library

#

and make your own method

late mural
#

oh ok

#

im not smart, sorry lol

late mural
#

google is not helping me either

#

sorry im really not good at complex stuff like this, you need to explain it step by step, or else i wont understand, im not clever sorry..

#

and no matter what im trying currently, i cant get it to work

#

i just keep getting errors that it cant find it

rotund token
#

i don't get it

#

are you unable to locate the source?

#

your ide should be able to find, and inspect, Math file

#

if not just find it in file explorer

#

and open it in notepad if you have to

#

Library\PackageCache\com.unity.physics@0.51.0-preview.32\Unity.Physics\Base\Math\Math.cs

late mural
#

oh

#

im a bit of an idiot, i thought i did it any file

#

i didnt realise i had to add it to the math file

#

sorry lol

rotund token
#

what

#

no

late mural
#

huh?

#

im so confused

rotund token
#

you need to copy the source code

#

from the physics library

#

and put it in your own method

#

so you can use it

late mural
#

which part of it?

rotund token
#

the method called ToEulerAngles (probably toEuler)

late mural
#

oh ok, ill go search for it and see if i can find it

late mural
#

ok woah, this requires so many internal functions, a lot more than it would seem at first glance

#

this is gonna take a while to get working lol

#

oh apparrently it cant be used in system bases....

#

atleast it cant be used in static system bases, unfortunately i dont know how to create non-static system bases

rotund token
late mural
#

hmm google had no clue, and i cant work anything out either

#

trial and error aint helping neither

#

welp trial and error is the only thing left, so i may aswell continue, not like there is anything better to try

#

imma go make noodles, and come back and rethink all the stuff you have said to me, and see if i can work anything out, i may be stupid, but im not gonna give up!!

#

couldnt you instantiate it using burst instead?

#

perhaps?

#

i dont know enough about burst to say if it is possible though, but i wish you luck!

late mural
#

if i make my system base static, how badly will this affect stuff?

late mural
#

what if i use a static monobehaviour that i then inherit from using my system base?

solemn hollow
#

when you convert you get the reference of the converted prefabentity (converted by adding a gameobject to DeclareReferencedPrefabs). Then in a system you can just instantiate a copy of this prefab either with entitymanager or a commandbuffer.

solemn hollow
late mural
#

i dont know what an extension method is

solemn hollow
#

well show the method

late mural
solemn hollow
late mural
#

good idea lol

#

oh ok, i think i get them

solemn hollow
#

extension methods are a way to extend functionality of classes you don thave ownership over. (this keyword in params)

late mural
#

ok that makes sense, so i have to put them in mono behaviours then?

solemn hollow
#

no. are you trying to define one or use one?

late mural
#

both

solemn hollow
#

well then straight from official microsoft example : public static class MyExtensions { public static int WordCount(this string str) { return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length; } }

late mural
#

ok fascninating

solemn hollow
#

then you can call .WordCount() on any string

late mural
#

can i have 2 classes in 1 file?

solemn hollow
#

yes but you probably shouldnt

late mural
#

oh, so then should i use a monobehaviour instead?

#

im very lost, sorry, im quite stupid lol

solemn hollow
#

you dont need to inherit from anything. why you like monobehaviours so much ? ๐Ÿ™‚

late mural
#

cause the only 2 things i know about classes are monobehaviours and systembases

#

the rest is black magic as far as im concerned

#

oh also they have to be the same as the file name!

solemn hollow
#

if you need a explaination on c# basics like what a class is you should probably post in code-beginner channel though.

late mural
#

lol, but the people there know very little when it comes to dots

solemn hollow
#

well i guess the problem is you dont know what is dots and what are basics yet. DOTS is kinda the wrong end to start your journey.

So back to your problem. look at the code from the documentation. its neither a monobehaviour nor a systembase. its just a class not inheriting functions from any other class.

late mural
#

fascinating, and dont worry i didnt start with dots, for about 2 years ive been learning non dots unity and stuff, but i needed a bit more performance on my current project hence why im doing dots, but thanks for the class stuff info, ill do some things with it and report back!

#

ok i think i got something now, now i just gotta figure out how to import it into the other file!

#

hmm it is saying something about using a namespace, perhaps i should have a namespace around my class so i can import it?

#

ok i think i got it, im using a static using!

solemn hollow
#

so its just an object in your scene you want to copy? why is it not a prefab?

late mural
#

@solemn hollow thank you so much, everything works now, finally i can deal with euler angles instead of quaternions yay!!!!

solemn hollow
#

well you can instantiate copies from entities. you dont even need the DeclareReferencedPrefabs then. you just get the PrimaryEntity of that sceneobject

late mural
#

very odd, but it seems that by unity compiling my code, it has caused a permanent fps drop, even though im not in play mode

solemn hollow
#
            entityToCopy = conversionSystem.GetPrimaryEntity(gameObjectToCopy); ``` like this
late mural
#

hmm, comparing euler angles has many issues aswell it appears, including but not limited to 7 != 7 for some reason

late mural
#

why does it do this?

#

welp im tired, imma leave my logic of 7 being equal to 200 alone, and imma eat lasagna and try and work out what on earth i have done wrong

solemn hollow
#

that happens automatically when you DeclareReferencedPrefab. an entity is created and a prefab tag is added. the gamesystems dont interact with entities tagged as such

#

you need to specifically enable that in the query

solemn hollow
late mural
solemn hollow
#

sry no idea what your error is

late mural
#

also even weirder is despite my object staying still at 90 degrees in the inspector, it still says that every frame it changes randomly to anywhere between -3 and -2

late mural
#

i have a bad feeling it is an issue to do with unity physic's quaternion to euler function...

#

yup turns out that either i dont know how to use unity physic's quaternion function, or it just doesn't work

#

anyone know which?

solemn hollow
#

considering this function is around for decades at this point its probably you ^^

late mural
late mural
#

how could i go wrong?

rotund token
#

Pretty sure you need to choose your ordering as well?

late mural
#
var ent_rot = extension_stuffs.ToEulerAngles(transform.Rotation, math.RotationOrder.XYZ);
#

is that good?

#

to test it i got an object which has 90 euler angle in the z slot in the inspector of rotation

#

then i grab the rotation quaternion

#

then tell it to convert to euler angels

#

this gives me somwhere between -2 and -3

#

in the z slot

#

no clue why

#

even weirder

#

i then tell it to set the z to that weird -2 or -3 number thing

#

and it becomes somwhere between -200 and positive 200

rotund token
late mural
#

ok i shall!

late mural
#

also it is spinning

#

in circles

#

my syncing system is in shambles clearly, perhaps there is a bigger issue with my sync system?

#

im reverting back to xyz and ill send a code snippet of what im doing

rotund token
#

cant remember maths by zyx is more efficient conversion so usually used when converting into quaterions

#

anyway im heading to bed so won't read it for a few hours sorry

#

(make sure you have your radians right...)

late mural
#

oh that's ok, im heading to bed soon aswell

rare dew
#

I doubt I need to do a lot of async await in my systems, but purely to bikeshed, if I did, how would I go about doing this?

late mural
rare dew
#

Make a fire and forget method that mutates a member, and then poll that member on every run or?

late mural
dreamy glade
late mural
dreamy glade
dreamy glade
#

Which falls in line with how many threads my pc is capable of

late mural
#

i know not much about noise sadly, otherwise i would try help you more, but perhaps try the full stack traces setting for jobs? (note it will cost a lot of fps, but it may tell you what is causing what to leak)

late mural
# rotund token anyway im heading to bed so won't read it for a few hours sorry

ahh i feel like an idiot, apparrently due to there being multiple ways of representing quaternions using euler angles it wont ever be consistent, meaning as far as i can tell there is no way for me to rotate an entity, or atleast i dont know how to, ahhhhhhh, oh also setting 1 angle at a time causes some kind of drift leading to spinny circles, and it is just a nightmare in general, im tired, im going to bed, if you read this in the morning, pls help, if you cant help, then welp i have no clue what to do lol

misty wedge
#

Look at the nutty A* I wrote (white dots are visited nodes)

misty wedge
#

They're all empty

#

It's still good practice to do it imo

#

Is there a way to convert an integer to a fixedstring32bytes?

coarse turtle
#

I guess you could count the # of digits in the integer and then for each digit you offset integer value by 48 and cast it into a char - so you can append it into a FixedString32Bytes

misty wedge
#

Yeah that was my thought too, just wanted to know if there is already something built in before I jerry rig it

rustic rain
#

2

#

but tbh

#

better check

#

maybe it was due to second collider having raise trigger events

#

along with first

rustic rain
#

data oriented means your objects only store data

#

and logic is applied based on this data through composition

#

folder organization has nothing to do with it

misty wedge
rustic rain
#

using disposes blobassetstore

#

right after it's finished

viral sonnet
#

use the blobassetstore from conversionSystem

misty wedge
#

Someone tell me how to make my pathfinding faster

#

Update component values?

#

Sure, EntityCommandBuffer.SetComponent

#

Your code wouldn't work regardless afaik, since at the point you are executing GetComponentData the entity does not exist yet (the buffer hasn't played back)

#

(So like you said, you need to use an entitycommand buffer to set the component)

#

How are you creating your command buffer?

#

And are you adding the job handle as a producer?

rustic rain
#

ahem

#

why are you running system

#

it's supposed to be scheduled, hehe

misty wedge
#

Shouldn't it still work, even if it's incorrect? The system will have no job handles in it's dependencies, and the EndSimulationCommandBufferSystem would then just play back the buffer and spawn the entity?

rustic rain
#

it should, and it probably does

#

well

#

you instantiate in end sim ecb

#

that's right before rendering

#

only then on next frame

#

systems will update this entity's state

misty wedge
#

Are there any performance benefits to storing less keys in a hashmap?

e.g. instead of storing global positions to entities using a NativeHashMap, storing a group of entities in a square using a NativeMultiHashMap?

#

(you would then also need to iterate over the values in the NMHM to check if an entity is at a specific position)

rustic rain
#

more keys - more cache miss rate
But it'll probably depend on specifics of your application more than anything

misty wedge
#

Are the values per key close to each other in memory?

rotund token
#

No

#

Well depends on what you're asking

#

A chunk of memory is allocated

#

First capacity bytes is for keys, next capacity bytes is for values, then they're are buckets and next arrays

#

If to don't remove any element then key/value pairs are just added in order into to these native arraus

#

You're not storing anything less by grouping keys

misty wedge
#

So it'd be just as fast if I store the direct position of the entity instead of a chunk

rotund token
#

Multi hash map still stores key value pairs of all entries

misty wedge
#

Yeah, I just looked at the implementation a bit

#

tertle tell me how to make my pathfinding not sucky and slow :[

rotund token
#

Use a navmesh instead of a grid

misty wedge
#

I tried using unitys navmesh

#

And told it to build the navmesh from the mesh representation of my voronoi cells, it took like 5 minutes and used ~5gb of ram

#

This is on a mesh that is 1024*512 in game units, with a voxel size of 10

#

That said, the mesh has a lot of vertices, so I don't know if that was the issue (~350k)

rotund token
#

Odd I actually found unitys nav mesh to be really fast

#

And I've been having issues trying to replicate it's performance

misty wedge
#

I assume the searching is very fast, the building just made my computer explode

rotund token
#

It only took me like 2 seconds in background to build 8000 meshes of a whole city

#

Into a navmesh

misty wedge
#

Do you think the vertex count could be the issue?

rotund token
#

350k is tiny

misty wedge
#

That was my thinking too

#

And a voxel size of 10 is massive

rotund token
#

Is it a single mesh?

misty wedge
#

Yes

rotund token
#

Probably issue

misty wedge
#

I did set the index bytes to 32, but maybe the navmesh can't handle it

rotund token
#

Navmesh break works into cells

#

It's probably had to calculate every cell in world using this same giant mesh

#

Because it overlapped them

misty wedge
#

So creating a mesh per cell would be faster I'm guessing

#

I have 3k cells

#

each has like 100 something vertices

rotund token
#

Apart from that

#

How long is your pathfinding taking anyway

misty wedge
#

this takes like 2 ms

#

which seems very long

rotund token
#

We use a 2.5k x 2.5k cell grid at work

#

Ok 2ms for a long path is fast

misty wedge
#

That's a long path?

rotund token
#

Considering cell density I'd say so

#

What's it touching a 1000+ nodes?

#

Pathfinding can take multiple frames

#

For long distances

misty wedge
#

I'm not sure how I'd implement that though, since I'm writing my final path to dynamic buffers on entities, and those invalidate

rotund token
#

(this is why nav mesh much faster, a lot less calls to visit)

misty wedge
#

I could limit the amount per frame

#

Or use a step system

#

(I think that's what unity's job navmesh query system does)

late mural
late mural
#

hmm the real question is, does math.degrees() convert degrees to radians or radians to degrees?

#

ok something is really bugging me about this whole thing, i just dont seem to get, i get a vector3 of euler angles in degrees of the desired rotation

#

and i get the x of it

#

i set the x of the object that needs the rotation to the x of the desired rotation

#

it completely messes up and sets the x rotation to a random number and starts spinning in circles

#

it tells me it set the x to this value

#

inspector tells me it did something completely different

#

im so lost, if anyone knows or gets anything, i will accept any help, ill also send my code incase that will help

#
var ent_rot = extension_stuffs.ToEulerAngles(transform.Rotation, math.RotationOrder.XYZ);
ent_rot = new Vector3(math.degrees(ent_rot.x), math.degrees(ent_rot.y), math.degrees(ent_rot.z));
#

here is how im syncing it:```csharp
sync_rot = new Vector3(sync_rot.x, sync_rot.y, ent_rot.z);

rotund token
late mural
rotund token
#

rotation z is in quaterions though?

late mural
#

it is?

rotund token
#

are you not looking at the rotation component on an entity?

#

what are you looking at

late mural
#

im looking at a game object in the inspector on the rotation thingy, that im pretty sure is euler angles

rotund token
#

i'm so confused what you're doing

late mural
#

same

rotund token
#

if you are using gameobjects

#

why are you using quaternions at all?

late mural
#

im using both game objects and entities

#

let me explain

#

so i have an entity with a desired euler angle z value, and i want to set the euler angle z value of a game object to it

#

unfortunately entitie's rotation does not have a built in method to convert the rotation quaternion into a euler angle, hence why i had to use the physics math method thing to do that, but that caused my thing to spin in circles for some reason

late mural
#

as im so lost lol

rotund token
#

why not just set the gameobject to the same rotation as the entity rotation?

late mural
#

unfortunately the entities x euler angle is not desired, hence why i cant do that unfortunately

rotund token
#
gameobject.rotation = entity.entityRotation;
var angles1 = gameobject.eulerAngles;
angels1.x = angles.x;
gameobject.eulerAngles = angles1;```
#

just store the angle you want

#

then write it back

late mural
#

oh

rotund token
#

why go through all the effort of doing the maths yourself ^_^'

late mural
#

that is so clever

#

i never thought of any of that

#

ahhhh

#

welp thank you so much!!!!!

late mural
late mural
#

although it is consistent with the spinning, always changing between 2 angles back and forth

#

ok i found the source of the issue

#

apparrently local to word transform component on my entity really has no clue what rotation quaternion my entity has and it is chaotically changing at all seconds, despite the rotation actually being the same

#

im just going to use whatever regular transform component entities have, cause this local to world one is weird

#

huh and now im getting an error that tells me if i want to write i need to not use the ref modifier, despite me not wanting to write

#

ok apparently i have no clue how to use transforms, thought it would be a simple ref Transform kinda thing, seems that it is not happy with that though

#

ok i think i get it

#

ill just use ref Rotation instead

#

huh now suddenly it is not spinning, but neither is it doing anything, which means ive messed soemthing up

#
sync_objects[sync_comp.sync_id].transform.rotation = ent_quaternion;

var angle_storage = sync_objects[sync_comp.sync_id].transform.eulerAngles;
angle_storage.x = sync_angles.x;
angle_storage.y = sync_angles.y;
sync_objects[sync_comp.sync_id].transform.eulerAngles = angle_storage;
sync_angles = angle_storage;
``` any ideas on why this just doesnt work?
misty wedge
#

What is sync_angles?

late mural
misty wedge
#

With "it doesn't work", do you mean it does nothing or it works incorrectly?

late mural
#

it claims to have synced them, the code runs, i can tell via debug logs, but it just doesnt change the rotation

misty wedge
#

What is sync_objects? A hashmap?

late mural
#

huh from debugging i think i know the issue, it is with setting the angle storage

robust scaffold
misty wedge
#

Have you tried checking if the issue is struct copying? e.g. instead of

sync_objects[sync_comp.sync_id].transform.rotation = ent_quaternion;

do

var tr = sync_objects[sync_comp.sync_id]
tr.transform = new ...
sync_objects[sync_comp.sync_id] = tr;
#

It's the only issue I can see, besides a bug somewhere else

late mural
#

basically i removed all lines beside that one, and it works, although without the correct x and y, which means im assigning the x and y incorrectly that somehow changes the z

#

i think i know the issue aswell, and it is gonna be a pain if it is what i think it is

#

basically what i would assume to be the issue is that euler angles doesnt get updated until next frame, hence why setting angle storage equal to eulerAngles is giving my old data

#

meaning either i have to manually somehow update eulerAngles or manually convert the quaternion into eulerAngles, or somehow not use eulerAngles, all of those options appear extremely difficult though

misty wedge
#

Why do you need to use euler angles?

late mural
misty wedge
#

Aren't you just trying to set the rotation on the gameobject?

late mural
#

yes

misty wedge
#

Why not just set the rotation as a quaternion instead of euler angles?

late mural
#

that would be nice, unfortunately i still need the x and the y euler angles to remain the same on the game object, hence why i cannot do that

#

im sure using fancy quaternion math it might be possible to do it, but that stuff is way too advanced for me to understand, so i really dont have many good options

misty wedge
late mural
#

because the game object needs a different x and y than the entity

misty wedge
#

What transformation does it need?

late mural
#

?

misty wedge
#

Well, why does it need a different x and y?

#

I thought you wanted to set a gameobject's rotation to that of an entity's? or is your render representation somehow different

late mural
late mural
#

i sync them in most cases to be exactly the same

#

but this is a different case

misty wedge
#

But how different is it? Like rotated by some degrees or what?

late mural
misty wedge
#

Then just rotate the quaternion by 90 degrees?

late mural
misty wedge
#

multiply them

late mural
#

how do you multiply quaternions?

misty wedge
#

quaternion1 * quaternion2

#

will apply both rotations into one quaternion

late mural
#

oh they natively multiply?

misty wedge
#

yes

late mural
#

ok, how do i get the 2nd quaternion?

misty wedge
#

Quaternion as well as quaternion iirc

#

quaternion.Euler(90, 0, 0)

#

or whatever your rotation is

late mural
#

ok thank you so much!

misty wedge
#

I lied, it's probably some function in math, let me check

#

Quaternion definitely has the multiply operator overloaded though

late mural
#

oh ok!

robust scaffold
#
rotation.Value = math.mul(
math.normalize(rotation.Value),
quaternion.AxisAngle(math.up(), rotationSpeed.RadiansPerSecond * deltaTime));
#

probably standard math.mul

misty wedge
#

Yeah I would have guessed so too, I'll still check

late mural
#

ok ill try that thanks so much all of you!

robust scaffold
#

honestly I just stick with regular uppercase Quat for all these rotations and such. Much more documented. Sure, there's equiv with lowercase but good luck finding any examples on stack overflow.

late mural
#
sync_objects[sync_comp.sync_id].transform.rotation = math.mul(ent_quaternion, quaternion.Euler(sync_angles.x, sync_angles.y, 0));
``` so making certain i understood everything right, i would do it like this right?
robust scaffold
#

test it out. See if it works. Quats cant really be proofread in the brain like regular transforms

late mural
#

ok it does not work, i clearly have messed something up

#

it spins out of control at random angles

robust scaffold
#

if you're doing this every frame, then it applys the rotation of sync angles every frame as well on top of the current rotation

#

so if that runs every frame, it spins

late mural
#

oh that aint good, anyway i can get it to not do that?

robust scaffold
#

somehow make a conditional that checks to do it once

late mural
#

to do what once?

robust scaffold
#

the application of this rotation

late mural
#

this has to run every frame unfortunately

robust scaffold
#

are you trying to set it to sync angles or rotate it by sync angles?

late mural
#

im syncing the z axis rotation between 2 things

#

that is all i know

robust scaffold
#

sync_objects[sync_comp.sync_id].transform.rotation = quaternion.Euler(sync_angles.x, sync_angles.y, 0);
Try this.

misty wedge
robust scaffold
late mural
misty wedge
robust scaffold
robust scaffold
#

.....

late mural
#

...

robust scaffold
#

alright, i give up, i have no clue

late mural
#

oh ok...

robust scaffold
#

i think you need to spend some time researching what rotation and quats are before trying to figure out what you want to do.

late mural
#

i have been doing that

#

this is the 3rd day of attempts

#

nothing wants to work in any logical way

robust scaffold
#

Try opening up a new project and trying to get a cube to rotate.

late mural
#

i know how to make stuff rotate, that is not the issue

robust scaffold
#

That contains the samples of a single cube rotating.

late mural
#

that is not what i need i have the rotation already, i just need to make something else have the same, but only in 1 axis

robust scaffold
#

alright, if you know how to rotate something, then thats everything you need to know

robust scaffold
#

can you not just make the quat equal to eachother in whatever axis you want synced?

late mural
#

that would be nice, unfortunately im not good enough in quaternion math to know how to do that

#

and no amount of research online has shown me how to either

late mural
#

you are good at googling then

#

i am not

robust scaffold
#

programming is 90% googling, 9% finding out what to google, 1% copy pasting.

late mural
#

yup, and i suck at that 9%

robust scaffold
#

"unity how to set rotation of one object equal to another" That is what I googled.

viral sonnet
#

if you need to only apply 1 axis you can multiply the rotation with a forward vector, take xyz you need and create a lookrotation from it

late mural
#

also i tried the method that is suggested in that page, it doesnt work for me, cause euler angles of the entity seem to act very weird

viral sonnet
#

easiest to debug if you are that stuck

late mural
viral sonnet
#

quat * new Vector(0, 0, 1)

#

the resulting vector points in the direction of the rotation

late mural
#

woah, is it really that simple?

#

so how do i put this in a cohesive form?

robust scaffold
#

((Quadernion) quaternion).EulerAngles

late mural
late mural
viral sonnet
#

the vector is axis based so you can discard any axis you don't want and just use the ones you want

late mural
#

how exactly?