言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

NavMeshPath.corners

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.

Close

Sumbission failed

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

Close

Cancel

public var corners: Vector3[];
public Vector3[] corners;
public corners as Vector3[]

Description

パスのコーナーポイント (Read Only)

別名 "waypoint" は経路上で向きを変えて曲がる地点を定義します(すなわち、経路は waypoint を結ぶ複数の直線から成ります)。

// Calculate the length of a NavMeshPath. A character will
// typically move a slightly longer distance than this as a
// result of its steering behaviour.
function PathLength(path: NavMeshPath) {
	// The length is implicitly zero if there aren't at least
	// two corners in the path.
	if (path.corners.Length < 2)
		return;
	
	var previousCorner = path.corners[0];
	var lengthSoFar = 0.0;
	
	// Calculate the total distance by adding up the lengths
	// of the straight lines between corners.
	for (var i = 1; i < path.corners.Length; i++) {
		var currentCorner = path.corners[i];
		lengthSoFar += Vector3.Distance(previousCorner, currentCorner);
		previousCorner = currentCorner;
	}
	
	return lengthSoFar;
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    float PathLength(NavMeshPath path) {
        if (path.corners.Length < 2)
            return;
        
        Vector3 previousCorner = path.corners[0];
        float lengthSoFar = 0.0F;
        int i = 1;
        while (i < path.corners.Length) {
            Vector3 currentCorner = path.corners[i];
            lengthSoFar += Vector3.Distance(previousCorner, currentCorner);
            previousCorner = currentCorner;
            i++;
        }
        return lengthSoFar;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def PathLength(path as NavMeshPath) as float:
		if path.corners.Length < 2:
			return
		previousCorner as Vector3 = path.corners[0]
		lengthSoFar as float = 0.0F
		i as int = 1
		while i < path.corners.Length:
			currentCorner as Vector3 = path.corners[i]
			lengthSoFar += Vector3.Distance(previousCorner, currentCorner)
			previousCorner = currentCorner
			i++
		return lengthSoFar