Hello!
I hope I have asked this in the right spot! SO I am going through the laser Defender videos and got up to the move along path. I have given up after 3 days of trying and copied the code from GitHub, but still the problem remains… IT WONT MOVE! It goes to the first waypoint, but nowhere else. I have checked to make sure the waypoints are in order. I have checked my code, and copied the code (In the end). Here is the copied code I used.
public class EnemyPathing : MonoBehaviour
{
[SerializeField] List waypoints;
[SerializeField] float moveSpeed = 2f;
int waypointIndex = 0;
private void Start()
{
transform.position = waypoints[waypointIndex].transform.position;
}
private void Update()
{
Move();
}
private void Move()
{
if (waypointIndex <= waypoints.Count - 1)
{
var targetPosition = waypoints[waypointIndex].transform.position;
var movementThisFrame = moveSpeed * Time.deltaTime;
transform.position = Vector2.MoveTowards(transform.position, targetPosition, movementThisFrame);
if (transform.position == targetPosition)
{
waypointIndex++;
}
}
else
{
Destroy(gameObject);
}
}
I hope this can be resolved. OH the unity version I am using is 2020.2.5f1.
Thanks