Professional Documents
Culture Documents
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Update()
{
//Establishes a pre-established forward/backward travel path for
objects/obstacles/enemies within the game world.
if(Vector2.Distance(waypoints[current].transform.position, transform.position) <
WPradius)
{
current++;
if(current >= waypoints.Length)
{
current = 0;
}
}
transform.position = Vector2.MoveTowards(transform.position,
waypoints[current].transform.position, Time.deltaTime * speed);
}
}