Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.3k stars 346 forks source link

New behavior when rotating transform 180 degrees #601

Closed Reniestra closed 1 year ago

Reniestra commented 1 year ago

Recently updated to 1.0.330 version and I am getting a different behavior with transform.DORotate() when rotating Y axis by 180 degrees. Now it is sometimes rotating via different axis. I also tried to get the same behavior I had before the update using transform.DOLookAt(AxisConstraint.Y), but I am getting the same issue. Am I missing something or is it a bug introduced with the new version?

Thanks!

Edit: just noticed that someone reported this issue or a similar one in the Unity forum thread at post #3883

Joknaa commented 1 year ago

Did you check the transform of the parents of the game object ? it could be that it has a rotation there, that messes up the rotation axes.

Reniestra commented 1 year ago

The parent of the Transform is the scene itself. Also this out of Y axis rotation never happend with the previous version of DOTween. It started to happen after the update. Unity version is 2021.3.6f1. I only have the issue when rotating by 180 degrees, but dorusoftware reported the same problem with 90 degree rotations in the unity forum last month.

Demigiant commented 1 year ago

Ahoy. Trying to replicate this so I can fix it. The latest version had introduced a fix to a bug where rotations would wobble in very rare cases, and I fear it might've caused this issue. Will hopefully push an update today.

Demigiant commented 1 year ago

P.S. If you have an example of how to replicate this issue it would help, because at the moment I've been trying various things but I can't

Demigiant commented 1 year ago

Managed to reproduce it (at least the issue that was posted in the forums). Working on a fix now :)

Demigiant commented 1 year ago

Question... is your RotateModeset to WorldAxisAdd or LocalAxisAdd? Because it seems that this issue is only related to those modes, but if you tell me you're using others than I'm banging my head on the wrong wall 👀

Reniestra commented 1 year ago

I used the following, and both had the same issue: transform.DORotate(endValue: new Vector3(0.0f, 180.0f, 0.0f), duration: 0.4f) transform.DOLookAt(towards: new Vector3(giving a target that is at 180 degrees), duration: 0.4f, AxisConstraint.Y)

RotateMode should be Fast (default) as I didn't change it

Demigiant commented 1 year ago

Ouch! I'm going to dig deeper then

Demigiant commented 1 year ago

Ahoy! It was complicated but I should've fixed it in all cases! Could you check if this update fixes it for you (it contains only DOTween's core, but it's ok since that's where the changes were made, Pro can remain the same)?

Reniestra commented 1 year ago

Yes, it solved the issue for me! Great!

Demigiant commented 1 year ago

Wonderful. Going to release it publicly today then ^_^

Reniestra commented 1 year ago

Awesome!

ttesla commented 1 year ago

Because it seems that this issue is only related to those modes, but if you tell me you're using others than I'm banging my head on the wrong wall

complicated but I should've fixed it in all cases! Could you ch

I guess this fix breaks LocalAxisAdd mode. It wobbles at 180. You can try it. Put a Cube in the scene, attach this script and press Q, you will notice the bug at 180 degree. It somehow jumps to -180 and whobbles.

public class TestTweenCode : MonoBehaviour
{
    private Vector3 mRotVal = new Vector3(60.0f, 0.0f, 0.0f);

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Q)) 
        {
            transform.DOLocalRotate(mRotVal, 0.1f, RotateMode.LocalAxisAdd).SetEase(Ease.OutQuad);
        }
    }
}
Demigiant commented 1 year ago

Ouch! I understood why LocalAxisAdd broke because of that fix (and WorldAxisAdd too) and this v1.2.710 fixes it (while not touching anything about other RotateModes, so those won't be rebroken for sure). Can you check it out and confirm it too?

ttesla commented 1 year ago

Yes, v.1.2.710 fixes the problem. No wobble. But it still jumps to -180 when it should be 180. They both mean the same thing but it may create new problems. So its like: 0 -> 60 -> 120 -> -180 . Is it the expected behaviour?

ttesla commented 1 year ago

Transform Chamber

Demigiant commented 1 year ago

Ah, yes, that is expected behavior. Unity's Inspector shows an on-the-fly conversion of Quaternion to Vector3, and some rotations can be represented by multiple different Vector3 values, but DOTween continues using the ones you inputted when animating

ttesla commented 1 year ago

Ok, issue is solved then. Thank you ;)