Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Axe : MonoBehaviour
- {
- Animator axeAnimator;
- AnimatorClipInfo[] currentAnimator;
- float currentAnimation;
- [SerializeField] float axeDamage = 100f;
- bool isAnimationPlaying = false;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- public void AxeSwing()
- {
- //Debug.Log("hello");
- this.gameObject.SetActive(true);
- isAnimationPlaying = true;
- axeAnimator = GetComponent<Animator>();
- axeAnimator.SetTrigger("AxeSwing");
- }
- public void DeativateAxe()
- {
- this.gameObject.SetActive(false);
- isAnimationPlaying = false;
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- Debug.Log("I hit " + other.name);
- if (other.gameObject.tag == "enemy")
- {
- var health = other.gameObject.GetComponent<Health>();
- health.DealDamage(axeDamage);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement