Hello, I have a 2d game that is laying down in the x & z. You click and drag a game object across the screen. This work, the only problem I have is, when I get the 'hit.point' the 'y' that gets returns is extremely 'high'. I try and set it manually after but it glitches and jumps back and forth from the 'y' in the hit.point to the 'y' that i set manually. Any help at all would be greatly appreciated. Thanks Fabrizio
function Update ()
{
if (Input.GetButton("Fire1"))
{
var ray: Ray = mCamera.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if (Physics.Raycast(ray, hit))
{
if(!rockCreated)
{
var rock: GameObject;
var newPosition = Vector3(hit.point.x, hit.point.y, hit.point.z);
rock = Instantiate(rockPrefab, newPosition, City.transform.rotation);
Physics.IgnoreCollision(rock.collider, City.collider);
currRock = rock;
}
}
if(rockCreated)
{
Debug.Log("Y position of Hit" + hit.point.y);
currRock.transform.position.x = hit.point.x;
currRock.transform.position.z = hit.point.z;
//currRock.transform.position.y = hit.point.y;
}
}
}