Here is the webplayer preview. Right-Click drag moves the camera, left click drag on a cube rotates the cube. http://www.sfbaystudios.com/cubetest.html
The problem is that once the camera is facing a different direction from the start, the cubes do not rotate properly – they rotate backwards or sometimes on a completely different axis than I expect. I pass the following info to the cube script:
selectedCube.GetComponent(cubeScript).WasMoved(90 * (rawXDelta / 100), 90 * (rawYDelta / 100));
(rawXDelta / rawYDelta is the change in position of the mouse between frames).
function WasMoved (xMove : float, yMove : float){
var i = 0;
for (var cube : Collider in neighborCubes)
{
if (yMove * yMove > xMove * xMove)
{
cube.gameObject.transform.Rotate(yMove, 0, 0, Space.World);
}
else
{
cube.gameObject.transform.Rotate(0, -xMove, 0, Space.World);
}
}
}
I’m guessing that I need a way to change the axis used here: cube.gameObject.transform.Rotate(yMove, 0, 0, Space.World);
– so that it’s either a negative or a different axis based on where the camera is facing. However, I’m having a headache of a time trying to figure out how to do that. Any suggestions?