コード例 #1
0
    protected void onHit(Collider other)
    {
        healthBehaviour = other.GetComponent <HealthBehaviour>();

        if (healthBehaviour != null && this.tag == healthBehaviour.damageDealerType)
        {
            Vector3 knockbackDirection = new Vector3(other.transform.position.x - this.transform.position.x, 0, other.transform.position.z - this.transform.position.z).normalized;
            knockbackDirection.y = 4;

            knockbackDirection *= knockback;

            healthBehaviour.hit(damage, knockbackDirection);

            Debug.Log("hit " + other + "with" + this.gameObject);
        }
    }