我正在跟踪敌人,但遇到此错误:
错误CS0029:无法将UnityEngine.Vector3'类型隐式转换为bool'
这是我的代码:
IEnumerator FollowPath(Vector3[] waypoints)
{
transform.position = waypoints[0];
int targetWaypointIndex = 1;
Vector3 targetWaypoint = waypoints[targetWaypointIndex];
while (true)
{
transform.position = Vector3.MoveTowards(transform.position, targetWaypoint, speed * Time.deltaTime);
if (transform.position = targetWaypoint) //error comes at this line
{
targetWaypointIndex = (targetWaypointIndex + 1) % waypoints.Length;
targetWaypoint = waypoints[targetWaypointIndex];
yield return new WaitForSeconds(waitTime);
}
yield return null;
}
}
,这里是我在本教程中使用的脚本。
如何解决此问题,我在做什么错了?
答案 0 :(得分:4)
以下行有错误:
A<int>
您正在分配值而不是进行比较,应该是
rect