Hi All!
I have a code to control animation like that:
public class EM : MonoBehaviour {
public enum Type
{
Solo_Left, Solo_Right, Multiple
}
public Type type;
public GameObject curveL, curveR;
public int reps;
public float speed;
private Animator aniL, aniR;
void Start () {
aniL = curveL.GetComponent<Animator>();
aniR = curveR.GetComponent<Animator>();
}
void Update () {
if (type == Type.Solo_Left)
{
if (aniL.GetCurrentAnimatorStateInfo(0).IsName("Idle") && reps != 0)
{
aniL.speed = speed;
aniL.Play("Take 001");
reps--;
}
}
if (type == Type.Solo_Right)
{
if (aniR.GetCurrentAnimatorStateInfo(0).IsName("Idle") && reps != 0)
{
aniR.speed = speed;
aniR.Play("Take 001");
reps--;
}
}
if (type == Type.Multiple)
{
if (aniR.GetCurrentAnimatorStateInfo(0).IsName("Idle") && reps != 0)
{
aniL.speed = speed;
aniR.speed = speed;
aniL.Play("Take 001");
aniR.Play("Take 001");
reps--;
}
}
}
}
Which looks like that in inspector.
By using this code I can set up reps, speed , and choose the type of curveL and R in the inspector.
However currently it is a set of opinion. I want to make another public integer input so I can control the requiring sets of reps, speed, Type etc. For example, if the input integer is 2, it will have 2 sets of reps, speed, Type in inspector. if it is 5, it will allow me to have 5 sets. What should I do in order to reach that? Thanks for helping!