![]() If you want to distinguish between walking or jumping, you need to perform a couple of more checks, but nothing hard. The player sees questions (pics) and needs to guess the correct answer. Play sound if walk/jump on a musical blockĪs commented in code, this code may work both for jumping on top of or walking onto a musical block. Var curr_coll = place_meeting(x,y+1,oBlock) ![]() So, our full code will be: /// Step Event for object 'oPlayer' /// If we want to just play a sound only when landing on a musical key, we can write: if ( (curr_coll=1) & (prev_coll=0) ) You can use both a switch statement, or a chain of ifs, depending on your purpose. That said, we can write our code to check for the needed values. CC = 1, PC = 1 : there's always a collision with a given oBlock or whatever object, so the player is walking on top of it.Now you can play the proper musical sound 6 Broku 7:15am Originally posted by Forward Resent: Check your audio group settings at tools > audio group and also check the sound mixer settings found in tools. So, the player was in mid-air and is currently hitting the ground. Check your audio group settings at tools > audio group and also check the sound mixer settings found in tools. CC = 1, PC = 0 : there's a collision at the current step, and no collision a game step before.The sound can either be a single instance of a sound (the index for individual sounds being played can be stored in a variable when using the audioplaysound, audioplaysoundat, audioplaysoundon and audioplaysoundext functions) or a sound asset, in which case. This means the player has just performed a jump This function will check the given sound to see if it is currently playing. CC = 0, PC = 1 : no collision now, but collision detected in the previous step.CC = 0, PC = 0 : no collision both currently and previously, so the player has jumped and is in mid-air. ![]() So, we can have four different cases (CC: curr_coll, PC: prev_coll): As well, prev_coll does the same, but assuming the player position in the previous game step. Variables curr_coll is a boolean value that tells us if there's a collision with a block underneath the player at the current position. Var prev_coll = place_meeting(xprevious,yprevious+1,oBlock) Objects name are only indicative: var curr_coll = place_meeting(x,y+1,oBlock) Assuming that in the real world when someone jumps you hear a sound only in the very moment contact with the ground occurs, I managed to get the following code which checks for collision in the current position and in the previous one. I have my sounds set on timers.I solved this problem without using any additional variables, just collision checking function. I don't know what the problem really is here so if you need more into, please tell me what else to screenshotĪnd incase someone is wondering, I set it to False so it wouldn't repeat the instant it ended. I went over the codes again, deleted all but the ones I knew worked fine, but I can't get the audio to play at all anymore ![]() but then while making adjustments to make sure all worked correctly, they just suddenly stopped. I did the audio_play_sound like I was supposed to, and at first all the sounds worked. I've been having trouble with my automatic sounds lately.
0 Comments
Leave a Reply. |