Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to avoid normalizing zero-length vector3s?

Discussion in 'Visual Effect Graph' started by dgoyette, Sep 14, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I found that I was getting a lot of error spam when I was normalizing a vector3, and passing that into a Sample Curve. I found this was because sometimes the Vector3 was zero-length, and normalizing a zero-length Vector3 doesn't make sense. However, I don't see how I can conditionally avoid that case.

    For example, here's a graph where I'm trying to detect that a Vector3 is length zero, and to branch to something other than evaluating the Normalize on that vector3. However, despite this, it still emits error spam:

    upload_2020-9-14_11-29-42.png

    This emits:

    Assertion failed on expression: 'curveT >= GetRange().first && curveT <= GetRange().second'
    Assertion failed on expression: 'curveT >= m_Curve[lhs].time && curveT <= m_Curve[rhs].time'

    Over and over. Is there some way for me to properly detect that a vector3 is zero-length, and to prevent normalizing it?