- Home /
Question by
Roby-Gunqwn · Jun 13, 2013 at 05:10 AM ·
movementgameobject
How to make object move and rotate
I'm New in unity3d and game development also. i just start to make game runnig style like temmple run. i add a cube in scene and assign this script for movement
function Update () {
transform.Translate (transform.forward * 2.0f * Time.deltaTime);
if (Input.GetKey ("up")) {
transform.Rotate (Vector3.up * 90.0f ); ;
}
}
when i play cube moving correctly. but when press up button the cube not rotate 90 degree but just move forward and backward.
Comment
Answer by Theinsanekiller · Jun 13, 2013 at 08:41 AM
Instead of Just
tranform.Rotate();
use transform.RotateAround( axis, angle ); it will work