Vector3 arthmetic misbehaves when debugging.

I’m having trouble to debug functions that use vector arithmetic (Unity 5.5.0b10), because Vector3 misbehaves when the debugger is active, I tested with both Visual Studio and Mono develop and I’m getting the same behavior in both.

One of the problems I have is in this piece of code:

      Vector3 dir  = (trans.position-Core.position).normalized;
      Vector3 test = dir*10000;
      Debug.Log(test.magnitude);

If I run this without the debugger, the reported value at the console is 10000, as expected… however when I set a break point before these lines and go step by step, sometimes it seems like the value assigned to test is completely random, so I’m getting all sorts of crazy values when I try to evaluate magnitude, if I set the break point after these lines, the reported value is correct. I’m having similar problems with other arithmetic operations. As far as I can tell right now, the problem is caused by the multiplication not by the normalization. I’m experiencing similar problems with other arithmetic operations.

This does not happen on Unity 5.3.5p8…

Hi georgeq,
Thanks for reporting this! Could we get a bug report with the reproduction case please?

@georgeq

Actually, we have corrected a bug that looks very much like this in 5.5b11. Can you give that version a try? If the problem still happens, then please submit a bug report.

I upgraded to 5.5b11 and the problem seems to be fixed.

Thank you!

1 Like