- Home /
Question by
Crespo-Cabrera · Oct 04, 2016 at 05:11 AM ·
c#inputanimations
C# Script The same Input play two animations every time
For my new project I have two animations. One for Open and the secondone for close. I would like if I press Input 4 play open, but if I press the input 4 again and play open its true play close.
My script is this:
public class OpenandCloseCortinas : MonoBehaviour {
public Animation anim;
public bool animopen;
public bool animclose;
// Use this for initialization
void Start()
{
anim = GetComponent<Animation>();
anim["Open2"].wrapMode = WrapMode.Default;
anim["Close2"].wrapMode = WrapMode.Default;
}
// Update is called once per frame
void Update()
{
if (Input.GetKey("4") && anim["Open2"].enabled == false)
{
anim["Open2"].enabled = true;
anim.Play("Open2");
}
else if (Input.GetKey("4") && anim["Open2"].enabled == true)
{
{
anim["Close2"].enabled = true;
anim.Play("Close2");
}
}
}
}
I need help? what is wrong? I'm stating now with scriptting
Comment