I’m trying to rotate a Camera game object to the right by referencing game object.
using UnityEngine;
using System.Collections;
public class CameraRotate : MonoBehaviour {
public float startCameraYRotation;
public float cameraSpin = .20f;
void Start(){
//Note: Here I attempted to spin the camera
//gameObject.transform.localEulerAngles = new Vector3(0,cameraSpin , 0.0f);
//Note: Next Attempt using a reference to the game object
GameObject gameObject = new GameObject(); getTRotation(ref gameObject);
transform.localEulerAngles = new Vector3(0,cameraSpin , 0.0f);
}
//NOTE: a reference to the game object
void getTRotation(ref GameObject gameObject){
//NOTE: Attempting to Change the Y Value in this function
//NOTE: adds .2f to the y value of game objects transform.rotation.y which should turn the camera (game object) right
//gameObject.transform.rotation.y += cameraSpin * Time.deltaTime;
//gameObject.transform.rotation = Quaternion.AngleAxis(cameraSpin, Vector3.right);
//transform.localEulerAngles.y += cameraSpin * Time.deltaTime;
//transform.localEulerAngles = new Vector3(0,cameraSpin , 0.0f);
}
void Update(){
if (Input.GetKeyDown (KeyCode.C)) {
//NOTE:Prints the current value of game objects transform rotation y value
startCameraYRotation = gameObject.transform.rotation.y;
Debug.Log (startCameraYRotation);
}
}
}
any ideas