Forum rules - please read before posting.

Is there a way to change the Walk, Run etc. sound details by script?

edited July 2018 in Technical Q&A
As the title says, I hope to control the playing of Walk & Run sound by script. So that sometimes it would play and sometimes it wouldn't, or even change the sound source base on the game situation. How may I do that?

Comments

  • The "Footstep sounds" component provides more control over sound playback than the simple method of assigning audio clips directly in the Player/NPC Inspectors.

    With this method, you can use the dedicated Sound: Change footsteps Action to change the the clips at runtime.  Assigning "empty" clips would allow you to prevent sound from playing, and you can place instances of this Action in ActionList Asset files to use re-use them throughout your game.

    For more, see the Manual's "Footstep sounds" chapter.
  • edited July 2018
    When using the "Footstep sounds" component, how should I call the PlayFootstep function? Can it be called in a custom script? I prefer the footstep only plays when the walking animation is playing.

    I tried to make a Public FootstepSounds fs and drag the FootstepSounds child into it, then call fs.PlayFootstep (); but without success.
  • There's two ways to do it, and you first have to select which method via the Inspector's Play sounds field.

    The default option is Via Animation Events, which means you call the PlayFootstep method through events attached to your animations - see Animation Events.

    You can alternatively call this method through a custom script.  Bear in mind that if your Character field is assigned (or the component is attached to your character's root object), then that character must also be moving at the time.  If you're having trouble with this approach, please share more details in the form of version numbers and screenshots of the relevant Inspectors.

    The other field option is Automatically, which has AC playback sounds for you based on movement speed.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.