I have this code
using UnityEngine;
using System.Collections;
public class InvestigateObjectScript : MonoBehaviour
{
public float time;
private Animation anim;
void Awake()
{
anim = GetComponent<Animation>();
}
void Update()
{
if (Input.GetKey(KeyCode.S) && time <= 1.048052f)
{
anim.enabled = true;
anim["basicRigAction_002"].speed = 0.1f;
anim["basicRigAction_002"].time = time;
anim.Play("basicRigAction_002");
}
if (Input.GetKey(KeyCode.H))
{
anim.enabled = true;
anim["basicRigAction_002"].speed = -0.1f;
anim["basicRigAction_002"].time = time;
anim.Play("basicRigAction_002");
}
if (time <= 1.048052f && anim.enabled)
{
time = anim["basicRigAction_002"].time;
}
/* if (!(Input.GetKey(KeyCode.H) || Input.GetKey(KeyCode.S)))
{
anim.enabled = false;
// time = anim["basicRigAction_002"].time;
}*/
if (Input.GetKey(KeyCode.H) && time >= 1.04053f)
{
time = 1.048052f;
}
Debug.Log("" + time.ToString());
Debug.Log("dsd" + anim["basicRigAction_002"].time.ToString());
}
}
And what i want is that when I push those buttons animatiions play, but i have the opposite when I push those buttons the animations dont play and when I let them go animations starts. Why is happening this?