Bounds.IntersectRay
Declaration
public bool IntersectRay(Ray ray);Описание
Пересекается ли ray с этой границей?
using UnityEngine;
public class Example : MonoBehaviour { // Function to detect if a ray (representing a beam weapon, say) // makes contact with the collider's bounds.
Collider myCollider;
void Start() { // Store a reference to the collider once at startup. myCollider = GetComponent<Collider>(); }
bool DetectHit(Ray ray) { return myCollider.bounds.IntersectRay(ray); } }
Declaration
public bool IntersectRay(Ray ray, out float distance);Описание
Пересекается ли ray с этой границей?
Когда функция возвращает true, расстояние до источника луча будет возвращено в параметре distance.