protected void SetUpComponent() { rb = GetComponent <Rigidbody2D>(); animator = GetComponentInChildren <Animator>(); spriteRenderer = GetComponentInChildren <SpriteRenderer>(); capsuleCollider = GetComponent <CapsuleCollider2D>(); enemyHpBar = GetComponentInChildren <EnemyHpBar>(); }
private void Awake() { op = ObjectPooling.GetInstance(); rigid = transform.GetComponent <Rigidbody2D>(); weapon = transform.Find("Weapon").GetComponent <Weapon>(); sprite = transform.GetComponent <SpriteRenderer>(); ani = transform.GetComponent <Animator>(); enemyManager = GameObject.Find("EnemyManager").GetComponent <EnemyManager>(); enemyHpBar = hpBar.GetComponent <EnemyHpBar>(); }
protected void Start() { Player = GameObject.FindGameObjectWithTag("Player"); navAgent = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); enemyHpBar = gameObject.transform.parent.Find("Canvas").GetComponent <EnemyHpBar>(); StartCoroutine(CoCoolTime()); }
private void Start() { //uiCanvas = GameObject.Find("UICanvas").GetComponent<Canvas>(); GameObject hpPanel = GameObject.Find("EnemyHpPanel"); hpBarPrefab = Resources.Load <GameObject>("Prefabs/EnemyHpBar"); GameObject hpBar = Instantiate <GameObject>(hpBarPrefab, hpPanel.transform); //GameObject hpBar = Instantiate<GameObject>(hpBarPrefab, uiCanvas.transform); hpBarImage = hpBar.GetComponentInChildren <Image>(); hpBarImage.fillAmount = 1.0f; EnemyHpBar enemyHpBar = hpBar.GetComponent <EnemyHpBar>(); enemyHpBar.target = transform; enemyHpBar.offset = hpBarOffset; }