Using a raycast to make an object disappear
- Keshav Batra
- Dec 17, 2021
- 1 min read
Below is the code that I used to make this disappear
Ray DisappearRay = new Ray(cam.transform.position, cam.transform.forward);
if (Input.GetKeyDown(KeyCode.T))
{
if (Physics.Raycast(DisappearRay, out hit, MaxDistance)) //This is a raycast
{
Debug.DrawRay(cam.transform.position, cam.transform.forward * MaxDistance);
Destroy(Sphere);
}
}
Here's the result:
Komentar