Ok, so im trying to rotate my object towards these points i made. I have a transform array, but i cant use it in Vector3.RotateTowards. I dont know much about rotating an object towards one. Here is my script so far,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PathFollower : MonoBehaviour
{
public Transform[] path;
public float speed = 1.0f;
public float reachDistance = 1.0f;
public int currentPoint = 0;
private void Start()
{
}
private void Update()
{
float step = speed * Time.deltaTime;
Vector3 newDir = Vector3.RotateTowards(transform.forward,//How do i put Path[] here? , step, 0.0f);
Vector3 dir = path[currentPoint].position - transform.position;
transform.position += dir * Time.deltaTime * speed;
if (dir.magnitude <= reachDistance)
{
currentPoint++;
}
if (currentPoint >= path.Length)
{
currentPoint = 0;
}
}
private void OnDrawGizmos()
{
if (path.Length > 0)
for (int i = 0; i < path.Length; i++)
{
if (path[0] != null)
{
Gizmos.DrawSphere(path*.position, reachDistance);*
}
}
}
}
Anyone know how this is done or how to do it?