1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 audio gets louder when player gets near the target

Discussion in 'Programming' started by Furiosposion, Aug 12, 2019.

  1. Furiosposion

    Furiosposion Member

    Joined:
    Aug 6, 2019
    Posts:
    17
    Code:
    Create:
    sound = audio_play_sound(sn_water,10,true);
    
    Step:
    if (o_player.x > x+32){
    audio_sound_gain(sound, ((obj_player.x-x+32)/32)/100, 1);
    
    }else
    
    if (o_player.x < x){
    audio_sound_gain(sound, ((x-obj_player)/32)/100, 1);}
    i do use this code for checking if player is getting near or far through the source of audio,
    this is water object and in 32x32 in tile, but this code works wrong as this: it gets louder when player is right side of the spot it starts get louder by every going far, and gets lower on every going near, but if player is on left side of spot it always stuck at 10.59
     
  2. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    326
    I think audio_play_sound_at is what you are missing.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice