Hello! When character's turn to face another character I receive the following error:
"Rotation quaternions must be unit length.
UnityEngine.Rigidbody:MoveRotation(Quaternion)
AC.Char:DoTurn(Boolean) (at Assets/AdventureCreator/Scripts/Character/Char.cs:1541)
AC.Char:_FixedUpdate() (at Assets/AdventureCreator/Scripts/Character/Char.cs:584)
AC.StateHandler:FixedUpdate() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:470)"
This happens once per prefab type, and then won't happen again if I unpause the scene. Does anyone have an idea what's going on/need more information?
Thanks!
Comments
Here are the screenshots requested:
Here is the Actionlist that is causing the error to occur. It is using Gameobject parameters to reference the characters. Though when called again in the scene the error will not occur again. I have tried removing the animate and follow before and after, the error persists if I do this.
Thanks for your help!
- I set up the navigation bake using Unity Navigation after a character was already in the scene
- By removing and re-adding characters to a scene, the error is resolved permanently for that scene.
- As long as the nav mesh has been baked at least once it can then be changed and rebaked without the issue re-occurring.
While I fixed this just after you responded, I only just figured out how I fixed it and thought it would be nice to tell you the cause and solution.I'm seeing this error frequently as well.
Rotation quaternions must be unit length.
UnityEngine.Rigidbody:MoveRotation(Quaternion)
AC.Char:DoTurn(Boolean) (at Assets/AdventureCreator/Scripts/Character/Char.cs:1659)
AC.Char:_FixedUpdate() (at Assets/AdventureCreator/Scripts/Character/Char.cs:610)
AC.StateHandler:FixedUpdate() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:479)
or
Rotation quaternions must be unit length.
UnityEngine.Rigidbody:MoveRotation(Quaternion)
AC.Char:DoTurn(Boolean) (at Assets/AdventureCreator/Scripts/Character/Char.cs:1655)
AC.Char:_FixedUpdate() (at Assets/AdventureCreator/Scripts/Character/Char.cs:610)
AC.StateHandler:FixedUpdate() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:479)
This is in Unity 2018.4.1f1 and AC 1.67.5.
https://imgur.com/a/fpUxpBm
I'd also note that re-baking the nav mesh and removing and re-adding the characters does not seem to fix it for me. It will occasionally play through successfully but it's pretty rare. When it fails the value of newRotation is always (0.0, 0.0, 0.0, 0.0).
Welcome to the community, @WillD.
A few questions, to help figure out where this is coming from:
This'll be hard to pin down without seeing the issue for myself, but try opening up Char.cs, and inserting the following just inside the _Awake function (around line 396):
Please try both of these additions separately, and together (i.e. all 3 combinations) and let me know which work (if any). If all else fails, you can PM me your scene + character prefabs as a .unitypackage file - but let's see the results of this first.
Thanks Chris!
Adding the newRotation=TransformRotation in the _Awake function solves the issue. It also works with newRotation=TransformRotation and lookDirection=TransformForward, but not with just lookDirection=TransformFoward. Not sure what's up with my character models that causes the issue. I made them out of Reallusion's character creator. In any case, thanks for coming up with a fix for it so quickly!
Thanks for the feedback.