Randomly play multiple attack animation
Hello,
How to randomly play multiple animation attack with this script Thanks
 #pragma strict
 
 var Distance : float;
 var Target : Transform;
 var lookAtDistance : float = 20;
 var chaseRange : float = 10;
 var attackRange : float = 2.2;
 var moveSpeed : float = 3;
 var Damping : float = 6;
 var attackRepeatTime : float = 1;
 
 var damage : float = 10;
 
 private var attackTime : float;
 
 var controller : CharacterController;
 var gravity : float = 20;
 
 private var moveDirection : Vector3 = Vector3.zero;
 
 
 
 function Start () {
 attackTime = Time.time;
 FindHealth();
 }
 
 
 
 function Update () {
 Distance = Vector3.Distance(Target.position, transform.position);
 if (Distance < lookAtDistance){
 lookAt();
 }
 
 if (Distance < attackRange){
 attack();
 }
 
 else if (Distance < chaseRange){
 chase();
 }
 }
 
 
 
 function lookAt (){
 var rotation = Quaternion.LookRotation(Target.position - transform.position);
 transform.rotation = Quaternion.Slerp(transform.rotation, rotation,Time.deltaTime * Damping);
 }
 
 
 
 function chase() {
 GetComponent.<Animator>().Play("creature1run");
 moveDirection = transform.forward;
 moveDirection *= moveSpeed;
 moveDirection.y -= gravity * Time.deltaTime;
 controller.Move(moveDirection * Time.deltaTime);
 }
 
 
 
 function attack() {
 if (Time.time > attackTime){
 GetComponent.<Animator>().Play("creature1Attack2");
 Target.SendMessage("PlayerDamage", damage);
 Debug.Log ("The enemy has attacked");
 attackTime = Time.time + attackRepeatTime;
 }
 }
 
 
 
 function ApplyDamage(){
 chaseRange += 30;
 moveSpeed += 2;
 lookAtDistance += 40;
 }
 
 
 
 function FindHealth(){
 Target = GameObject.Find("Player").GetComponent(HealthScript).transform;
 }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Animations not playing correctly for FPS enemy AI 0 Answers
Animations not playing correctly for FPS enemy AI 0 Answers
How To Stop Enemy Movement During Its Attack Animation 1 Answer
AI Problem. 0 Answers