Hi,
i want to rotate around the center Object, but with min/max Angles.
my script works with 360°, but i can't limit the rotation.
Have somebody an idea? Thank you very much.
using UnityEngine;
using System.Collections;
public class RotateAroundScript : MonoBehaviour {
public Transform center;
public float rotationSpeed = 80.0f;
public Vector3 axis = Vector3.up;
public Transform PlayerFlip;
public float speed = 1.5f;
void Update ()
{
if (Input.GetKey (KeyCode.UpArrow) && PlayerFlip.localScale.x ==1)
{
transform.RotateAround (center.position, axis, rotationSpeed* Time.deltaTime);
}
if (Input.GetKey (KeyCode.DownArrow) && PlayerFlip.localScale.x ==1)
{
transform.RotateAround (center.position, -axis, rotationSpeed* Time.deltaTime);
}
if (Input.GetKey (KeyCode.UpArrow) && PlayerFlip.localScale.x ==-1)
{
transform.RotateAround (center.position, -axis, rotationSpeed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.DownArrow) && PlayerFlip.localScale.x ==-1)
{
transform.RotateAround (center.position, axis, rotationSpeed * Time.deltaTime);
}
}