赞
踩
ray | The starting point and direction of the ray. |
distance | The length of the ray. |
hitInfo | If true is returned, hitInfo will contain more information about where the collider was hit (See Also:RaycastHit). |
layerMask | A Layer mask that is used to selectively ignore colliders when casting a ray. |
bool True when the ray intersects any collider, otherwise false.
Same as above using /ray.origin/ and /ray.direction/ instead of origin and direction.
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) Debug.DrawLine(ray.origin, hit.point); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。