PlayerSfxScript.playMeleeSound C# (CSharp) Method

playMeleeSound() public static method

public static playMeleeSound ( ) : void
return void
    public static void playMeleeSound()
    {
        float vol = Random.Range(instance.volLowRange, instance.volHighRange);
        instance.sound.PlayOneShot(instance.meleeSound, vol);
    }

Usage Example

Ejemplo n.º 1
0
    void Update()
    {
        // Regenerate the energy/mana bar after a specified amount of time
        if (Time.time > nextTime)
        {
            nextTime = Time.time + 1f;
            if (cooldown != 100f)
            {
                cooldown += regen;
            }
            UpdateCoolDownSlider();
        }

        // Perform a basic melee attack
        if (Input.GetKeyDown(KeyCode.J) && Time.time > nextMelee)
        {
            // Playsound, animate and attack
            PlayerSfxScript.playMeleeSound();
            anim.SetTrigger("Melee");
            // Pauses to sync up more with the animation
            Invoke("AttactInstantiate", 0.15f);
            nextMelee = Time.time + meleeRate;
        }
    }