Why this script dont work properly? any ide to fix it?

Hey i need help with creating script. I have isometric camera and i have script that allow me moving it and zooming in/out but i need something that allow me rotating it by 45 degree when i click left or right arrow and 30 degree when i click up button (and of course backing to previous position when i click down arrow)
any idea how it should look?
thank 4 all help

function Update () {

/////////////////////

//keyboard rotate

var translationX : float =
Input.GetAxis(“Horizontal”);

var translationY : float =
Input.GetAxis(“Vertical”);

var fastTranslationX : float = 2 *
Input.GetAxis(“Horizontal”);

var fastTranslationY : float = 2 *
Input.GetAxis(“Vertical”);

if (target) {

x += Input.GetAxis(“Right”) * xSpeed *
0.02;

y -= Input.GetAxis(“Up”) * ySpeed *
0.02;

y = ClampAngle(y, yMinLimit,
yMaxLimit);

var rotation = Quaternion.Euler(y, x,
0);

var position = rotation * Vector3(0.0,
0.0, -distance) + target.position;

}

////////////////////

//mouse scrolling

var mousePosX = Input.mousePosition.x;

var mousePosY = Input.mousePosition.y;

var scrollDistance : int = 5;

var scrollSpeed : float = 70;

//Horizontal camera movement

if (mousePosX < scrollDistance)

//horizontal, left

{

transform.Translate(-1, 0, 1);

}

if (mousePosX >= Screen.width -
scrollDistance)

//horizontal, right

{

transform.Translate(1, 0, -1);

}

//Vertical camera movement

if (mousePosY < scrollDistance)

//scrolling down

{

transform.Translate(-1, 0, -1);

}

if (mousePosY >= Screen.height -
scrollDistance)

//scrolling up

{

transform.Translate(1, 0, 1);

}

////////////////////

//zooming

var Eye : GameObject =
GameObject.Find(“Eye”);

//

if (Input.GetAxis(“Mouse ScrollWheel”)

0 && Eye.camera.orthographicSize > 4)

{

Eye.camera.orthographicSize =
Eye.camera.orthographicSize - 4;

}

//

if (Input.GetAxis(“Mouse ScrollWheel”)
< 0 && Eye.camera.orthographicSize <
80)

{

Eye.camera.orthographicSize =
Eye.camera.orthographicSize + 4;

}

//default zoom

if (Input.GetKeyDown(KeyCode.Mouse2))

{

Eye.camera.orthographicSize = 50;

}

2 Answers

2

up! can anyone help me? i wrote on unity forum in scripts but they advice me to write here.

You can use transform.Rotate(eulerAngles, Space.Self);

Attach a script to the object you want to rotate. Create a method

RotateMyObject(Vector3 angleToRotate)

{
      vector3 angle = currentAngle-angleToRotate;
      transform.Rotate( angle , Space.Self);
}

U can call this method when you click on your buttons and pass the angle values.