【发布时间】:2016-04-06 16:59:25
【问题描述】:
我正在尝试对对手进行编码,使其在两点之间移动并在触碰玩家时摧毁玩家。
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);
}
}
方法 'Distance' 没有重载需要 1 个参数。"
如何解决?
【问题讨论】:
-
错误信息的哪一部分让您感到困惑?没有这些信息,很难提供有用的帮助。
-
在问题的当前状态下,它看起来与通过搜索错误消息可以找到的数千个类似情况没有任何不同 - (即stackoverflow.com/questions/19517794/…我用作重复项)。如果这不能提供足够的解释 - 请务必编辑您的问题以澄清您不理解的内容(可能需要为此提出新的、更具体的问题)。
标签: c# unity3d unityscript