cude issue

Hello i’m trying to create a cube that rotates to move as seen in this video

I thought this would be a simple matter of rotating the cube. however I’ve had some weird issues. This is the script i used

function Update ()
{
if( Input.GetKey ("w") )
   {
      transform.Rotate(-5,0,0);
	
   }
   if( Input.GetKey ("s") )
   {
      transform.Rotate(5,0,0);
   }

}

first thing i noticed is that the rotation doesn’t seem to be in degrees, is it calculated in radians?

Another problem is the reversal of rotation, it seems to propel forwards i must rotate in the opposite direction, this doesnt seem right at all maybe i’m missing somthing. The last issue i’m facing is snapping to grid, is this even possible as I’m not sure there is a playable grid in the engine?

Thoughts, suggestions?
Regards
Ant

i think if P is 3.14, it’s just good if you divide it into 360 part…
and NOW IT’S DEGREE xD … for 3.14 … i mean in SIN and COS

No, it’s degrees. Your code is framerate-dependent though; you’re rotating 5 degrees every frame.

Not really sure what you mean.

Anything is possible as long as you program it to do what you want.

–Eric

Someone on unity answers had the same problem…

The solution at the bottom appears to work.

http://answers.unity3d.com/questions/742/rolling-cubes-one-space-and-one-rotation-at-a-time-with-a-delay

just noticed i’ve made a ton of grammer and spelling errors sorry, had the flu recently so i’m all over the shop lol, will get back to you soon after i’ve read the responses

just read over this and implimented and it works with key imputs, however it seems to be run constantly once started and i’m having trouble fidning how to which axis the edge it’s moving to is on. would it not be simpler to move it as like the fps walker and just rotate as an animation. seems very over kill to rotate a cube plus theres the fact adding physics to the cube seems to mess up the rotation

Well you could check for keypress in Update () then invoke DoRoll() which would probably stop the perpetual rolling.

I haven’t really looked at the code though - but its probably a good starting place.

ah yes thats what I was doing I forgot to add

seem to have done the animation way and it works, however i’m having move issues is moveDirection(x,y,z) the right syntax to move a object with no rigid body