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.
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;
}