//Both objects need rigidbodies and colliders
    private void OnTriggerEnter(Collider other)
    {
        if (alreadyTriggeredSomething == false)
        {
            string collisionName = other.name;

            if (collisionName == "Player-1" || collisionName == "Player-2")
            {
                alreadyTriggeredSomething = true;
                Debug.Log("[ " + this.name + " ] - OBJECT entered TriggerZone: " + collisionName);



                //Check to see who to deal damage to
                string playerCheck = collisionName.Substring(collisionName.Length - 1);
                Debug.Log("Player # Check: [ " + playerCheck + " ]");

                int whoToDamage = 0;

                if (playerCheck == "1")
                {
                    //Debug.Log("whoToDamage set to [1]");
                    whoToDamage = 1;

                    //Logic behind damage
                    //Debug.Log("Attempting to deal damage to: " + other.name);
                    percentGauge.DealDamage(damage, whoToDamage);
                }
                else if (playerCheck == "2")
                {
                    //Debug.Log("whoToDamage set to [2]");
                    whoToDamage = 2;

                    //Logic behind damage
                    //Debug.Log("Attempting to deal damage to: " + other.name);
                    percentGauge.DealDamage(damage, whoToDamage);
                }

                //Logic behind knockback
                //Debug.Log("Attempting to addForce to: " + collision.gameObject.name);
                Vector3 passedKnockback = gameObject.transform.TransformDirection(knockback_Angle);

                /*Debug.Log("Knockback Method Call Parameters, knockback: [" + knockback_Strength + "], " +
                 *  "attackDirection: [" + tempVector2 + "], attackOrigin: [" + gameObject.transform
                 + "], toWhichPlayer: [" + whoToDamage + "]");
                 */

                percentGauge.DealKnockback(knockback_Strength, passedKnockback, gameObject.transform, whoToDamage);

                //destroy projectile
                Destroy(gameObject);
            }
        }
    }
Beispiel #2
0
    //Both objects need rigidbodies and colliders
    private void OnTriggerEnter(Collider other)
    {
        if (alreadyTriggeredSomething == false)
        {
            alreadyTriggeredSomething = true; //-Might be able to hit mutliple things in the future before being turned off
            Debug.Log("[ " + this.name + " ] - OBJECT entered TriggerZone: " + other.name);

            //Do check that trigger is not from the player who cast it
            //--DO THIS AFTER GET THE REST OF MECHANIC WORKING

            string collisionName = other.name;

            //Check to see who to deal damage to
            string playerCheck = collisionName.Substring(collisionName.Length - 1);
            Debug.Log("Player # Check: [ " + playerCheck + " ]");

            //Check what kind of hitbox was triggered
            string hitboxCheck = collisionName.Substring(0, 5);
            Debug.Log("Hitbox type Check: [ " + hitboxCheck + " ]");

            int whoToDamage = 0;

            if (playerCheck == "1")
            {
                //Debug.Log("whoToDamage set to [1]");

                whoToDamage = 1;

                //Logic behind damage
                if (hitboxCheck == "Basic")
                {
                    //Debug.Log("Attempting to deal damage to: " + other.name);
                    percentGauge.DealDamage(damage, whoToDamage); //--Fix Indicator in method for who to damage
                }
                else if (hitboxCheck == "Criti")
                {
                    //Debug.Log("Attempting to deal damage to: " + other.name);
                    percentGauge.DealDamage(damage * (1.25f), whoToDamage); //--Fix Indicator in method for who to damage
                }
            }
            else if (playerCheck == "2")
            {
                //Debug.Log("whoToDamage set to [2]");

                whoToDamage = 2;

                //Logic behind damage
                if (hitboxCheck == "Basic")
                {
                    //Debug.Log("Attempting to deal damage to: " + other.name);
                    percentGauge.DealDamage(damage, whoToDamage); //--Fix Indicator in method for who to damage
                }
                else if (hitboxCheck == "Criti")
                {
                    //Debug.Log("Attempting to deal damage to: " + other.name);
                    percentGauge.DealDamage(damage * (1.25f), whoToDamage); //--Fix Indicator in method for who to damage
                }
            }

            //Logic behind knockback
            //Debug.Log("Attempting to addForce to: " + collision.gameObject.name);

            Vector3 tempVector2 = gameObject.transform.TransformDirection(knockback_Angle); //-New Implementation

            /*Debug.Log("Knockback Method Call Parameters, knockback: [" + knockback_Strength + "], " +
             *  "attackDirection: [" + tempVector2 + "], attackOrigin: [" + gameObject.transform
             + "], toWhichPlayer: [" + whoToDamage + "]");
             */

            percentGauge.DealKnockback(knockback_Strength, tempVector2, gameObject.transform, whoToDamage);

            //Check if is a projectile, if is, destroy projectile --Put at end of logic
            if (GetComponent <FlyAtTarget>())
            {
                knockbackData.RemoveObserver(this);

                Destroy(gameObject);
            }
        }

        //Destroy(personalCollider);
        //personalCollider.isTrigger = false;
        //Disable collider ^^^
    }