2016-04-06 13 views
-3

私は2点間を移動し、タッチされた場合にプレイヤーを破壊する敵をコードしようとしています。メソッド「距離」のオーバーロードが1つの引数を取る

public class MovementBetweenPoints : MonoBehaviour { 
    public Transform[] keyPoints; 
    public float speed; 
    private int currentKeyPoint; 
    public float min_Distance; 
    public float Distance; 

    // Use this for initialization 
    void Start() 
    { 
     transform.position = keyPoints[0].position; 
     currentKeyPoint = 1; 
    } 

    // Update is called once per frame 
    void Update() 
    { 
     // ----------- Error happens on next line 
     if (Vector3.Distance(transform.position - keyPoints[currentKeyPoint].position) <= min_Distance) 
     { 
      currentKeyPoint++; 
     } 

     if (currentKeyPoint >= keyPoints.Length) 
     { 
      currentKeyPoint = 0; 
     } 

     transform.position = Vector3.MoveTowards(transform.position, keyPoints[currentKeyPoint].position, speed * Time.deltaTime); 
    } 

    void OnTriggerEnter(Collider Player) 
    { 
     Destroy(Player.gameObject); 
    } 

} 

方法についてませオーバーロード「の距離が」1つの引数を取りません。」

それを修正する方法は?

+1

エラーメッセージのどの部分があなたに混乱していますか?その情報なしで*役に立つヘルプを提供することは非常に難しいです。 –

+0

質問の現状では、何千もの類似したものとは違い、エラーメッセージを検索して見つけられます(つまり、http://stackoverflow.com/questions/19517794/how-to-fix-no -overload-for-method-takes-0-argumentsを重複として使用する)。それで十分な説明が得られない場合は、あなたが理解していないことを明確にするためにあなたの質問を編集してください(新しい、より具体的な質問をする必要があるかもしれません)。 –

答えて

0

Distanceコールは2点間の距離が、あなたが書いたコードを返します。 1点しか与えられません。あなたは "、"をしたいところに " - "あると思います。
これを試してみてください:

if (Vector3.Distance(transform.position, keyPoints[currentKeyPoint].position) <= min_Distance) 
+0

それでした!手伝ってくれてどうもありがとう! –

関連する問題