📜  unity raycast - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:17.432000             🧑  作者: Mango

代码示例1
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!");
    }
}