Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Spine.Unity;
- using Spine;
- using UnityEngine.UI;
- public class Police : MonoBehaviour
- {
- public float startHealth =100;
- private float health;
- [SpineAnimation]
- public string stand;
- [SpineAnimation]
- public string attack;
- [SpineAnimation]
- public string die;
- public SkeletonAnimation SkelAnim;
- public Image HealthBar;
- void Start()
- {
- health = startHealth;
- SkelAnim = GetComponent<SkeletonAnimation>();
- SkelAnim.state.SetAnimation(0,stand,true);
- }
- public void TakeDamge (float amount)
- {
- health -= amount;
- HealthBar.fillAmount = health/startHealth;
- if (health <=0)
- {
- Destroy(gameObject);
- }
- }
- void update(){}
- void OnTriggerEnter2D (Collider2D collider)
- {
- Debug.Log("im hit");
- health -=1f;
- SkelAnim.state.SetAnimation(0,attack,true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement