ok im making a showcase app for showing production models around to view glitches etc.. I have this code but it doesn't seem to work: Code (csharp): var isrotate = false; function Update () { //transform.Rotate (0, 50 * Time.deltaTime ,0); if (isrotate) { transform.Rotate ((Input.GetAxis ("Vertical") * 50) * Time.deltaTime,(Input.GetAxis ("Horizontal") * 50) * Time.deltaTime, 0); } } function OnMouseEnter () { } function OnMouseDown () { isrotate = true; } function OnMouseUp () { isrotate = false; } Whats wrong?
Not quite sure what you want to do but, your code will: Rotate the object the script is attached to, when the arrow keys are pressed and the mouse is over the collider of the object and the mouse is pressed down.
Yea that was entirely wrong I made this which works but I want the value to be reverse, how do I do this? Code (csharp): var isrotate = false; function Update () { //transform.Rotate (0, 50 * Time.deltaTime ,0); if (isrotate == true) { transform.Rotate ((Input.GetAxis ("up") * 10) * Time.deltaTime, (Input.GetAxis ("side") * 10) * Time.deltaTime, 0); } } function OnMouseDown () { isrotate = true; } function OnMouseUp () { isrotate = false; }
the up and sides are x and y values of the mouse position so you can rotate the model around at will, looking at what you want on the model..
mm, that might work out better thanks! You mean using rotatearound the obj on the camera right? Im trying that!
Hmm I can't get it to move in two(3) axes! Code (csharp): var isrotate = false; var cam : Transform; function Update () { if (isrotate == true) { cam.RotateAround (transform.position, Vector3.up, (Input.GetAxis ("side") * 20) * Time.smoothDeltaTime ); // (Input.GetAxis ("up") * 20) * Time.smoothDeltaTime } } function OnMouseDown () { isrotate = true; } function OnMouseUp () { isrotate = false; }
ok, one more thing: It would be really cool if the Vector was oriented after the world values, because now when I turn the obj the controlls reverse!