How do I make rotation with the mouse more intuitive?

Hi guys,

This is a question regarding the rotation of platform with the mouse. The platforms have rotational pivots in the middle (please see the image supplied).

The platforms rotate relative the mouse’s X-POSITION. And it feels quite counter-intuitive. We tried changing the platform rotation to rotate relative to the mouse’s Y-POSITION which was a small improvement, but it feels counter-intuitive nonetheless.

Our user-testing shows problems with users rotating the platforms with ease.

Does anyone know a way to make the platforms take into account both the x and y position and rotate accordingly? I’ve attached the rotation code below.

Thanks in Advance. Kudos if you can solve this issue.

alt text

var lastMousePosition : Vector3;
var rotationWhenClicked : float;
private var shouldRotate:boolean;
private var rotateAmount:float;
function Start(){
	shouldRotate=false;
 }
 
function FixedUpdate(){
        
   if(shouldRotate){ //If shouldRotate = true...
     if(Input.GetMouseButton(0)){ //and if MouseButton is clicked
    	
			rotateAmount=(Input.mousePosition.y - lastMousePosition.y);
              transform.root.transform.rotation.eulerAngles.z=rotationWhenClicked-rotateAmount;

   	 }
    }
     
}

function OnMouseUp(){
 shouldRotate=false;
}

function OnMouseDown(){
		rotateAmount=0;
		lastMousePosition  = Input.mousePosition;	
		rotationWhenClicked=transform.root.transform.rotation.eulerAngles.z;
 shouldRotate=true;
}

Try this:

private var angleOffset = 0.0;
private var angleStart = 0.0;
private var camDist : float;

function Start() {
	//The distance from the camera to the player object
	camDist = transform.position.z - Camera.main.transform.position.z;
}

function OnMouseDown() {
	var mousePos = Vector3(Input.mousePosition.x, Input.mousePosition.y, camDist);
    var lookPos = Camera.main.ScreenToWorldPoint(mousePos)- transform.position;
    angleOffset = angleStart-Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
}

function OnMouseDrag() {
	var mousePos = Vector3(Input.mousePosition.x, Input.mousePosition.y, camDist);
    var lookPos = Camera.main.ScreenToWorldPoint(mousePos) - transform.position;
    var angleT : float = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
    angleStart = angleT + angleOffset;
    transform.rotation = Quaternion.AngleAxis(angleStart, Vector3.forward);
}