Questions like this have been asked before but not quite in the context im looking for. I need to find the world coordinates of a point that is clicked on a screen. I can only get this working when clicking on a gameObject, but I want it to find the coordinates whether or not there is.anything to click there.

As you have probably read, using a raycast will return the hit.point in the world-space. If you are not clicking on a collider, then how far away from the camera should your input return a world-space position. It would be like pointing at the sky and saying “put a star there”, where? how far away?

If you don’t have a collider to raycast against for depth reference, but you know the distance from the camera you would like the point to be, you can use Ray :

#pragma strict

public var distance : float = 4.5;

function Update() {
    CastRayToWorld();
}

function CastRayToWorld() {
    var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);    
    var point : Vector3 = ray.origin + (ray.direction * distance);    
    Debug.Log( "World point " + point );
}

There is no necessary coordinate of a position clicked on the screen - you have to click something to give you a perspective and distance. Normally what you would have is a very large plane representing the ground and see where on that you clicked.

@alucardj How do you get the coordinates in variables