top of page
Search

Using a raycast to make an object disappear

  • Writer: Keshav Batra
    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


bottom of page