お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeray | 始点とレイの方向 |
hitInfo | trueが返された時、 hitInfo はヒットしたコライダーについての情報が含まれています。(See Also: RaycastHit) |
distance | 適用する距離 |
bool 飛ばしたレイがコライダーにヒットした際に、trueを返します。それ以外はfalseです。
このコライダーのみを判断するRayを飛ばします。他のコライダーは無視されます。
function Update(){ var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hit : RaycastHit; if (collider.Raycast(ray, hit, 100.0)) { Debug.DrawLine(ray.origin, hit.point); } }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (collider.Raycast(ray, out hit, 100.0F)) Debug.DrawLine(ray.origin, hit.point); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Update() as void: ray as Ray = Camera.main.ScreenPointToRay(Input.mousePosition) hit as RaycastHit if collider.Raycast(ray, , 100.0F): Debug.DrawLine(ray.origin, hit.point)