try adding a line
img.transform.Rotate( 0f, 0f, -6f );
to all the cards.
After you experiment with that, try some code like this …
float totalTwist = 20f;
// 20f for example, try various values
int numberOfCards = ... get this from your List or array
float twistPerCard = totalTwist / numberOfCards;
float startTwist = -1f * (totalTwist / 2f);
where you use howManyAdded , basically do this…
float twistForThisCard = startTwist +
(howManyAdded * twistPerCard);
img.transform.Rotate( 0f, 0f, twistForThisCard);
That should get you going.
Further, note that the cards on each end should sit “down” a bit.
Try adding code like this…
float scalingFactor = 0.01f;
// that should be roughly one-tenth the height of one
// of your cards, just experiment until it works well
float nudgeThisCard = Mathf.Abs( twistForThisCard);
nudgeThisCard *= scalingFactor;
img.transform.Translate( 0f, -nudgeThisCard, 0f );
Have fun!
Now, you can improve you look by slightly randomizing each value, for the twist and the nudge.
This is a good chance for you to…
#…learn how to make an extension in c#.
Make a new text file HandyExtensions.cs like this …
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class HandyExtensions
{
public static float Jiggled(this float ff)
{
return ff * Random.Range(0.9f,1.1f);
}
}
As you can see, the Jiggled() extension will take a float and change it slightly. Try it like this
float x = 3.5f;
Debug.Log("x is " + x);
Debug.Log("x is " + x.Jiggled() );
Debug.Log("x is " + x.Jiggled() );
Debug.Log("x is " + x.Jiggled() );
Debug.Log("x is " + x.Jiggled() );
Debug.Log("x is " + x.Jiggled() );
Do some tests like that until you have a good understanding of extensions.
As you can see it’s one of the most powerful language features.
So, where you have these two lines of code
img.transform.Rotate( 0f, 0f, twistForThisCard);
img.transform.Translate( 0f, -nudgeThisCard, 0f );
simply change to
img.transform.Rotate( 0f, 0f, twistForThisCard.Jiggled() );
img.transform.Translate( 0f, -nudgeThisCard.Jiggled(), 0f );
Hope it gets you started.