Hi,
I am really struggling here and I need some help with drag and drop gameobject on terrain. I wrote the following code but it gives me a strange result. When i drop my object, it actually bounces from terrain as ball.
void OnMouseDrag () {
Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if(Physics.Raycast(ray,out hit))
{
//We’ve hit something
if(hit.collider.gameObject.name.Equals(“Terrain”)) {
transform.position = hit.point;
}
}
}
What is the best way to do drag and drop gameobject on terrain? I would like to keep game object position where I click my mouse.
Thank you for your help !!!