Hi All
So I am trying to have a ray rotate 90 degrees to either side of a parent object.Think a robot with an eye that scans from side to side .Now the code below works only if the parent is facing forward and never rotates any solutions to get it to work with a rotating parent?.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotateray1 : MonoBehaviour
{
int limit=0;
public int rotspeed;
private void Update()
{
if (limit<=0){
transform.Rotate(0, - rotspeed,0);
if ( transform.eulerAngles.y<270&& transform.eulerAngles.y>269)
{limit=1;}
}
else
{
limit=1;
transform.Rotate(0, rotspeed,0);
if ( transform.eulerAngles.y>90&& transform.eulerAngles.y<91){limit=0;}
}
}
}