Exemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        rb.constraints = RigidbodyConstraints.FreezeAll;
        currentSpeed   = 0;
        Attack attackStruct;

        // Damage section.
        Rigidbody targetRigidbody = other.GetComponent <Rigidbody>();

        if (targetRigidbody != null)
        {
            HealthClass targetHealth = other.GetComponent <HealthClass>();
            if (targetHealth != null)
            {
                attackStruct = ValkyDetection.GetAttackStruct(owner, projectileDirection, damage, yKnockbackOffset, knockbackForce, uniformKnockback);

                targetHealth.TakeDamage(attackStruct);
            }
        }
        Release();


        #region old code

        /* Damage section.
         *
         * RaycastHit groundHit;
         * Physics.Raycast(transform.position, Vector3.down, out groundHit, 20, groundLayer);
         * Vector3 impostorPos = groundHit.point;
         *
         * Rigidbody targetRigidbody = other.GetComponent<Rigidbody>();
         * if (targetRigidbody != null)
         * {
         *  RaycastHit gHit;
         *  Physics.Raycast(other.transform.position, Vector3.down, out gHit, 20, groundLayer);
         *  Vector3 hitImpostorPos = gHit.point;
         *
         *  Vector3 knockDirection = Vector3.Normalize(impostorPos - hitImpostorPos);
         *  if(knockDirection.Equals(Vector3.zero)) Debug.Log("distance between objects is zero");
         *  knockback = knockDirection * knockbackForce;
         *  knockback.y = yKnockbackOffset;
         *  Attack attackStruct = new Attack(damage, knockback, uniformKnockback);
         *
         *  HealthClass targetHealth = other.GetComponent<HealthClass>();
         *  if (targetHealth == null)
         *  {
         *      return;
         *  }
         *  else
         *  {
         *      targetHealth.TakeDamage(attackStruct);
         *  }
         * }
         * Release();
         */
        #endregion
    }
Exemplo n.º 2
0
    private void OnCollisionEnter(Collision other)
    {
        if (hitboxActive)
        {
            projectileDirection = Vector3.Normalize(awakePosition - asleepPosition);

            HealthClass targetHealth = other.gameObject.GetComponent <HealthClass>();
            if (targetHealth != null)
            {
                rb.Sleep();

                Attack attackStruct = ValkyDetection.GetAttackStruct(transform, projectileDirection, GetDamage(), 0, knockbackForce, false);
                targetHealth.TakeDamage(attackStruct);
            }
        }
    }
Exemplo n.º 3
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == groundLayer)
        {
            Explosion(false);
            Release();
        }
        else
        {
            rb.Sleep();
            currentSpeed = 0;
            Attack attackStruct;

            HealthClass healthClass = other.gameObject.GetComponent <HealthClass>();
            if (healthClass != null)
            {
                attackStruct = ValkyDetection.GetAttackStruct(owner, projectileDirection, damage, yKnockbackOffset, knockbackForce, uniformKnockback);
                healthClass.TakeDamage(attackStruct);
            }
            Release();
        }
    }