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!

OnMouseDown() 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

1 Answer

1

Use the Rotation function in MoveObject.

Omg! @Eric5h5 thank you very much it works like a charm!