Search Unity

Rays, Points and Ports

Discussion in 'Scripting' started by marty, Jul 25, 2006.

  1. marty

    marty

    Joined:
    Apr 27, 2005
    Posts:
    1,170
    I'd like to be able to get the position in worldspace that corresponds to the pixel rendering at a specific location in the viewport.

    I've seen how I can use ScreenPointToRay to get this information on the location I have clicked on in the viewport. But what I want is the same information returned for a specific position in the viewport.

    I want this so that I can fire a projectile along a ray cast from the viewport camera to the location under a reticle that oves around inside the viewport.

    Any suggestions?
     
  2. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    ViewportToWorldPoint?
     
  3. marty

    marty

    Joined:
    Apr 27, 2005
    Posts:
    1,170
    I thought that might be the rascal I was looking for, but I can't figure out how to write any code for it.

    Boy, I can't wait until the Unity online reference has a code example for each class and method.
     
  4. marty

    marty

    Joined:
    Apr 27, 2005
    Posts:
    1,170
    Nevermind, I figured it out.

    Turns out I needed to use ''WorldToScreenPoint''.