Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Vector3 arthmetic misbehaves when debugging.

Discussion in '5.5 Beta' started by georgeq, Nov 17, 2016.

  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    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:

    Code (CSharp):
    1.  
    2.       Vector3 dir  = (trans.position-Core.position).normalized;
    3.       Vector3 test = dir*10000;
    4.       Debug.Log(test.magnitude);
    5.  
    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...
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,132
    Hi georgeq,
    Thanks for reporting this! Could we get a bug report with the reproduction case please?
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @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.
     
  4. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    I upgraded to 5.5b11 and the problem seems to be fixed.

    Thank you!
     
    LeonhardP likes this.