Results 1 to 7 of 7
  1. #1
    MSgt. Shooter Person
    Join Date
    Apr 2008
    Posts
    290

    Default How to determine if sound has finished playing

    Hello, noob question here.

    Is there a way to determine via scripting that a sound that I previously played has finished playing??

    Thanks in advance!

  2. #2
    Boomshot

    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    2,168

    Default

    I never worked with sound actors, but maybe you can use the property Duration (float Duration (native, const)). Make something like a timer and when you make the sound play, activate the timer that will increase the value of a new variable. If the new variable's value is equal to Duration the sound has ended.

  3. #3
    MSgt. Shooter Person
    Join Date
    Apr 2008
    Posts
    290

    Default

    So basically you would have to know how long the sound is, hrm.

    While I could see it working, it's gonna be quite a hassle to time the sounds I would play lol

  4. #4
    Redeemer
    Join Date
    Jan 2004
    Location
    The great Pacific Northwest
    Posts
    1,435

    Default

    Try using the function GetSoundDuration (defined in actor.uc) to grab the duration of the sound that is going to be played.
    "What do you mean it doesn't exist clientside?"
    YARM: where player's Lean, Prone, Mantle, Dash, Crouch Jump, 'Parkour' and slide around all with generic realistic weapons!
    My Generic Mods for UT2K4:
    Yet Another Real-life Mod: Realistic weapons, unoriginal gameplay, w/ cheap CODMW knockoff mutator
    TD Vehicles: HUMV, MI4Hound, Motorcycle, IFAV Jeep, UH-60, MH-53 & AH-6 Helicopters, Abrams Tank

  5. #5
    Boomshot

    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    2,168

    Default

    That is what I was talking about. There is a variable in the class Sound that holds the duration of the sound.

    So you would have your sound variable:
    Code:
    var sound MySound;
    Set in default properties for the package, groupd and file:
    Code:
    DefaultProperties
    {
         MySound=Sound'MyPackage.MyGroup.MySound'
    }
    Then you would be able to know the duration of the sound with:
    Code:
    MySound.Duration;

  6. #6
    MSgt. Shooter Person
    Join Date
    Apr 2008
    Posts
    290

    Default

    ohhhhh I see i see...I didn't know that the sound class had a public property for duration lol

    I also didn't knew there was a getsoundduration either...interesting.

    I'm guessing I should use that level.seconds or level.timeinseconds or whatever it is( that method or property that gives you the time in seconds of which the name I can't remember) then equate it if it's already equal to the duration or something to that extent

    anyway, thanks you two!

  7. #7

    Default

    The Duration property might be invalid for ProceduralSounds and SoundGroups. GetSoundDuration() probably is the way to go, though keep in mind it returns real time seconds, while functions like Sleep() expect game seconds. You will have to scale by Level.TimeDilation there.
    Wormbo's UT/UT2004/UT3 mods | PlanetJailbreak | Unreal Wiki | Liandri Archives

    <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
    <TNSe> nono
    <TNSe> its always funny to find code a week later you dont even remember writing
    <Pfhoenix> what's worse is when you have a Star Wars moment
    <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
    Note that your questions via PMs will be ignored if they actually belong in the forum.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.