Built in aspects gone?

Hello,

So i am new to unity ECS (using 1.0.0-pre.65), have been following some tutorials, and it seems to appear that there were supposed to be some default built-in aspects that come with certain authored gameobject-components to make life easier (e.g. a TransformAspect to handle changing a transform like one would expect, instead of 5D quaternion mess when trying to rotate something).
8900376--1217724--5D Quaternion.gif

These aspects seem to be removed? Cant seem to find them anywhere. Are we now supposed to make our own aspects to use unity’s built in components, or am i missing something?

Yeah transformaspect seems to be one of the casualties of the recent transform changes. There was a good explanation over on the unity discord(not a bad resource to have at your fingertips)
You can still make your own aspects, LocalTransform should suffice in most uses though.

2 Likes

So i am supposed to write my own aspect, in order to fix rotation, until unity patches it in the next pre- version?

Also, cant seem to find “DOTS General Discussion” on the official unity discord, can you give me a link?

I’m really as far from an expert on quaternions as anyone could possibly be, but my assumption is this is normal when modifying a quaternion, perhaps you were expecting euler angle based rotations in the inspector(like a gameobject has)? Just for the record I never actually had a chance to use the transform aspect before it was removed, so not sure if it had euler rotations inside of it.
You could make your own component where a system takes an euler rotation and overwrites the existing rotation of localtransform.

Scroll down under scripting to find the dots-forum area

It most definitely is no normal quaternion behaviour. Modifying a proper quaternion gives rotation only, not scale.

I just hope unity patches this soon

Actually I see someone else complaining on discord(and a dev mentioning a fix on the way) about the same rotation scaling so yeah I definitely know nothing of quaternions!

This is the same discord i found. But for some reason i dont see the dots parts… I suspect it to be the fact i need to “complete some steps before you may chat”, but for that i need to give a phone number. Hella aint going to do that, thx anyway.

Huh, I don’t remember doing that. Probably to stop bots from joining and spamming the server. Unfortunately, that is where a lot of the DOTS discussion happens and the best place to get quick help.

Not sure what quaternion issue you are talking about, but the one mentioned on the discord is how the LocalToWorld.Rotation property returns the wrong value if the entity is scaled in any way. A quick fix is to create an extension method for LocalToWorld that normalizes the quaternion:

public static quaternion Rotation(this LocalToWorld ltw) =>
quaternion.LookRotationSafe(ltw.Forward, ltw.Up);

More info in this thread: https://discussions.unity.com/t/788891

As you can clearly see in the supplied GIF, my issue isn’t the rotation being slightly off when the object is scaled, but the fact that changing the rotation scales the object in a weird manner. Think ill be waiting for a patch tho, instead of trying to get a workaround (Quaternions aren’t supposed to space out scale on default in my oppinion). Thanks anyway.

Sorry, I actually didn’t realize that was a gif, I thought it was a screenshot about the lack of aspects.

Manually modifying one component of a quaternion will result in scale and shear. This is because the result needs to be normalized.

I think you might be confusing quaternions with euler angles. With euler angles, the “x” component represents the amount the object was rotated around the x axis. Likewise for y and z. With euler angles, you can manually override the value and it will update in a mostly intuitive way without and scaling or shearing artifacts. However, while euler angles are nice for debugging and manual editing, they have a couple of problems that make them unsuitable for runtime rotation information. The first issue is that euler angles have to be applied in a specific order, and that order is not really intuitive to the user. The other issue is known as “gimbal lock” where a degree of freedom is lost in certain configurations.

Quaternions fix all these problems, but are harder to work with manually. Generally, if you want to change an object’s rotation quaternion, you’ll want to use methods like the following:

quaternion.Euler()
quaternion.RotateX()
quaternion.RotateY()
quaternion.RotateZ()
quaternion.AxisAngle()
quaternion.LookRotationSafe()

Btw, the Euler method lets you choose which order the axis rotations are applied.

Another option is to switch the inspector to show authoring data instead of runtime data. Then you can rotate the authoring game object’s transform component (which shows euler angles) and it will rotate the baked entity without scaling or shearing.

1 Like

I am aware that changing components on a quaternion does not work like eulers. It’s just that any other 3D program using quaternion are apparently already normalised, for i never encountered scale and shear using them. Which means i just don’t know how quaternion work, in raw math lol…

In my case i rarely change transforms manually during play-test runtime, and if so, yes using the authoring components. I’ts just also nice to know how to properly rotate something from script.

Thanks for telling me ^.^

1 Like

Nobody really knows how quaternions work

2 Likes

Nah, they’re pretty simple after you learn them
8902059--1218108--upload_2023-3-25_12-34-21.png
)

2 Likes

The best explanation on quaternions I could ever find was the color theory one.