Search Unity

Audio Audio while player moves

Discussion in 'Audio & Video' started by benjano, Nov 13, 2018.

  1. benjano

    benjano

    Joined:
    Dec 14, 2016
    Posts:
    6
    Hi,
    I'd need a script that plays an audio track while my character is moving and pause when he stops, of course.
    But the tricky part is that I want the audio continues where it has stopped as player moves forward.
    To make it simple, and audio that follows in his lenght the player, when he stops and when he walks.

    Can you help me? Thanks
     
  2. leftshoe18

    leftshoe18

    Joined:
    Jul 29, 2017
    Posts:
    61
  3. benjano

    benjano

    Joined:
    Dec 14, 2016
    Posts:
    6
    it could be! but how to connect it to the player movement?
    thank you
     
  4. leftshoe18

    leftshoe18

    Joined:
    Jul 29, 2017
    Posts:
    61
    You could pause the audio when there's no movement input or when the velocity has a magnitude of 0. Getting the velocity will depend on the way you're performing your movement.