Hi!
I’m trying to create enemy holding a flashlight and then rotating it randomly. I got to variables, minRot and maxRot which is the points I wanna rotate around. Here is my current code which kind of works but when it picks a rotation it apperes to pick a rotation on the whole 360 axis, not between the points I have specified.
using UnityEngine;
using System.Collections;
public class AIFlashLight : MonoBehaviour {
public float rotSpeed;
public float minRot;
public float maxRot;
public Quaternion targetRot;
void Start () {
SelectNewTargetRotation ();
}
void Update () {
transform.rotation = Quaternion.RotateTowards (transform.rotation, targetRot, rotSpeed * Time.deltaTime);
if(transform.rotation == targetRot) {
SelectNewTargetRotation();
}
}
void SelectNewTargetRotation () {
targetRot = new Quaternion (0, 0, Random.Range (minRot, maxRot), 1.0f);
}
}
Thanks for your help
//Proximal Pyro