Search Issue Tracker

By Design

Votes

0

Found in

2020.3.39f1

2021.3.9f1

2022.1.14f1

2022.2.0b6

2023.1.0a8

Issue ID

UUM-13005

Regression

No

Quaternions are initialized with the real part being zero

--

-

Reproduction steps:

# Open the “PoseTest” project
# Open the “SampleScene” scene
# Press the Play button
# Observe the Console

Expected result: “(0.00000, 0.00000, 0.00000, 1.00000)” is printed in the Console
Actual result: “(0.00000, 0.00000, 0.00000, 0.00000)” is printed in the Console

Reproducible with: 2020.3.39f1, 2021.3.9f1, 2022.1.14f1, 2022.2.0b6, 2023.1.0a8

Reproduced on: Windows 10

Note: one of the workarounds for the issue would be to set one of the rotation values in the Inspector and save the scene. This way the “W” parameter will be 1. It is also believed that 0,0,0,0 quaternion rotation is impossible or an invalid/undefined rotation.

  1. Resolution Note:

    This is by design in c# that fields in a struct are always zeroed by default. Thus, the quaternion will be (0,0,0,0) when the new struct is constructed an that is intended by the c# standard.

    If you want to set default values to your quaternion, I recommend you add a `Reset` function to your MonoBehaviour. This is called whenever the component is created in the editor, or when manually clicking reset on the component sub-menu:

    https://docs.unity3d.com/ScriptReference/MonoBehaviour.Reset.html

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.