Guest User

Untitled

a guest
Jun 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var enemyTarget : GameObject;
  2. var countDown : int = 0;
  3. var coolDown : int = 2;
  4. var playerAttackRange : int = 2;
  5. var player : GameObject;
  6. var timeSpeed : int = 1;
  7. var particle : GameObject;
  8.  
  9.  
  10. function Update() {
  11.     if(countDown > 0) {
  12.         countDown -= 1 * Time.deltaTime;
  13.     }
  14.    
  15.     if(countDown < 0) {
  16.         countDown = 0;
  17.     }
  18.    
  19.     if(Input.GetKeyUp(KeyCode.F)) {
  20.         Debug.Log("Attacked");
  21.         Slash();
  22.         //Debug.Log(enemyTarget.GetComponent(BadGuyHealth).currentEnemyHealth);
  23.     }
  24. }
  25.  
  26. function Slash() {
  27.     var hit : RaycastHit;
  28.     var fwd = transform.TransformDirection (Vector3.forward);
  29.                
  30.     if (Physics.Raycast (transform.position, fwd, hit, playerAttackRange)) {
  31.         if(hit.collider.gameObject.tag == "Enemy") {
  32.             Debug.Log(hit.collider.gameObject.GetComponent(BadGuyHealth).currentEnemyHealth);
  33.             hit.collider.gameObject.GetComponent(BadGuyHealth).currentEnemyHealth -= player.GetComponent(Statistics).Strength;
  34.             Instantiate (particle, transform.position, transform.rotation);
  35.  
  36.             //Play attack animation.   
  37.                 //if (hit.collider.gameObject.GetComponent(EnemyHealth).enemyHealth <= 10) {
  38.                     // Time.timeScale = timeSpeed;     
  39.                 //}
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment