I am about a week in to Unity but reading through all the tutorials, guides and documentation I can as quickly as I can.
I have what I'm sure is a simple scenario but I'm having trouble determing the method to tackle it in Unity.
What I want to do is have a row of cubes roll 90 degrees and one position downward followed by a delay of 2 seconds (an arbitrary number of seconds), and then repeat. Put another way, I want the cube to roll over on its side in the direction it is rolling.
From what I've gathered so far, I thought one way would be to transform the cube at set intervals:
That's rotating it, but that rotation doesn't match up with the movement in the x-axis properly, so it looks awful. How could I sync the roll to exactly match up with the x-asix movement?
Should I be doing this as a RigidBody and AddMotion instead? I tried that, but the roll didn't seem predictable depending on where the block was on the plane.
There are animation curves I know, but I wonder how I would sync the rotation and movement on the x-axis.
A simple solution is to do the rotation as an animation where at the end of the animation the cube has moved the +1 distance.
Alternatively use Transform.rotateArount to rotate around a point on the edge of the cube you're currently rolling over.
If not clear what I mean, let me know, can make an example or so.
EDIT2: now have rotation done from Coroutine so we can delay after rolling to a side.
answered Nov 28 '09 at 04:48 AM