Version: 5.3 (switch to 5.4b)
언어English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Physics.Linecast

Suggest a change

Success!

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.

닫기

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

닫기

취소

Switch to Manual
public static function Linecast(start: Vector3, end: Vector3, layerMask: int = DefaultRaycastLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): bool;
public static bool Linecast(Vector3 start, Vector3 end, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
public static function Linecast(start: Vector3, end: Vector3, layerMask: int = DefaultRaycastLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): bool;
public static bool Linecast(Vector3 start, Vector3 end, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
public static function Linecast(start: Vector3, end: Vector3, layerMask: int = DefaultRaycastLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): bool;
public static bool Linecast(Vector3 start, Vector3 end, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

파라미터

start Start point.
end End point.
layerMask Layer mask는 레이 캐스팅 시에 콜라이더를 선택적으로 무시하는데 사용됩니다.
queryTriggerInteraction Specifies whether this query should hit Triggers.

Description

어떤 콜라이더가 /start/와 /end/사이의 선에 교차할 경우 true를 반환합니다.

	var target : Transform;
	function Update () {
		if (Physics.Linecast (transform.position, target.position)) {
			Debug.Log ("blocked");
		}
	}
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 function Linecast(start: Vector3, end: Vector3, out hitInfo: RaycastHit, layerMask: int = DefaultRaycastLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): bool;
public static bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
public static function Linecast(start: Vector3, end: Vector3, out hitInfo: RaycastHit, layerMask: int = DefaultRaycastLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): bool;
public static bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
public static function Linecast(start: Vector3, end: Vector3, out hitInfo: RaycastHit, layerMask: int = DefaultRaycastLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): bool;
public static bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

파라미터

start Start point.
end End point.
layerMask Layer mask는 레이 캐스팅 시에 콜라이더를 선택적으로 무시하는데 사용됩니다.
queryTriggerInteraction Specifies whether this query should hit Triggers.
hitInfo True가 반환되면, /hitInfo/는 충돌한 콜라이더에 대한 더 자세한 정보를 포함할 것입니다. (See Also: RaycastHit).

Description

어떤 콜라이더가 /start/와 /end/사이의 선에 교차할 경우 true를 반환합니다.

True가 반환되면, /hitInfo/는 충돌한 콜라이더에 대한 더 자세한 정보를 포함할 것입니다. (See Also: RaycastHit). Layer mask는 레이 캐스팅 시에 콜라이더를 선택적으로 무시하는데 사용됩니다.