Esempio n. 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject target = collision.gameObject;

        Debug.Log(target.transform.name);
        Health hit = target.GetComponent <Health>();
        Shh    shh = target.GetComponentInChildren <Shh>();

        if (shh != null)
        {
            _speed          *= -2;
            _damage         *= 3;
            _damage         /= 2;
            gameObject.layer = LayerMask.NameToLayer("PlayerProjectiles");
            return;
        }

        if (hit != null)
        {
            hit.Value -= _damage;
            var pm = target.GetComponent <Playermovement>();
            if (pm == null)
            {
                target.transform.position += transform.right * Time.deltaTime * _speed * 2; //knockback, can delete
            }
            else
            {
                pm.KnockBack(transform.right, _speed * 2);
            }
        }

        Destroy(gameObject);
    }
Esempio n. 2
0
 private void Awake()
 {
     _myAnimator = GetComponent <Animator>();
     _shh        = GetComponentInChildren <Shh>();
     _shh.gameObject.SetActive(false);
 }