Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Vector3.Reflect does not preserve magnitude of vector

Discussion in 'Editor & General Support' started by crowmagnon, Feb 21, 2013.

  1. crowmagnon

    crowmagnon

    Joined:
    Mar 2, 2011
    Posts:
    36
    I assume when reflecting a vector about another vector, that the resulting vector should be the same magnitude as the input vector but just a different direction. So I'm baffled at why the result I'm getting to this:

    var reflectVec = Vector3.Reflect(Vector3(0, -7.4, 0), Vector3(.1, 1.4, 0));

    is that reflectVec = (2.072, 21.608, 0).

    Is this a bug in how Reflect is implemented? I would expect the Vector3.magnitude of the answer to be the same as the input vector.
     
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,171
    The surface vector needs to be normalized to give a valid reflect vector.
     
  3. crowmagnon

    crowmagnon

    Joined:
    Mar 2, 2011
    Posts:
    36
    Oh yeah, that makes sense. Thanks!