virtual public void RaycastHit()
    {
        RaycastHit hit;

        if (Physics.Raycast(camtrans.position, camtrans.TransformDirection(Vector3.forward), out hit, range, ignore))
        {
            if (hit.collider.tag == "Enemy")
            {
                AIHitbox hitbox = hit.collider.GetComponent <AIHitbox>();

                if (hitbox != null)
                {
                    hitbox.Hit(damage * Stats.instance.playerDamage);
                    Debug.Log("Enemy Hit");
                }
                else
                {
                    Debug.LogWarning("Enemy AIHitBox not found.");
                }
            }
#if UNITY_EDITOR
            else
            {
                Debug.Log("Hit tag: " + hit.collider.tag);
            }
            Debug.DrawRay(camtrans.position, camtrans.TransformDirection(Vector3.forward) * hit.distance, Color.yellow, 0.2f);
        }
        else
        {
            Debug.DrawRay(camtrans.position, camtrans.TransformDirection(Vector3.forward) * range, Color.red);
            Debug.Log("Miss");
#endif
        }
    }
Пример #2
0
    void Start()
    {
        gm       = GameObject.Find("GameManager").GetComponent <GameManager>();
        hitbox   = GetComponent <AIHitbox>();
        playerTR = GameObject.Find("Player").GetComponent <Transform>();

        enemyUI   = GetComponentInChildren <Canvas>();
        feed      = GetComponentInChildren <TextMeshProUGUI>();
        feed.text = "";

        if (randomize)
        {
            movementType = Random.Range(1, Mathf.RoundToInt(3));
        }
    }