Frictional Games Forum (read-only)

Full Version: Help - Play Music when I touch an object
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(07-11-2013, 07:32 PM)The chaser Wrote: [ -> ]Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this:

void Touch(string &in asEntity)
{
PlayMusic("music.ogg", false, 1, 1, 1, false);
}



Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.

that worked, but the song is only 7 seconds long, and i want the music that was originally playing to start playing again, cuz the song that plays when i touch the violin loops and i dont want it to, even though i put false.

(07-11-2013, 07:32 PM)The chaser Wrote: [ -> ]Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this:

void Touch(string &in asEntity)
{
PlayMusic("music.ogg", false, 1, 1, 1, false);
}



Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.

that worked, but the song is only 7 seconds long, and i want the music that was originally playing to start playing again, cuz the song that plays when i touch the violin loops and i dont want it to, even though i put false.
Use this one instead:



void Touch(string &in asEntity)

{

PlayMusic("music.ogg", true, 1, 0.1, 1, false);

}

That'll make the song loop Wink
(07-11-2013, 10:55 PM)The chaser Wrote: [ -> ]Use this one instead:



void Touch(string &in asEntity)

{

PlayMusic("music.ogg", true, 1, 0.1, 1, false);

}

That'll make the song loop Wink

No, i don't want it to loop, when you touch the violin i want the song to play once and then i want the music that was playing before you touched it to begin playing again. My problem is that the music when you touch the violin is looping even though i put false on the loop.
Oh, I see. Then, do this:

void Touch(string &in asEntity)



{

PlayMusic("music.ogg", false, 1, 0.1, 1, false);

AddTimer("", 7, "Replay");

}

void Replay (string &in asTimer)
{
PlayMusic("yourlevelmusic.ogg", true, 1, 1, 1, true);
}

That will make the music play, and, in 7 seconds, it will resume your level song. I think this should fix you error now Wink
(07-12-2013, 12:45 PM)The chaser Wrote: [ -> ]Oh, I see. Then, do this:

void Touch(string &in asEntity)



{

PlayMusic("music.ogg", false, 1, 0.1, 1, false);

AddTimer("", 7, "Replay");

}

void Replay (string &in asTimer)
{
PlayMusic("yourlevelmusic.ogg", true, 1, 1, 1, true);
}

That will make the music play, and, in 7 seconds, it will resume your level song. I think this should fix you error now Wink

thanks for your help! Everything works fine now! thank you Big Grin
Pages: 1 2