Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

Rotations give predicted shape when applied separately but warped shape when combined (Pic)

Discussion in 'General Graphics' started by WilkinsMicawber, Feb 15, 2016.

  1. WilkinsMicawber

    WilkinsMicawber

    Joined:
    Jan 22, 2016
    Posts:
    27
    I create hundreds of primitive cubes positioned along the top of another cube so that they are side by side. I then apply outward rotations and upward rotations to each. The upward and outward rotations look exactly as expected applied separately but result in a warped shape when combined. The code is:

    //cube[] is an array of the primitive cubes

    vertical:
    for (int x = 0; x++; x < cube.count)
    {
    cube[x].transform.RotateAround(cube[x].transform.position - new Vector3(cube[x].transform.localScale.x / 2f, cube[x].transform.localScale.y / 2f, transform.localScale.z / 2f), new Vector3(0, 0, 1), 45f);
    }

    horizontal:
    for (int x = 0; x++; x < cube.count)
    {
    cube[x].transform.RotateAround(cube[x].transform.position - new Vector3(cube[x].transform.localScale.x / 2f, 0, 0), new Vector3(0, 1f, 0), drawAngle);
    drawAngle -= .10f;
    }
    grahics1.png

    Any idea what is happening?