I have this code
var rotationSpeed = 2.0;
var cam : Transform;
function Update () {
//~ var rightCameraRelative : Vector3 = cam.TransformDirection (Vector3.right);
//~ var leftCameraRelative : Vector3 = cam.TransformDirection (-Vector3.right);
if(enableRotate){
if(Input.GetKeyDown(KeyCode.LeftArrow)){
RotateObject(transform.rotation, Quaternion.Euler(transform.rotation.eulerAngles + transform.right * 90), rotationSpeed);
timeCounterStart();
}
if(Input.GetKeyDown(KeyCode.RightArrow)){
RotateObject(transform.rotation, Quaternion.Euler(transform.rotation.eulerAngles + transform.right * -90), rotationSpeed);
timeCounterStart();
}
if(Input.GetKeyDown(KeyCode.UpArrow)){
RotateObject(transform.rotation, Quaternion.Euler(transform.rotation.eulerAngles + transform.up * 90), rotationSpeed);
timeCounterStart();
}
if(Input.GetKeyDown(KeyCode.DownArrow)){
RotateObject(transform.rotation, Quaternion.Euler(transform.rotation.eulerAngles + transform.up * -90), rotationSpeed);
//~ myRotation(Vector3.right);
timeCounterStart();
}
}
giveBackEnableRotate();
}
function RotateObject(startRot : Quaternion, endRot : Quaternion, rotateTime : float)
{
var i = 0.0;
var rate = 1.0/rotateTime;
while (i < 1.0)
{
i += Time.deltaTime * rate;
transform.rotation = Quaternion.Lerp(startRot, endRot, Mathf.SmoothStep(0.0, 1.0, i));
yield;
}
}
function myRotation(axisR){
transform.Rotate(axisR * Time.deltaTime);
yield;
}
var enableRotate =true;
var nextEnable = 0.0;
function giveBackEnableRotate(){//w update
if(!enableRotate){
if( Time.time >= nextEnable)
enableRotate = true;
}
}
function timeCounterStart(){
if(enableRotate){
enableRotate = false;
nextEnable = Time.time + rotationSpeed;
}
}
placed on an empty object that is a parent to the camera (and is placed in the point in the space that I want to rotate around), the problem is, rotation does really "wrap" weird ways... I can't comprehend.
Is there a possibility for much saner camera? the point is to make the camera rotate around the point in the space. along any axis(es) really, up and down, left and right, as long as it wraps correctly. Can any one give me a hand?