- Home /
Question by
ggnoob003 · Oct 15, 2020 at 04:32 PM ·
deletedrag objects
How do we delete a GameObject by dragging it into a corner in ARCamera?
void Move() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); if (Physics.Raycast(ray, out hit, 30.0f, LayerMask.GetMask("Surface"))) {
transform.position = new Vector3(hit.point.x,
transform.position.y,
hit.point.z);
var viewportPos = Camera.main.WorldToViewportPoint(transform.position);
if (viewportPos.x > 0.9 && viewportPos.y < 0.1)
{
Destroy(this);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613013845im_/https://answers.unity.com/themes/thub/images/avi.jpg)