Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unitry raycast

using UnityEngine;
//This will cast a raycast from the mouse to the world
public class ExampleClass : MonoBehaviour
{
    void FixedUpdate()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, 100))
            print("Object hit!");
    }
}
 
PREVIOUS NEXT
Tagged: #unitry #raycast
ADD COMMENT
Topic
Name
4+2 =