hey guys , so i’m using a script to make my object look at the target only on y axis. is there any way to limit the object’s rotation? for example rotate on y axis only 45 and -45 degrees thanks
public class lookonlyony : MonoBehaviour {
public GameObject target;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 targetPosition = new Vector3 (target.transform.position.x,transform.position.y, target.transform.position.z);
transform.LookAt (targetPosition);
}
}