Greetings,
Here is my code -
- usingUnityEngine;
- usingSystem.Collections;
- publicclass enemyai :MonoBehaviour{
- publicTransform target;
- NavMeshAgent agent;
- // Use this for initialization
- voidStart(){
- agent =GetComponent();
- }
- // Update is called once per frame
- voidUpdate(){
- agent.SetDestination(target.position);
- GetComponent().Play(“Run”);
- if(Input.GetKeyDown(KeyCode.LeftAlt))
- {
- GetComponent().Play(“Attack_01”);
- }
- }
- voidOnTriggerEnter(Collider hel)
- {
- if(hel.gameObject.tag ==“enemy”)
- {
- GetComponent().Stop(“Run”);
- }
- }
- }
It’s not playing 2nd animation cause it’s not stopping 1st , if i press left alt then it just play it for i millisecond , just a little bit and then again play run animation as loop .
can you please tell me how can i correct this in unity 5.1 , it have GetComponent so a bit confusing for me , can you write that code line to fix this , thanks .