Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020.2 has been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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?
     
unityunity