using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spin : MonoBehaviour
{
[SerializeField]
Transform waypoints;
[SerializeField]
float moveSpeed = 2f;
int waypointIndex = 0;
private Transform t;
// Use this for initialization
void Start()
{
t = GetComponent();
RotateToRandomPosition();
randomRotation = waypoints[waypointIndex].randomRotation;
}
// Update is called once per frame
void Update()
{
Rotate();
}
void Rotate()
{
randomRotation = Vector3.randomRotation(Random, waypoints[waypointIndex].randomRotation,
moveSpeed * Time.deltaTime);
if (randomRotation == waypoints[waypointIndex].randomRotation)
{
waypointIndex += 1;
}
if (waypointIndex == waypoints.Length)
waypointIndex = 1;
}
}