interpolating a sound with the actors x position

digitalzerodigitalzero Member, BASIC Posts: 639

so i want to know how to make the sound which is a looping sound get louder as the character gets closer to the actor and starts to get more quiet as the character gets further away from the actor

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    I think you'd have to use the magnitude function to keep track of the distance between the two actors and then increase or decrease the volume as needed.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    There is the option of Positional Sound but that doesn't account for actors positions away from each other. I believe that adjusts volume level based on the cameras distance from the sound.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    yea, track the magnitude from the character to the actor. It will output the number of pixels away.

    Audio is calculated on a 0 to 1 scale, 1 being loudest.
    So depending on how far away you want the volume to work, maybe have something like

    constrain game.sound to 1-magnitude(actorX-characterX,actorY,characterY)/500

    so if you actor was 400 pixels away your audio would be .2,
    if your actor was 100 pixels away, your audio would be .8

  • digitalzerodigitalzero Member, BASIC Posts: 639

    WOW this forum is the best and the community is awesome! i really appreciate it all from you guys! you all are helping me make this game awesome!!!!!!!!!

Sign In or Register to comment.