Version: 2021.1
言語: 日本語
public static bool Linecast (Vector3 start, Vector3 end, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

パラメーター

start 始点
end 終点
layerMask レイヤーマスク はレイキャストするときに選択的に衝突を無視するために使用します。
queryTriggerInteraction トリガーに設定されているものも検索対象にするか

説明

始点と終点を設定してそこに線を張り、コライダーがヒットした場合 true を返します

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; void Update() { if (Physics.Linecast(transform.position, target.position)) { Debug.Log("blocked"); } } }

public static bool Linecast (Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

パラメーター

start 始点
end 終点
layerMask レイヤーマスク はレイキャストするときに選択的に衝突を無視するために使用します。
queryTriggerInteraction トリガーに設定されているものも検索対象にするか
hitInfo If true is returned, hitInfo will contain more information about where the collider was hit. (See Also: RaycastHit).

説明

始点と終点を設定してそこに線を張り、コライダーがヒットした場合 true を返します

If true is returned, hitInfo will contain more information about where the collider was hit. (See Also: RaycastHit). Layer mask is used to selectively ignore colliders when casting a ray.