#archived-dots
1 messages ยท Page 283 of 1
is there a good way to extend math? Would like to add a projectOnPlane method and unsure where to put it ๐ค
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?
@drowsy pagoda public PhysicsCategoryTags layerMask;
Oh didn't realize there was a Unity.Physics.Hybrid assembly.
ITriggerEventsJob and ICollisionEventsJob
@pulsar jay I just made my own math package for commonly used burstable stuff like that.
i think Physics has that although it may be marked internal.. there are comments in the code in Physics.Math saying some of those methods will eventually be moved into Mathematics
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
can i call methods in a system base from a monobehaviour, and how badly will it negatively affect performance?
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
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
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?
engine's random is static and managed
math's random is umanaged and is literally just value
aha, that doesnt mean a lot to me im afraid, guessing it means that neither of them really are better in terms of performance?
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!
everything else doesn't matter much until you have like thousands random iterations per frame
ooh ok, im aiming only for around 500, so hopefully whatever my solution becomes is good enough
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
Hmm
if I remove singleton component
and then add it on other entity
on same frame
will OnStartRunning trigger?
OnStartRunning is pretty simple
if (!DidRunLastFrame() && RunThisFrame()) OnStartRunning()
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
wondering, how do you burst compile for loops, or is this not possible?
you need to use for and not foreach if that is your question
i believe so?
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
Solution - create an array of randoms, one for each possible thread, each with a different seed:
Then inside your job, access by thread index:
Maybe worth looking into : https://github.com/Dreaming381/Latios-Framework/blob/master/Documentation~/Core/Rng and RngToolkit.md
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
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) ?
that is completely deterministic
(not that I care)
but you will always have the same entityInQueryIndex every frame until a structural change occurs
i think he meant deterministic between play sessions. i am not sure it is
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)
hmm how do parallel containers break it in normal usecases? at some point that parrallel container is written back to sth. if that write step is deterministic all is good right?
havent thought about determinism too much and am just wondering
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
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.
oh right. can you read the value in the parallel hashmap before overwriting it in from another thread? probably not right?
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
no but sometimes you use a hashmap as a check like
if (hashmap.TryAdd()) { doSomething();}
that seems a fairly good way to do it
sry i didnt get that. TryAdd was what i basically meant. Can i check on thread2 if thread1 already added a value in parallel?
yes that's what TryAdd does. It can't add a value twice (to non multi)
wow i thought thats only checking if the same thread already added
that wouldn't be a very good hashmap
so if id want to sum up all damagevalues for a targetentity i could do this in a parallel hashmap and still have determinism?
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?
yes
hmm thats very good to know.
Whats the current state of 2d support for DOTS stuff? Still nothing yet?
Yeah I think it travelled to another plane of existence
huh?
and nothing probably will be
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;
}
0
allthough
it's not hard to achieve 2D state in physics
but that would be 2D for the price of 3D anyway
Yeah and therin lies the problem for me. I know I tried to use it for a project at scale with a custom sprite render implementation but yeah.
In the end I went with monogame since at that point unity lost its benefits.
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
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.
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
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.
That is my point. I am seeing no real benefit in unitys way of doing it.
what is the bottleneck you cant solve?
game objects keep only data, I query over them through entities system
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.
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.
well, Unity offers quite an interesting way of conversion that lets you use all editor instruments
dots subscenes are specifically for that scalability
so you have good editing performance and optimized runtime
Its not scene complexity we have issue with or geometry complexity. Its maintainability.
any specific example?
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?
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.
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.
Do you mean you cant open a single scene because you are missing references that are setup in another scence at gamestart?
Not just at game start. What we would expect is to be able to arbitrarily test components or gameobjects in isolation by mocking inputs. Its not the references missing since we abstract references away generally to not use it. But how the editor is laid out it seems it expects us to hotwire references?
The point is when you do that you loose any editor side references of it.
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
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.
get entity query of player and then extract to native array
then just grab it, array will be size of 1
why not use getsingleton?
Isn't it a protected method?
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
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
even my UI is in SystemBase xD
hmmm
is it possible to grab a reference of world in conversion system?
ah, nvm
Sounds like a terrible idea anyway
@gusty comet also see pinned messages here
something that makes OOP look like garbage xD
OOP aka the trillion dollar disaster
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
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.
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.
yes
thanks!
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.
should I mark public EntityCommandBuffer.ParallelWriter commandBuffer; with [WriteOnly]?
tags are nice and "free" but as far as I know they still change the archetype.
And lead to the aforementioned cache misses.
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.
is there readonly verion of GetEntityTypeHandle() or it's already readonly?
its readonly
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?
IConvertGameObjectToEntity is just simple way to convert. It also goes inside conversion system which just collects all component with implemented interface. Also i remember that asset blob will automatically dispose duplicate data if you use BlobAssetStore so no really difference
conversionSystem.BlobAssetStore.AddUniqueBlobAsset(ref blob);```
Are there performance boosts for using GetComponentDataFromEntity<T>(readOnly: true); ...WithReadOnly(componentDataFromEntity); vs SystemBase.GetComponent<T> & SystemBase.HasComponent<T>?
are you talking within a entities.foreach?
because GetComponent HasComponent uses ComponentDataFromEntity
meaning on the main thread?
yea
And why does it make a difference on main vs background?
GetComponent/HasComponent uses EntityManager on main thread
Ah. Interesting. Thanks
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
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
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
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 ๐
yeah ๐ dumb mistake, working fine now
can you show me how you show pointers in the inspector?
ok, must be quite similar to the, what was it called, nativedebug something that we tried for the hashmap?
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)
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
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
added in 0.50 i believe
there actually is EntityField in Unity.Entities.Editor.Inspectors.
of course it's internal haha
DoDefaultGui(root, "NameOfEntityField");
will just render it with how it would be rendered by default
and that works behind a pointer?
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 >_>
I see what you are going for ๐
wait, how did this work? my editor scripts can't access my main script types
you mean the inspector?
yep
why not?
are they private
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
have you a reference to your NZSpellCasting in the NZSpellCasting.Editor asmdef?
(not sure what folders have to do with this at all)
yeah me neither, just trying things. I'll setup an asmdef. usually I don't need to make one. hm
yeah, oh is there also a new way?
yeah asmdef
ok, yeah setting that up right now.
can you show me which references you are using on your asmdef?
i'm just using unity and my own libraries
after my ocd kicked in
just make it an editor only assembly
thank you
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
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
ok cool that wasn't quite clear to me. i'll play around with it. should be close now
wrapper lib sounds cool
you don't want to inject too many assemblies into a package
because i believe it'll cause that package to have to recompile
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 ๐
not possible to inspect System member fields?
what's stopping you?
like how we can see DynamicBuffer values on entities in the inspector
oh you want a system inspector?
there's nothing written for that
usually you'd just break point
yeah it'd be useful
that is definitely behaviour i have never considered
not sure if i would even use it tbh
if i click a system in the Systems inspector, it shows queries, but not data/members
i don't really store state in my systems
yeah basically i have some nativearrays on my system
was naively hoping i could just inspect them ๐
it's not a big deal really, would be a nice to have
i wonder if there's any disadvantage to having persistent nativearrays on systems
really? don't you consider some NativeContainer as state or don't you use any?
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
not really
for the most part my systems are stateless
i don't share any native containers between systems
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
well, state is the wrong word. i have acceleration structs
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
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
huh, where would you store a hashmap then?
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
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
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
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
my sugar intake agrees
apparently he started out in games, and worked on Theme Park, anybody remember that gem of a game
first computer was a speccy ๐
yeah from bullfrog. what's his name?
Demis Hassabis
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 ๐
Yeah tbh i've never dabbled in ML at all although i've wanted to try Unity's training thing
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
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
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
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.
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
is it normal to have this many things that unity thinks are potential job leaks?
normal would be 0
stop leaking native memory
turn on your leak detection so you can see what you're leaking
oh ok, ill try that and report back!
ok, simply by turning it on has reduced the number to 0! Thanks so much!
it also has massively increased performance somehow!
ah thats' the opposite of what should happen
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
also full stack trace should dramaticly lower your fps
oh i have not enabled full stack traces, should i try it?
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
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
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.
Side note. I think you're mem leaking that dens array
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)
If it had the dispose attribute, then why initialize it in the field of the job scheduling, just create it inside the job as it wont be crossing main and job boundaries?
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.
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?
I assume System's Time.DeltaTime is specific to that System?
Meaning FixedStep will have according Delta time or not?
Time.Delta time is a World value
I see
but system groups can set it
hence how fixed update systems work
it pushes a time then pops it when it leaves the group
I just wonder, whether I should have delta in fixed or just use whatever fixed target delta is meant to be
be the same
i have tried that, i dont get how to do them
i only want to change 1 axis, i somehow manage to change them all
let me explain, this might take a bit
just tell technical part. You want to rotate object on 1 axis?
yup
in what way
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
Well yeah x is not Euler x
sadly yup
maybe instead of assigning Euler angles
you sohuld just rotate object_rot together with second_object?
how?
how is your second object rotation assigned?
ive done this before, usually i can
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
well, if you want to go this way
you need to extract quat into Euler
which is quite big tbh
yeah
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?
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
sir, just do it if you don't see any other way
i do want to do it, but how, ive googled there is no info anywhere
but converting to EUler is somewhat complex either, heh
cant i just copy unity's game object code for it? and then dot-ify it?
ok ill try that
this is how I usually find certain solution to math problems xD
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!
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
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
you should not really worry about doing math
unless it's a lot of mat
how?
if i dont do math, then everything fails
math is like least expensive thing in C#
yup, and i suck at math though lol
compared to some managed queries, casts and etc
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
apart from ones like this wikipedia thing: https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles but that uses the fancy equation stuff, which i cannot understand, and google aint helping me neither
quite exactly the reason I suggest against it, heh
whyyyy does entity transforms not include the same stuff as game object transforms ahhhh
unless you can suggest a better method?
work in quaternions and keep your workflow inside of them
yes, but i dont understand quternions
i dont get them, they just dont make sense to me
you don't need to understand them
how?
what does that mean???
you just need to learn how to use them:
multiplication, dot products
cross products
you don't need nothing else
tbh
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!!!
ok im trying that sure
unfortunately that is not what i want
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
it's matrix multiplication
?
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
how do i learn how to use it though, as im finding nothing useful, my googling is not helping me
for humans there's Euler representation of any angle
give me some links please to anything that even vaguely might help
sir, doubt my links would help. Language issue
just look up
smt hlike
"How to rotate quaternions"
in yourtube
or smth
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
welp, you can't learn encyclopedia in one day xD
multiplication, dot products
cross products
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!
those are key, just start with them in order
ok sure, and imma try bing, because google doesnt have a clue what your talking about
once you will know what each mean - you won't need anything else imo
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
i dont think this has anything to do with entities
it's simply you're using an experimental product that isn't complete
i suppose so
i'm pretty sure you'll get full easy transform support with aspects in 1.0+
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...
there's a method in the physics package that does it
what is it called?
ToEuler from memory
thank you so much!!!! I have been trying for 2 days, thank you so much, you are awesome!!!!!!!
cant seem to find it?
googling cant find it, dont see it anywhere in the physics manual, and my ide aint auto completeing it
thank you so much!
you need to learn to search
yes i do
๐
im not good at searching lol, i just dont get it, no matter how many tutorials i watch
i cant find it still
my ide is giving me not found errors
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
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?
internal means you can't access it outside of the assembly
so i was correct with my interpretation then?
im sorry i dont get this at all, this doesn't make sense to me, how do i this?
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
ctrl+c, ctrl+v
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
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
you need to copy the source code
from the physics library
and put it in your own method
so you can use it
which part of it?
the method called ToEulerAngles (probably toEuler)
oh ok, ill go search for it and see if i can find it
found it, ok now i can try it, thank you so much!
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
? it works fine in jobs
odd, i get an error from my ide
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!
if i make my system base static, how badly will this affect stuff?
i see that destroys everything
what if i use a static monobehaviour that i then inherit from using my system base?
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.
im not sure what you are trying to do. can you show the code? is it just a static function you want do define somewhere?
i dont fully know, im getting an error that tells me my systembase needs to be static
i dont know what an extension method is
well show the method
what method?
why dont you google that first ^^
extension methods are a way to extend functionality of classes you don thave ownership over. (this keyword in params)
ok that makes sense, so i have to put them in mono behaviours then?
no. are you trying to define one or use one?
both
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; } }
ok fascninating
then you can call .WordCount() on any string
can i have 2 classes in 1 file?
yes but you probably shouldnt
oh, so then should i use a monobehaviour instead?
im very lost, sorry, im quite stupid lol
you dont need to inherit from anything. why you like monobehaviours so much ? ๐
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!
if you need a explaination on c# basics like what a class is you should probably post in code-beginner channel though.
lol, but the people there know very little when it comes to dots
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.
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!
so its just an object in your scene you want to copy? why is it not a prefab?
@solemn hollow thank you so much, everything works now, finally i can deal with euler angles instead of quaternions yay!!!!
well you can instantiate copies from entities. you dont even need the DeclareReferencedPrefabs then. you just get the PrimaryEntity of that sceneobject
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
entityToCopy = conversionSystem.GetPrimaryEntity(gameObjectToCopy); ``` like this
hmm, comparing euler angles has many issues aswell it appears, including but not limited to 7 != 7 for some reason
ok i know what is wrong, problem is i dont get it, i say that this_should_be_7 = 7 and it equals 200
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
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
what youve done wrong is you entered the realm of transforms ๐
ah, any logical way to fix my errors?
sry no idea what your error is
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
neither do i lol
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?
considering this function is around for decades at this point its probably you ^^
probably, but i dont see how i can go that wrong surely, perhaps im accidentally using radeons instead of degrees?
i mean all you do is put in a quaternion, and then it gives out a float3
how could i go wrong?
Pretty sure you need to choose your ordering as well?
i did, i think?
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
try ZYX
ok i shall!
nope
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
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...)
oh that's ok, im heading to bed soon aswell
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?
oh im using degrees...
Make a fire and forget method that mutates a member, and then poll that member on every run or?
welp atleast i know a potential issue
Thanks Korn for the response. I dispose of the Jobs each time they're complete though! Would there be any other reason of memory leaks? Thanks.
sometimes memory leaks are random, bit unrelated but i remember one time i had 600 memory leaks, and then never got a single one again, despite me not changing anything
Well, if you see by the original post, the perlin noise stops working properly 13 rows in out of the 20. Exactly in the same spot each time.
ye, that is weird
Which falls in line with how many threads my pc is capable of
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)
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
They're all empty
It's still good practice to do it imo
Is there a way to convert an integer to a fixedstring32bytes?
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
Yeah that was my thought too, just wanted to know if there is already something built in before I jerry rig it
2
but tbh
better check
maybe it was due to second collider having raise trigger events
along with first
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
and that the data is layed out in a way that makes your code run (hopefully) faster ๐
use the blobassetstore from conversionSystem
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?
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?
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
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)
more keys - more cache miss rate
But it'll probably depend on specifics of your application more than anything
Are the values per key close to each other in memory?
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
So it'd be just as fast if I store the direct position of the entity instead of a chunk
Multi hash map still stores key value pairs of all entries
Yeah, I just looked at the implementation a bit
tertle tell me how to make my pathfinding not sucky and slow :[
Use a navmesh instead of a grid
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)
Odd I actually found unitys nav mesh to be really fast
And I've been having issues trying to replicate it's performance
I assume the searching is very fast, the building just made my computer explode
It only took me like 2 seconds in background to build 8000 meshes of a whole city
Into a navmesh
Do you think the vertex count could be the issue?
350k is tiny
Is it a single mesh?
Yes
Probably issue
I did set the index bytes to 32, but maybe the navmesh can't handle it
Navmesh break works into cells
It's probably had to calculate every cell in world using this same giant mesh
Because it overlapped them
So creating a mesh per cell would be faster I'm guessing
I have 3k cells
each has like 100 something vertices
That's a long path?
Considering cell density I'd say so
What's it touching a 1000+ nodes?
Pathfinding can take multiple frames
For long distances
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
(this is why nav mesh much faster, a lot less calls to visit)
I could limit the amount per frame
Or use a step system
(I think that's what unity's job navmesh query system does)
now that im awake, i can deal with this problem, i thought it was in degrees, not radians, guessing i gotta convert to degrees first lol?
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);
what are you looking at inspector?
rotation z
rotation z is in quaterions though?
it is?
are you not looking at the rotation component on an entity?
what are you looking at
im looking at a game object in the inspector on the rotation thingy, that im pretty sure is euler angles
i'm so confused what you're doing
same
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
any ideas tertle?
as im so lost lol
why not just set the gameobject to the same rotation as the entity rotation?
unfortunately the entities x euler angle is not desired, hence why i cant do that unfortunately
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
oh
why go through all the effort of doing the maths yourself ^_^'
that is so clever
i never thought of any of that
ahhhh
welp thank you so much!!!!!
this has one small downside of either making me have to set rotation ever frame for a few seconds, or deal with trying to round quaternions somehow, oh well ill see how the first option goes and hope it doesnt cause too much lag
there appears to be severe issues with your method, as my object spins in circles violently and seems determined to not stay at the same angle as the entity, or more likely i just have implemented it extremely poorly
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?
What is sync_angles?
original euler angles of the game object
With "it doesn't work", do you mean it does nothing or it works incorrectly?
it claims to have synced them, the code runs, i can tell via debug logs, but it just doesnt change the rotation
What is sync_objects? A hashmap?
a list of game objects that need to be synced with an entity, i know it probably aint the most efficient, but i can deal with that later
huh from debugging i think i know the issue, it is with setting the angle storage
Just attach the corresponding GO's transform as a component on the relevant entity.
that is what ive done
ish
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
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
Why do you need to use euler angles?
how else would i convert the quaternion into a vector 3 of degrees?
Aren't you just trying to set the rotation on the gameobject?
yes
Why not just set the rotation as a quaternion instead of euler angles?
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
Why do they need to stay the same if you are updating it?
because the game object needs a different x and y than the entity
What transformation does it need?
?
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
due to them being oriented differently
i have 2 versions of everything basically, one for collision of game objects and one for collision of entities
i sync them in most cases to be exactly the same
but this is a different case
But how different is it? Like rotated by some degrees or what?
Have you tried using axis angle?
yes, rotated 90 degrees differently
Then just rotate the quaternion by 90 degrees?
ooh i have not heard of that, i shall check it out
how?
multiply them
how do you multiply quaternions?
oh they natively multiply?
yes
ok, how do i get the 2nd quaternion?
Quaternion as well as quaternion iirc
quaternion.Euler(90, 0, 0)
or whatever your rotation is
ok thank you so much!
I lied, it's probably some function in math, let me check
Quaternion definitely has the multiply operator overloaded though
oh ok!
rotation.Value = math.mul(
math.normalize(rotation.Value),
quaternion.AxisAngle(math.up(), rotationSpeed.RadiansPerSecond * deltaTime));
probably standard math.mul
Yeah I would have guessed so too, I'll still check
ok ill try that thanks so much all of you!
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.
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?
test it out. See if it works. Quats cant really be proofread in the brain like regular transforms
ok it does not work, i clearly have messed something up
it spins out of control at random angles
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
oh that aint good, anyway i can get it to not do that?
somehow make a conditional that checks to do it once
to do what once?
the application of this rotation
this has to run every frame unfortunately
are you trying to set it to sync angles or rotate it by sync angles?
sync_objects[sync_comp.sync_id].transform.rotation = quaternion.Euler(sync_angles.x, sync_angles.y, 0);
Try this.
ok i shall, then ill report back
wait no, i know that wont work
quats are magic
it doesnt have the 2nd quaternion anywhere in it
I'd at least assume they would both be the same
yea. Are you trying to set the rotation to sync angles or trying to spin it by sync angles. What do you want?
neither
.....
...
alright, i give up, i have no clue
oh ok...
i think you need to spend some time researching what rotation and quats are before trying to figure out what you want to do.
i have been doing that
this is the 3rd day of attempts
nothing wants to work in any logical way
i know how to make stuff rotate, that is not the issue
That contains the samples of a single cube rotating.
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
alright, if you know how to rotate something, then thats everything you need to know
unlikely
can you not just make the quat equal to eachother in whatever axis you want synced?
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
first google link
programming is 90% googling, 9% finding out what to google, 1% copy pasting.
yup, and i suck at that 9%
"unity how to set rotation of one object equal to another" That is what I googled.
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
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
easiest to debug if you are that stuck
how do i do this, i have no euler angles of the entity rotation, only a quaternion, so how on earth could i do this?
quat * new Vector(0, 0, 1)
the resulting vector points in the direction of the rotation
((Quadernion) quaternion).EulerAngles
i couldn't get that working, it would keep changing every frame to some random number that wasnt anywhere near related to the rotation
how is this useful btw?
the vector is axis based so you can discard any axis you don't want and just use the ones you want
how exactly?
