-3
我想編碼對手在兩點之間移動並摧毀玩家,如果觸摸。沒有超載的方法'距離'需要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個參數。」
如何解決?
錯誤信息的哪一部分讓你感到困惑?沒有這些信息就很難提供有用的幫助。 –
在問題的當前狀態中,它看起來沒有任何與成千上萬的類似的任何不同,可以通過搜索錯誤消息來找到 - (例如http://stackoverflow.com/questions/19517794/how-to-fix-no -overload-for-method-takes-0-arguments我用作重複)。如果這不能提供足夠的解釋 - 確保編輯你的問題,以澄清你不明白的東西(可能需要爲此提出新的更具體的問題)。 –