- Home /
Move and turn a cube to a certain angle
Hi, I am struggling to get this done, what i want to do is when a certain condition is met, I want to move the cube by a certain distance to the right and at the same the cube should align to the right. How can this be done?
This is what i've got to so far. The cube is moving but it is turning the other side
void Update () {
GameObject cube = GameObject.Find("Cube");
cube.transform.Translate(Vector3.right *2* Time.deltaTime,cube.transform);
cube.transform.Rotate(2*Time.deltaTime, 0, 0);}
EDIT The rotation script is attached to child of cube..
Answer by bubzy · Jun 08, 2013 at 01:57 PM
if you are rotating and multiplying it by Time.deltaTime it is going to continue to rotate.
find the actual value you want it to turn to and use that e.g transform.Rotate(rotVal,0,0);
if I understand you correctly.
if i use transform.Rotate(45,0,0) it should rotate around x axis at an angle of 45 deg right? If yes i donno why it is not rotating?