// Start is called before the first frame update void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); myPlayerHealth = player.GetComponent <MyPlayerHealth>(); myEnemyHealth = GetComponent <MyEnemyHealth>(); }
// Start is called before the first frame update void Awake() { player = GameObject.FindGameObjectWithTag("Player"); myPlayerHealth = player.GetComponent <MyPlayerHealth>(); anim = GetComponent <Animator>(); myEnemyHealth = GetComponent <MyEnemyHealth>(); }
void OnTriggerEnter2D(Collider2D hitInfo) { // Debug.Log(hitInfo.name); if (hitInfo.tag == "Player") { MyPlayerHealth playerHealth = hitInfo.GetComponent <MyPlayerHealth>(); Transform playerTransform = hitInfo.GetComponent <Transform>(); if (playerHealth != null) { if (transform.position.x > playerTransform.position.x) { playerHealth.TakeDamage(damage, true); //Debug.Log("go left"); } else { playerHealth.TakeDamage(damage, false); //Debug.Log("go right"); } } GameObject boom = Instantiate(impactEffect, transform.position, transform.rotation); Destroy(gameObject); Destroy(boom, time); } }
void Awake() { floorMask = LayerMask.GetMask("Floor"); anim = GetComponent <Animator>(); playerRigidbody = GetComponent <Rigidbody>(); MyPlayerHealth = GetComponent <MyPlayerHealth>(); speed = Speed; slowspeed = Speed / 2; }