Hello,
I have a little problem and i need your help. I developing an building control as RTS games. My problem is ;
I trying to build with following code and i can build my object easly with this code but my building code build my object up to fixed object(mouse’s attached object). when i attached an 3d object to my mouse. Input.mousePosition get object’s highest point which object attached mouse or which object fixed when building. How can i get Terrain position when building? How can i get Terrain.transform.position.y and use it?
Note : Mouse’s attached object’s base touch to Terrain.
function Update ()
{
if (Input.GetMouseButtonDown (0)) {
var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if (Physics.Raycast(ray, hit)) {
Instantiate(Object1, hit.point, Quaternion.identity);
}
}
}
Regards
Vincenzo