- Home /
How do you flip a card with smooth rotation?
Hello everyone!
I'm making a game which you flip cards. My camera points at the top showing the cards. When i click on a card that one flips but i want to add a realistic flip effect (smooth rotation of the card object) when the flip happens. Here is what i tried but it doesn't work:
public var card_1: GameObject;
card_1 = GameObject.Find("card_1");
function OnMouseDown () {
card_1.transform.Rotate(Vector3(0,0,180) * Time.deltaTime);
}
The js code is attached to the card object.
Any suggestions? Thanx in advance!
On$$anonymous$$ouseDown() needs to be on the object clicked. But your code flips another object ('card_1'). How do you have things structured.
I suggest make an animation, it let card flipping be more realistic, very smooth, not to mention it will only take a few Words of code to start the animation!
EDIT: Changed line to words.
Check this answer
http://answers.unity3d.com/questions/351899/rotation-lerp.html
Answer by Eric5h5 · Dec 03, 2013 at 08:36 PM
Use the Rotation function in MoveObject.
Omg! @Eric5h5 thank you very much it works like a charm!
Your answer
Follow this Question
Related Questions
Rotate an Object 1 Answer
How get the rotation of an GameObject? 3 Answers
Rotate around a locally tilted axis?, 1 Answer
Rotation is jumpy 2 Answers