Announcement

Collapse
No announcement yet.

Playsound pre-fire? (ChargeSound)- [Solved]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Playsound pre-fire? (ChargeSound)- [Solved]

    • [Original Query] Why does the sound not play when charging? but it plays for primary and secondary fire.
    • [Code below contains the FIX]


     
    Spoiler

    Many Thanks

    #2
    FYI Wall-of-text

    You have to create an AudioComponent either on runtime or on designtime.

    Code:
    function PlayChargeSound(SoundCue NewSound)
    {
        If (NewSound == None)
            Return;
    
        if (AudioComp == none)
            AudioComp = CreateAudioComponent(NewSound, false, true);
        else if (AudioComp.IsPlaying())
            AudioComp.Stop();
    
        AudioComp.SoundCue = NewSound;
        AudioComp.Play();
    }
    Besure to test this in a standalone match (instant action) as you're probably missing replication.

    Comment


      #3
      too late i solved it myself#
      Code:
      Simulated Function ChargeStarted()
      {
      local UTPawn POwner;
      
          // Play any extra effects you want here
          //PlayChargeSound(ChargeData[CurrentChargeLevel].ChargingSFX);
          POwner = UTPawn(Instigator);
                  if (POwner != None)
              {
                  POwner.SetWeaponAmbientSound((CurrentFireMode == 0) ? WeaponChargeSnd : WeaponEmpChargeSnd);
              PlayChargeSound(ChargeData[CurrentChargeLevel].ChargingSFX);
              }
      }
      
      Simulated Function ChargeFinished()
      {
      local UTPawn POwner;
          // Play any extra effects you want here
          // Turn Off sound 0
              POwner = UTPawn(Instigator);
                  if (POwner != None)
              {
                  POwner.SetWeaponAmbientSound(None);
              }
      }
      but i do appreciate the reply.
      • i think what i did only works client side,
      • I like to hear the power up of my enemy so i know whats coming.

      • (edit; i guess thats what your saying right?)

      Comment

      Working...
      X