Hello
I want a help in animation . i’m rotating cube with help of animation . But what issue is when i play animation it always start form same position . i want to rotated cube the basics of swipe in which direction i;m doing swipe . here is link what i smiler want to Do
thanx in advance
This is probably easier to do if you handle the animation from a script rather than define the animations with the editor. You would need to define a lot of separate animations for all the different types of rotation and then choosing the right one for each movement would be very complicated.
Hey andee ,
Thanx so suggestion, well How can i make smooth motion like in animation editor Done. I mean the with time of 1 sec and Smooth motion with help of script . it rotated to quick , can’t seen tht motion smooth can u written a simple example of smooth Rotation of Cube with 90 degree .
The problem is that you are rotating by a 90º angle with transform.RotateAround. This will immediately rotate the object by that amount. You need to rotate by a small amount each frame. Your code might look something like this:-
var rotateSpeed: float; // Set to 1 to rotate over 1 second.
function Update () {
...
var angleRotated = 90.0;
if (Input.GetMouseButton(0)) {
angleRotated = 0;
}
if (angleRotated < 90.0) {
var rotateStep = 90.0 * Time.deltaTime * rotateSpeed;
transform.RotateAround(Vector2(xpos,ypos), Vector3.forward, rotateStep);
angleRotated += rotateStep;
}
...
}
Hey andee Thnz , well Now the next issue what coming On which i can;t come Over that is as i hv 1x1x1 and 2x1x1 and 3x1x1 cube … what i;m Doing this cube are have rotated around point on each swipe . the Swipe can be right to left , top to bottom and vice - verse . and what i looking for the mid point of lower edge of cube The Cube. i had got mid point of 1x1x1 cube and it;s working i;m calculation that mid point on the basic of position of cube , But in 2x1x1 and 3x1x1 i can;t get generalize that mid point b’coz when cube is placed on plan with 2x1 or 3x1 surface that time the mid point of lower is different as cube placed on plan with 1x1 surface of cube of type 3x1x1 or 2x1x1 . what u suggest to get mid point of lower edge of cube surface which placed on plan.
Thanks In Advance .
– Kapil