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. Dismiss Notice

WorldToViewportPoint not normalized??

Discussion in 'Scripting' started by aubergine, May 24, 2014.

  1. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,862
    camera.WorldToViewportPoint function according to documents gives a normalized result (between 0-1) but i get funny results which are not normalized at all.
    Is this a known bug or something?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    How funny?
     
  3. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,862
    something like this: (3.5, 2.8, 5.9)
    z is correct, but x and y are not normalized at all??
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    The docs don't say the results will be normalized, they just say that viewport space is normalized. Naturally if you have an input value outside the viewport, the output will reflect that.

    --Eric
     
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    This method doesn't return a normalized vector (vector of length 1) and does not clamp values between 0 and 1.

    It simply says the screen space is between 0 and 1. Higher or lower value are simply object outside the screen view.
     
  6. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,862
    Thanks, that explains.
    Well the language used in the documents is alittle vague.
     
    krisventure likes this.