Hi. I’m trying to make that camera can rotate around object with the mouse,Problem in the last line of code,this line was taken from “Scripting API”
"transform.RotateAround(Vector3.zero, Vector3.up, 20 * Time.deltaTime)"and its working fine as it is.
But when i’m trying to change Vector3.up even on "Vector3 (0,1,0)"I have an error.
using UnityEngine;
using System.Collections;
public class camera_switch : MonoBehaviour {
public float ScreenHi = 0.12f;
public float ScreenWi = 0.12f;
public float MenuPosX = 5f;
public float MenuPosY = 20f;
public Transform Obj1;
public Transform Obj2;
public float CamSpeed = 1.0F;
private float time;
private Vector3 currentPos;
private Vector3 toPos;
public float mouseSens = 2.0F;
void OnGUI() {
GUI.Box (new Rect (MenuPosX, MenuPosY, ScreenWi, ScreenHi), "Switch Menu");
if (GUI.Button (new Rect (MenuPosX + 10, MenuPosY + 20, ScreenWi - 20, ScreenHi - 70), "Obj 1")) {
currentPos = Obj1.position;
toPos = Obj2.position;
time=0;
}
if (GUI.Button (new Rect (MenuPosX + 10, MenuPosY + 60, ScreenWi - 20, ScreenHi - 70), "Obj 2")) {
currentPos = Obj2.position;
toPos = Obj1.position;
time=0;
}
}
void LateUpdate() {
float mouseX = Input.GetAxis ("Mouse X") * mouseSens;
float mouseY = Input.GetAxis ("Mouse Y") * mouseSens;
time += Time.deltaTime * CamSpeed;
transform.LookAt(Vector3.Lerp(currentPos,toPos,time));
transform.RotateAround (toPos, Vector3 (mouseX, mouseY, 0) , 20 * Time.deltaTime);
}
}