Search Unity

Get screen coordinates of an object

Discussion in 'Scripting' started by devknob, May 20, 2009.

  1. devknob

    devknob

    Joined:
    Apr 2, 2009
    Posts:
    66
    Im trying to get the screen coordinates of an object so that I can make it walk on a plane that has white and black on it. The problem im having is using WorldToScreenPoint and ScreenToWorldPoint I get numbers other than 320x480.
     
  2. devknob

    devknob

    Joined:
    Apr 2, 2009
    Posts:
    66
    the bottom left is -572.9, -351.9, 100
    thats wrong.


    var thePos : Vector3 = Camera.main.WorldToScreenPoint(transform.position);

    -572.9, -351.9, 100
     
  3. devknob

    devknob

    Joined:
    Apr 2, 2009
    Posts:
    66
    I just tried this code snippethttp://unity3d.com/support/documentation/ScriptReference/Camera.WorldToScreenPoint.html

    and it doesnt work either, at least not the way it says it does. It says the bottom left of the screen is 0,0. Not true when im using it.
     
  4. devknob

    devknob

    Joined:
    Apr 2, 2009
    Posts:
    66
    Is there any way to track objects via Screen Coordinates? Like 480x320 for the iphone?