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.
Thanks - C
Another strange result is the object instantiating slightly offset form where the mouse clicks.
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);
}
}
The Debug.DrawLine is something i have been ;looking to do for ages but not known how. thanks so much!
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!
Right, this answer is more than confusing. Static classes are never serialized by almost any serialization system. This includes Unity's serialization system. The question was specifically about singletons and editor scripts but the example is neither a singleton nor an editor script.
Another strange result is the object instantiating slightly offset form where the mouse clicks.
– CaiuseSounds like your prefab isn't centered around 0, 0, 0 then.
– Statement