Пример #1
0
    //changed 'OnCollisionEnter()' to 'OnTriggerEnter()' -Joey
    public void OnTriggerEnter(Collider other)
    {
        if (canCollide)
        {
            //Since the rigidbody is on the car, we will check if we can get the vehicle manager and then the player manager from there
            //changed 'GetComponent<>()' to 'GetComponentInParent<>()' -Joey
            TempVehicleManager vehicle = other.gameObject.GetComponentInParent <TempVehicleManager>();

            if (vehicle != null)
            {
                PlayerManager player = vehicle.playerManager;

                //If we can hit the owner or this is a different player
                if (canHitOwner || !player.Equals(owner))
                {
                    //Apply damage and disable collisions so that it does not hit the same object again this frame before it is destroyed
                    player.ApplyDamage(damage);
                    canCollide = false;
                    Destroy(gameObject); //cleaner form of self destroy -Joey
                }
            }                            //destroys the projectile upon collision with anything other than a vehicle
            if (vehicle == null)
            {
                Destroy(gameObject);
            }
        }
    }
Пример #2
0
    public void OnTriggerEnter(Collider other)
    {
        TempVehicleManager tempVehicleManager = other.GetComponentInParent <TempVehicleManager>();

        //Checks for tempVehicleManager then takes player's PlayerManager to add energy.
        if (tempVehicleManager != null)
        {
            PlayerManager playerManager = tempVehicleManager.playerManager;

            playerManager.ClearCheckpoint(checkpointID);
            lightBeams[(int)playerManager.id].SetActive(false);
        }
    }
Пример #3
0
    public void OnTriggerEnter(Collider other)
    {
        TempVehicleManager tempVehicleManager = other.GetComponentInParent <TempVehicleManager>();

        //Checks for tempVehicleManager then takes player's PlayerManager to add energy.
        if (tempVehicleManager != null)
        {
            PlayerManager playerManager = tempVehicleManager.playerManager;

            playerManager.GainEnergy(addedEnergy);
            StartCoroutine(SpawnDelay());
        }
    }