Demigiant / dotween

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

Index out of range #568

Open juicedup12 opened 2 years ago

juicedup12 commented 2 years ago

I'm trying to tween a Matrix4x4. I loop through all 16 matrix values and make a new tween. At first I was getting an error saying invalid index when I do Matrix4x4[i], so I thought I would make an array, but I get an out of index exception.

Here's my current code:


    {
        if(Keyboard.current.spaceKey.isPressed && !Transitioning)
        {
            if (orthoOn)
            {
                Transitioning = true;
                Matrix4x4 tmp = m_camera.projectionMatrix;
                float[] startMat = new float[16];
                float[] endMat = new float[16];
                for (int i = 0; i <16; i++)
                {
                    startMat[i] = tmp[i];
                    endMat[i] = perspective[i];
                    print("value is " + startMat[i]);
                    DOTween.To(() => startMat[i], x => startMat[i] = x, endMat[i], 3);
                }
                m_camera.projectionMatrix = tmp;
            }
}
Demigiant commented 2 years ago

Ahoy!

The exception is related to the Matrix, not to DOTween I assume? I think you should look into that because it's an issue external to the tweening, but if you show me the error log maybe I can help.

Cheers, Daniele