Question by 
               Razor1589 · Dec 22, 2017 at 11:16 AM · 
                animations3d modelscomboattacking  
              
 
              How to make so when i press the left mouse button the 3D model attacks, and when i press it again it makes the next attack animation and the next total of 3 animations in a row like a combo click animations?
using UnityEngine; using System.Collections;
public class pplayer : MonoBehaviour {
 private Animator anim;
 private CharacterController PlayerController;
 public Vector3 jump;
 public float speed = 6.0f;
 public float turnSpeed = 100.0f;
 private Vector3 moveDirection = Vector3.zero;
 public float gravity = 14.0f;
 private float verticalVelocity;
 private float jumpForce = 80.0f;
 public bool isGrounded;
 Rigidbody rb;
 int noOfClicks = 0;
 float lastClickedTime = 0;
 float maxComboDelay = 1;
 void Start () 
 {
     PlayerController = GetComponent <CharacterController>();
     anim = gameObject.GetComponentInChildren<Animator>();
     jump = new Vector3 (0.0f, 2.0f, 0.0f);
 }
 void OnCollisionStay()
 {
     isGrounded = true;
 }
 void Update ()
 {
     if (Input.GetKeyDown (KeyCode.Space) && isGrounded) {
         rb.AddForce (jump * jumpForce, ForceMode.Impulse);
         isGrounded = false;
     } 
     //if (PlayerController.isGrounded) 
     //{
     //    verticalVelocity = -gravity * Time.deltaTime;
     //    if (Input.GetKeyDown (KeyCode.Space)) 
     //    {
     //        verticalVelocity = jumpForce;
     //        anim.SetBool ("Jump", true);
     //    }
     //    else 
     //    {
     //        verticalVelocity -= gravity * Time.deltaTime;
     //        anim.SetBool ("Jump", false);
         //}
     //    Vector3 moveVector = new Vector3 (0, verticalVelocity, 0);
     //    PlayerController.Move (moveVector * Time.deltaTime);
     //}
     //if (Input.GetKey (KeyCode.Space)) 
     //{
     //    anim.Play ("JUMP", -1,0f);
     //}  
     if (Input.GetMouseButtonDown (1)) 
     {
         anim.SetBool ("Skill",true);
     } else {
         anim.SetBool ("Skill", false);
     }
     if (Input.GetMouseButtonDown (0)) 
     {
         anim.SetBool ("Attack", true);
     } else {
         anim.SetBool ("Attack", false);
     }
     if (Input.GetKey ("w")) 
     {
         anim.SetInteger ("AnimPar", 1);
     }  
     else 
     {
         anim.SetInteger ("AnimPar", 0);
     }
     if (Input.GetKey ("s")) {
         anim.SetInteger ("AnimPar1", 1);
     }  
     else 
     {
         anim.SetInteger ("AnimPar1", 0);
     }
     if(PlayerController.isGrounded){
         moveDirection = transform.forward * Input.GetAxis("Vertical") * speed;
     }
     float turn = Input.GetAxis("Horizontal");
     transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);
     PlayerController.Move(moveDirection * Time.deltaTime);
     moveDirection.y -= gravity * Time.deltaTime;
     if (Time.time - lastClickedTime > maxComboDelay) {
         noOfClicks = 0;
     }
 }
     
 void OnClick()
 {
     lastClickedTime = Time.time;
     noOfClicks++;
     if (noOfClicks == 1)
     {
         anim.SetBool ("Attack1", true);
     }
         noOfClicks = Mathf.Clamp (noOfClicks, 0, 3);
} }
 
                 
                the-game-screen.png 
                (194.1 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                