예제 #1
0
 // 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>();
 }
예제 #2
0
 // Start is called before the first frame update
 void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     myPlayerHealth = player.GetComponent <MyPlayerHealth>();
     anim           = GetComponent <Animator>();
     myEnemyHealth  = GetComponent <MyEnemyHealth>();
 }
예제 #3
0
    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);
        }
    }
예제 #4
0
    void Awake()
    {
        floorMask = LayerMask.GetMask("Floor");

        anim            = GetComponent <Animator>();
        playerRigidbody = GetComponent <Rigidbody>();
        MyPlayerHealth  = GetComponent <MyPlayerHealth>();
        speed           = Speed;
        slowspeed       = Speed / 2;
    }