Advertisement
Guest User

Untitled

a guest
May 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Axe : MonoBehaviour
  6. {
  7.     Animator axeAnimator;
  8.     AnimatorClipInfo[] currentAnimator;
  9.     float currentAnimation;
  10.     [SerializeField] float axeDamage = 100f;
  11.     bool isAnimationPlaying = false;
  12.  
  13.     // Start is called before the first frame update
  14.     void Start()
  15.     {
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void Update()
  20.     {
  21.        
  22.     }
  23.  
  24.     public void AxeSwing()
  25.     {
  26.  
  27.         //Debug.Log("hello");
  28.         this.gameObject.SetActive(true);
  29.         isAnimationPlaying = true;
  30.         axeAnimator = GetComponent<Animator>();
  31.         axeAnimator.SetTrigger("AxeSwing");
  32.     }
  33.  
  34.     public void DeativateAxe()
  35.     {
  36.         this.gameObject.SetActive(false);
  37.         isAnimationPlaying = false;
  38.  
  39.     }
  40.  
  41.     void OnTriggerEnter2D(Collider2D other)
  42.     {
  43.         Debug.Log("I hit " + other.name);
  44.         if (other.gameObject.tag == "enemy")
  45.         {
  46.             var health = other.gameObject.GetComponent<Health>();
  47.             health.DealDamage(axeDamage);
  48.            
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement