using UnityEngine;
using System.Collections;
public class RotationScript : MonoBehaviour
{
private float fromAngle;
private float toAngle = 90f;
private float yVel = 0.0f;
public float smooth = 0.3F;
private float yAngle;
void Update()
{
//move the MainCamera to the CameraAnchor’s position
Camera.mainCamera.transform.position = transform.position;
//when “a” is pressed…
if (Input.GetKeyDown(KeyCode.A))
{
orbitLeft();
}
}
void LateUpdate()
{
//have the MainCamera look at the CameraTarget’s positon
Camera.mainCamera.transform.LookAt(target.position);
}
void orbitLeft()
{
//set fromAngle as the y eulerAngles of the current transform.
fromAngle = transform.eulerAngles.y;
//set toAngle as fromAngle + 90
toAngle = fromAngle + 90;
//set yAngle to equal a SmoothDampAngle from
yAngle = Mathf.LerpAngle(fromAngle, toAngle, Time.deltaTime);
//rotate the CameraTarget 90 degrees
GameObject.Find(“CameraTarget”).transform.eulerAngles = new Vector3(0, yAngle,0); //Rotate(0, yAngle, 0);
}
}