I tried this but it was hopelessly shaky and didn’t work.
var y = Input.mousePosition.y - oldmousey;
var x = Input.mousePosition.x - oldmousex;
transform.rotation.x = transform.rotation.x+x;
transform.rotation.y = transform.rotation.y+y;}
oldmousey = Input.mousePosition.y;
oldmousex = Input.mousePosition.x;
If anyone knows a way I can rotate an object please post it I’m working on an editor like Spore’s.
ForceX
September 4, 2010, 2:13am
2
Apply this to the object you want to rotate with your mouse. For some reason on my setup front an back wont rotate more than 180. Left and right will rotate for ever.
Gets you going any way.
var RotationSpeed : float = 5;
private var MouseX : float;
private var MouseY : float;
function Update () {
MouseX = transform.localEulerAngles.x + Input.GetAxis("Mouse Y") * RotationSpeed ;
MouseY = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * RotationSpeed ;
transform.localEulerAngles = Vector2(MouseX, MouseY);
}