예제 #1
0
    private void OnTriggerEnter(Collider other)                  //when the player starts wallriding,
                                                                 //which means to enter the second box collider of each wall
    {
        if (other.tag == "RightWall" || other.tag == "LeftWall") //check if player is wallriding ,no matter which wall
        {
            WallRiding = true;
            if (other.tag == "RightWall")
            {
                RightRide = true;
            }
            else if (other.tag == "LeftWall")
            {
                LeftRide = true;
            }
        }

        if (other.tag == "Spikes" || other.tag == "LongSpikes")   //when player enters spikes' trigger collider, trigger DeathState
        {
            if (PlayerStates.isShielded)
            {
                other.gameObject.SetActive(false); //disable spike so the player will continue descent

                ShieldPowerUp.ShieldDestroyed();
            }
            else
            {
                PlayerStates.DeathState();
            }
        }
    }