Version: 2019.2
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トリガーに設定されているものも検索対象にするか
hitInfoIf 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.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961