- Home /
Rotate cube in two direction not working
First thing, i want to rotate block left-right , right-left, top-bottom and bottom-top.
See figure-1 one cube is their and all axis. when i rotate top to bottom (black arrow) cube z angle changed (red arrow) and get figure-2 this all work fine.
see figure-2 after that i move left to right rotate (black arrow) cube x angle change but at this time rotation is wrong beacuse of after first rotation all axis changed. and result is figure-3.
see figure 3 i am getting this position and movement (see red arrow), but i want exact figure-4 that not getting me.
check code file and video file is link text ( in this video cube movement show and also show you true rotation and wrong rotation)
please help me solve this.
Thnx
rotating through script works in local or global axis (im not sure which 1) so try both.
Answer by supernat · Jan 30, 2014 at 06:08 AM
It sounds like you want to use the Forward/Right/Down (FRD) coordinate system instead of the World coordinate system. Try using gameObject.transform.Rotate(someAmount, Space.Self). Because it rotates based on your model's coordinates (or FRD), rotating around the down axis (Z) will always move the cube left/right, rotating around the Right axis (Y) will always rotate up/down.
EDIT: Fixed my answer. Sorry about that, was thinking of parented rotations.
@supernat done changes in code but not working properly.