The example image demonstrates what I'm trying to achieve.
I tried using Recasting from the mouse position but I was getting strange results such as the object instance being far from the surface of the sphere. What would be the best way to go about Instantiating an object at the cursors position on a spherecial object.
var building : GameObject;
function Update ()
{
if(Input.GetMouseButtonDown(0))
{
Build();
}
}
function Build()
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100))
{
Debug.DrawLine (ray.origin, hit.point);
Instantiate(building,hit.point,Quaternion.identity);
}
}
Check all the prefabs pivot points making sure there not out of line of the mesh. In other words check if the object is centered at 0,0,0 otherwise you'll get my problem!