Making a coin flipping effect

Hi,
I’m new to Unity and I’m trying to create a 2D coin flipped like effect for a game object. I want it to continuously flip and change the ‘head’ image with a ‘tail’ image background and vice versa when is doing it. Something similar to this page: http://justflipacoin.com

Here’s what I have so far:

public class FlipEffect : MonoBehaviour
{
public GameObject coin;
	public Sprite headSprite;
public Sprite tailSprite;

void Update()
{
   FlipCoin();
}
public void FlipCoin()
{
    Vector3 vector3 = transform.localEulerAngles;
    float fT = vector3.z;
    vector3.z = vector3.y;
    vector3.y = fT;
    headObject.transform.localEulerAngles = vector3;

if(sourceObject.GetComponent<SpriteRenderer>().sprite.Equals(headSprite))
            {
               coin.GetComponent<SpriteRenderer>().sprite =tailSprite;
            }
            else
            {
                coin.GetComponent<SpriteRenderer>().sprite =headSprite;
            }
    }
}

Any help or suggestions would be appreciate.

Thank you,

…I’m not good with sprites, so why don’t you just use a 3D object for your coin? :stuck_out_tongue:

If you don’t want to, what you should probably do is determine how long 1 rotation takes,
then display the headSprite for half that time, then the tail sprite for half that time.

That doesn’t look very good, so should probably also make sprites for tail-at-half-rotation, head-at-half-rotation, and determine when to display them, etc.

I suppose you could also deform your head/tail sprites instead but I doubt that would be any easier.