Trying to make a script that will enable a game object to follow a set of waypoints.
But getting error -
Assets/WaypointInvaderMove.cs(15,50): error CS1503: Argument #2' cannot convert
UnityEngine.Transform’ expression to type `UnityEngine.Vector3’
Script -
using UnityEngine;
using System.Collections;
public class WaypointInvaderMove : MonoBehaviour
{
public Transform[] movePositions; // Create array(list) of positions/co-ords
int moveToIndex = 0;
public float speed = 5f;
void Update()
{
if(moveToIndex < movePositions.Length) //if moveToIndex is less than total array items/index do...
{
Vector3 newPos = Vector3.MoveTowards(transform.position, movePositions[moveToIndex], speed * Time.deltaTime);
transform.position = newPos;
if(newPos == movePositions[moveToIndex]) //if current position = the same as array index do...
{
moveToIndex++; // move to the next array index position
}
}
}
}
How do I fix this problem ?
???