The position is always 0,0,0 for my object, so it is the same thing. I should be using transform.position anyway so the object doesn’t have to be at 0,0,0
Basically is doesn’t allow for the tilt. Moving the mouse in a certain direction will always effect either y or x.
I’m not quite sure I fully understand what you mean by “the tilt”. If you mean that you want the mouse UP motion to be relative to the cube so that it rolls or yaws along it’s own axis this would be similar to the approach I’d use.
#pragma strict
var lastframeMouseY : float;
var lastframeMouseX : float;
var speedRot : float = 5;
function Update ()
{
var deltaMouseX : float = Input.mousePosition.x - lastframeMouseX;
var deltaMouseY = Input.mousePosition.y - lastframeMouseY;
lastframeMouseX = Input.mousePosition.x;
lastframeMouseY = Input.mousePosition.y;
if(((Input.GetMouseButton(0)) || Input.GetKey(KeyCode.LeftControl) ))
{
var rotationAmount : float = Time.deltaTime * speedRot;
var mouseAxis : Vector3 = Vector3(deltaMouseY*rotationAmount, deltaMouseX*rotationAmount,0);
//transform.RotateAround(transform.position,mouseAxis,rotationAmount);
transform.Rotate (mouseAxis.x, mouseAxis.y, mouseAxis.z, Space.Self);
}
}
Edit : CORRECTION (Script error edit)
lastframeMouseX : float = Input.mousePosition.x;
should read as
lastframeMouseX = Input.mousePosition.x;